From a367c7f04d42192b32558242eb859452689f02f0 Mon Sep 17 00:00:00 2001 From: DmitriyMX Date: Tue, 18 Dec 2018 12:52:10 +0300 Subject: [PATCH] tabs -> spaces --- .../flibitijibibo/flibitEFX/EFXEffect.java | 86 +- .../flibitEFX/EFXEffectEcho.java | 130 +- .../flibitEFX/EFXEffectReverb.java | 14 +- .../flibitEFX/EFXEffectRingModulator.java | 84 +- .../flibitijibibo/flibitEFX/EFXFilter.java | 62 +- .../flibitEFX/EFXFilterLowPass.java | 36 +- src/main/java/lwjake2/Defines.java | 74 +- src/main/java/lwjake2/Globals.java | 618 +- src/main/java/lwjake2/LWJake2.java | 54 +- src/main/java/lwjake2/client/CL.java | 22 +- src/main/java/lwjake2/client/CL_ents.java | 2342 +++---- src/main/java/lwjake2/client/CL_fx.java | 4258 ++++++------- src/main/java/lwjake2/client/CL_input.java | 1144 ++-- src/main/java/lwjake2/client/CL_inv.java | 180 +- src/main/java/lwjake2/client/CL_newfx.java | 80 +- src/main/java/lwjake2/client/CL_parse.java | 24 +- src/main/java/lwjake2/client/CL_tent.java | 156 +- src/main/java/lwjake2/client/Console.java | 2 +- src/main/java/lwjake2/client/Key.java | 1546 ++--- src/main/java/lwjake2/client/M.java | 18 +- src/main/java/lwjake2/client/Menu.java | 124 +- src/main/java/lwjake2/client/SCR.java | 24 +- src/main/java/lwjake2/client/V.java | 4 +- src/main/java/lwjake2/client/VID.java | 1340 ++-- src/main/java/lwjake2/client/centity_t.java | 14 +- .../java/lwjake2/client/cl_sustain_t.java | 46 +- .../java/lwjake2/client/client_state_t.java | 158 +- .../java/lwjake2/client/client_static_t.java | 64 +- .../java/lwjake2/client/clientinfo_t.java | 46 +- src/main/java/lwjake2/client/console_t.java | 24 +- src/main/java/lwjake2/client/cparticle_t.java | 18 +- src/main/java/lwjake2/client/dlight_t.java | 6 +- src/main/java/lwjake2/client/entity_t.java | 108 +- src/main/java/lwjake2/client/frame_t.java | 60 +- src/main/java/lwjake2/client/kbutton_t.java | 8 +- .../java/lwjake2/client/lightstyle_t.java | 4 +- src/main/java/lwjake2/client/particle_t.java | 34 +- src/main/java/lwjake2/client/refdef_t.java | 30 +- src/main/java/lwjake2/client/refexport_t.java | 126 +- src/main/java/lwjake2/client/viddef_t.java | 2 +- src/main/java/lwjake2/client/vidmode_t.java | 20 +- src/main/java/lwjake2/client/vrect_t.java | 10 +- src/main/java/lwjake2/game/AIAdapter.java | 2 +- src/main/java/lwjake2/game/Cmd.java | 10 +- .../java/lwjake2/game/EdictFindFilter.java | 8 +- src/main/java/lwjake2/game/EdictIterator.java | 12 +- src/main/java/lwjake2/game/EndianHandler.java | 68 +- .../java/lwjake2/game/EntBlockedAdapter.java | 4 +- src/main/java/lwjake2/game/EntDieAdapter.java | 2 +- .../java/lwjake2/game/EntDodgeAdapter.java | 2 +- .../java/lwjake2/game/EntInteractAdapter.java | 2 +- .../java/lwjake2/game/EntPainAdapter.java | 2 +- .../java/lwjake2/game/EntThinkAdapter.java | 2 +- .../java/lwjake2/game/EntTouchAdapter.java | 2 +- src/main/java/lwjake2/game/EntUseAdapter.java | 2 +- src/main/java/lwjake2/game/GameAI.java | 2 +- src/main/java/lwjake2/game/GameBase.java | 14 +- src/main/java/lwjake2/game/GameCombat.java | 4 +- src/main/java/lwjake2/game/GameFunc.java | 14 +- src/main/java/lwjake2/game/GameItemList.java | 1454 ++--- src/main/java/lwjake2/game/GameMisc.java | 4 +- src/main/java/lwjake2/game/GameSVCmds.java | 2 +- src/main/java/lwjake2/game/GameSave.java | 146 +- src/main/java/lwjake2/game/GameSpawn.java | 56 +- src/main/java/lwjake2/game/GameTarget.java | 46 +- src/main/java/lwjake2/game/GameTrigger.java | 26 +- src/main/java/lwjake2/game/GameTurret.java | 16 +- src/main/java/lwjake2/game/GameUtil.java | 10 +- src/main/java/lwjake2/game/GameWeapon.java | 14 +- src/main/java/lwjake2/game/Info.java | 6 +- .../java/lwjake2/game/ItemDropAdapter.java | 4 +- .../java/lwjake2/game/ItemUseAdapter.java | 4 +- src/main/java/lwjake2/game/Monster.java | 10 +- src/main/java/lwjake2/game/PlayerClient.java | 30 +- src/main/java/lwjake2/game/PlayerView.java | 10 +- src/main/java/lwjake2/game/PlayerWeapon.java | 48 +- src/main/java/lwjake2/game/SuperAdapter.java | 42 +- .../lwjake2/game/client_persistant_t.java | 212 +- .../java/lwjake2/game/client_respawn_t.java | 112 +- src/main/java/lwjake2/game/cmdalias_t.java | 6 +- src/main/java/lwjake2/game/cmodel_t.java | 8 +- src/main/java/lwjake2/game/cplane_t.java | 48 +- src/main/java/lwjake2/game/csurface_t.java | 6 +- src/main/java/lwjake2/game/cvar_t.java | 14 +- .../java/lwjake2/game/entity_state_t.java | 252 +- src/main/java/lwjake2/game/game_import_t.java | 2 +- src/main/java/lwjake2/game/game_locals_t.java | 6 +- src/main/java/lwjake2/game/gclient_t.java | 784 +-- src/main/java/lwjake2/game/gitem_armor_t.java | 36 +- .../java/lwjake2/game/level_locals_t.java | 222 +- src/main/java/lwjake2/game/link_t.java | 10 +- src/main/java/lwjake2/game/mapsurface_t.java | 4 +- src/main/java/lwjake2/game/mframe_t.java | 50 +- src/main/java/lwjake2/game/mmove_t.java | 92 +- src/main/java/lwjake2/game/monsterinfo_t.java | 228 +- .../java/lwjake2/game/monsters/M_Actor.java | 10 +- .../java/lwjake2/game/monsters/M_Berserk.java | 2 +- .../java/lwjake2/game/monsters/M_Boss2.java | 44 +- .../java/lwjake2/game/monsters/M_Boss3.java | 4 +- .../java/lwjake2/game/monsters/M_Boss31.java | 44 +- .../java/lwjake2/game/monsters/M_Boss32.java | 64 +- .../java/lwjake2/game/monsters/M_Brain.java | 68 +- .../java/lwjake2/game/monsters/M_Chick.java | 50 +- .../java/lwjake2/game/monsters/M_Flash.java | 460 +- .../java/lwjake2/game/monsters/M_Flipper.java | 30 +- .../java/lwjake2/game/monsters/M_Float.java | 38 +- .../java/lwjake2/game/monsters/M_Flyer.java | 46 +- .../lwjake2/game/monsters/M_Gladiator.java | 34 +- .../java/lwjake2/game/monsters/M_Gunner.java | 48 +- .../java/lwjake2/game/monsters/M_Hover.java | 34 +- .../lwjake2/game/monsters/M_Infantry.java | 44 +- .../java/lwjake2/game/monsters/M_Insane.java | 48 +- .../java/lwjake2/game/monsters/M_Medic.java | 46 +- .../java/lwjake2/game/monsters/M_Mutant.java | 74 +- .../lwjake2/game/monsters/M_Parasite.java | 48 +- .../java/lwjake2/game/monsters/M_Player.java | 2 +- .../java/lwjake2/game/monsters/M_Soldier.java | 72 +- .../lwjake2/game/monsters/M_Supertank.java | 32 +- .../java/lwjake2/game/monsters/M_Tank.java | 42 +- src/main/java/lwjake2/game/moveinfo_t.java | 136 +- .../java/lwjake2/game/player_state_t.java | 242 +- src/main/java/lwjake2/game/pmove_state_t.java | 196 +- src/main/java/lwjake2/game/pushed_t.java | 8 +- src/main/java/lwjake2/game/spawn_t.java | 12 +- src/main/java/lwjake2/game/spawn_temp_t.java | 190 +- src/main/java/lwjake2/game/trace_t.java | 64 +- src/main/java/lwjake2/game/usercmd_t.java | 74 +- .../lwjake2/qcommon/BaseQ2FileSystem.java | 8 +- src/main/java/lwjake2/qcommon/CM.java | 2 +- src/main/java/lwjake2/qcommon/CRC.java | 150 +- src/main/java/lwjake2/qcommon/Com.java | 712 +-- src/main/java/lwjake2/qcommon/Cvar.java | 2 +- src/main/java/lwjake2/qcommon/MD4.java | 480 +- src/main/java/lwjake2/qcommon/PMove.java | 22 +- src/main/java/lwjake2/qcommon/Qcommon.java | 352 +- src/main/java/lwjake2/qcommon/SZ.java | 136 +- .../java/lwjake2/qcommon/cmd_function_t.java | 6 +- src/main/java/lwjake2/qcommon/lump_t.java | 12 +- src/main/java/lwjake2/qcommon/miptex_t.java | 28 +- src/main/java/lwjake2/qcommon/netadr_t.java | 4 +- src/main/java/lwjake2/qcommon/netchan_t.java | 4 +- src/main/java/lwjake2/qcommon/qfiles.java | 1270 ++-- src/main/java/lwjake2/qcommon/sizebuf_t.java | 28 +- src/main/java/lwjake2/qcommon/texinfo_t.java | 50 +- .../java/lwjake2/render/DummyRenderer.java | 266 +- .../java/lwjake2/render/LWJGLRenderer.java | 334 +- src/main/java/lwjake2/render/Ref.java | 12 +- src/main/java/lwjake2/render/Renderer.java | 108 +- src/main/java/lwjake2/render/glconfig_t.java | 30 +- src/main/java/lwjake2/render/glpoly_t.java | 82 +- src/main/java/lwjake2/render/glstate_t.java | 24 +- src/main/java/lwjake2/render/image_t.java | 94 +- .../java/lwjake2/render/lwjgl/Anorms.java | 368 +- src/main/java/lwjake2/render/lwjgl/Draw.java | 604 +- src/main/java/lwjake2/render/lwjgl/Image.java | 3098 ++++----- .../java/lwjake2/render/lwjgl/LWJGLBase.java | 564 +- src/main/java/lwjake2/render/lwjgl/Light.java | 750 +-- src/main/java/lwjake2/render/lwjgl/Main.java | 2906 ++++----- src/main/java/lwjake2/render/lwjgl/Mesh.java | 1284 ++-- src/main/java/lwjake2/render/lwjgl/Misc.java | 434 +- src/main/java/lwjake2/render/lwjgl/Model.java | 2624 ++++---- .../java/lwjake2/render/lwjgl/Polygon.java | 208 +- src/main/java/lwjake2/render/lwjgl/Surf.java | 2478 ++++---- src/main/java/lwjake2/render/lwjgl/Warp.java | 1056 ++-- src/main/java/lwjake2/render/mleaf_t.java | 52 +- src/main/java/lwjake2/render/mmodel_t.java | 12 +- src/main/java/lwjake2/render/mnode_t.java | 26 +- src/main/java/lwjake2/render/model_t.java | 248 +- src/main/java/lwjake2/render/msurface_t.java | 108 +- src/main/java/lwjake2/render/mtexinfo_t.java | 40 +- src/main/java/lwjake2/server/SV.java | 62 +- src/main/java/lwjake2/server/SV_CCMDS.java | 2000 +++--- src/main/java/lwjake2/server/SV_ENTS.java | 10 +- src/main/java/lwjake2/server/SV_GAME.java | 2 +- src/main/java/lwjake2/server/SV_INIT.java | 12 +- src/main/java/lwjake2/server/SV_MAIN.java | 6 +- src/main/java/lwjake2/server/SV_SEND.java | 860 +-- src/main/java/lwjake2/server/SV_USER.java | 14 +- src/main/java/lwjake2/server/areanode_t.java | 18 +- src/main/java/lwjake2/server/challenge_t.java | 8 +- .../java/lwjake2/server/client_frame_t.java | 12 +- src/main/java/lwjake2/server/client_t.java | 74 +- src/main/java/lwjake2/server/moveclip_t.java | 42 +- src/main/java/lwjake2/sound/DummyDriver.java | 126 +- src/main/java/lwjake2/sound/S.java | 362 +- src/main/java/lwjake2/sound/Sound.java | 128 +- src/main/java/lwjake2/sound/WaveLoader.java | 442 +- .../java/lwjake2/sound/lwjgl/Channel.java | 536 +- .../lwjake2/sound/lwjgl/LWJGLSoundImpl.java | 884 +-- .../java/lwjake2/sound/lwjgl/PlaySound.java | 48 +- src/main/java/lwjake2/sound/sfx_t.java | 32 +- src/main/java/lwjake2/sound/sfxcache_t.java | 20 +- src/main/java/lwjake2/sound/soundinfo_t.java | 12 +- src/main/java/lwjake2/sound/wavinfo_t.java | 12 +- src/main/java/lwjake2/sys/IN.java | 34 +- src/main/java/lwjake2/sys/InputListener.java | 120 +- src/main/java/lwjake2/sys/JOGLKBD.java | 388 +- src/main/java/lwjake2/sys/KBD.java | 30 +- src/main/java/lwjake2/sys/LWJGLKBD.java | 366 +- .../java/lwjake2/sys/LWJake2InputEvent.java | 30 +- src/main/java/lwjake2/sys/NET.java | 4 +- src/main/java/lwjake2/sys/NanoTimer.java | 26 +- src/main/java/lwjake2/sys/StandardTimer.java | 28 +- src/main/java/lwjake2/sys/Sys.java | 4 +- src/main/java/lwjake2/sys/Timer.java | 32 +- src/main/java/lwjake2/util/Lib.java | 634 +- src/main/java/lwjake2/util/Math3D.java | 836 +-- src/main/java/lwjake2/util/PrintfFormat.java | 5544 ++++++++--------- src/main/java/lwjake2/util/Vargs.java | 138 +- 209 files changed, 27345 insertions(+), 27345 deletions(-) diff --git a/src/main/java/com/flibitijibibo/flibitEFX/EFXEffect.java b/src/main/java/com/flibitijibibo/flibitEFX/EFXEffect.java index 0522e92..ff69e77 100644 --- a/src/main/java/com/flibitijibibo/flibitEFX/EFXEffect.java +++ b/src/main/java/com/flibitijibibo/flibitEFX/EFXEffect.java @@ -25,47 +25,47 @@ import org.lwjgl.openal.EFX10; */ public abstract class EFXEffect { - - private int slotIndex; - private int effectIndex; - - /** Constructor creates an EFX effect slot containing an effect. - * @param efxEffect The EFX10 effect type (i.e. EFX10.AL_EFFECT_REVERB) - */ - public EFXEffect(int efxEffect) { - slotIndex = EFX10.alGenAuxiliaryEffectSlots(); - effectIndex = EFX10.alGenEffects(); - // TODO: Check to see if efxEffect is a valid AL_EFFECT_TYPE. - EFX10.alEffecti(effectIndex, EFX10.AL_EFFECT_TYPE, efxEffect); - EFX10.alAuxiliaryEffectSloti(slotIndex, EFX10.AL_EFFECTSLOT_EFFECT, effectIndex); - } - - /** Unloads the EFX effect and effect slot. */ - public void killEffect() { - EFX10.alDeleteEffects(effectIndex); - EFX10.alDeleteAuxiliaryEffectSlots(slotIndex); - } - - /** Returns the index of the EFX effect slot. - * @return The index of the EFX effect slot - */ - public int getIndex() { - return slotIndex; - } - - /** Applies an effect property to this EFX effect. - * @param passedProperty The EFX10 effect property - * @param passedValue The EFX10 effect value - */ - protected void addEffectf(int passedProperty, float passedValue) { - EFX10.alEffectf(effectIndex, passedProperty, passedValue); - } - - /** Applies an effect property to this EFX effect. - * @param passedProperty The EFX10 effect property - * @param passedValue The EFX10 effect value - */ - protected void addEffecti(int passedProperty, int passedValue) { - EFX10.alEffecti(effectIndex, passedProperty, passedValue); - } + + private int slotIndex; + private int effectIndex; + + /** Constructor creates an EFX effect slot containing an effect. + * @param efxEffect The EFX10 effect type (i.e. EFX10.AL_EFFECT_REVERB) + */ + public EFXEffect(int efxEffect) { + slotIndex = EFX10.alGenAuxiliaryEffectSlots(); + effectIndex = EFX10.alGenEffects(); + // TODO: Check to see if efxEffect is a valid AL_EFFECT_TYPE. + EFX10.alEffecti(effectIndex, EFX10.AL_EFFECT_TYPE, efxEffect); + EFX10.alAuxiliaryEffectSloti(slotIndex, EFX10.AL_EFFECTSLOT_EFFECT, effectIndex); + } + + /** Unloads the EFX effect and effect slot. */ + public void killEffect() { + EFX10.alDeleteEffects(effectIndex); + EFX10.alDeleteAuxiliaryEffectSlots(slotIndex); + } + + /** Returns the index of the EFX effect slot. + * @return The index of the EFX effect slot + */ + public int getIndex() { + return slotIndex; + } + + /** Applies an effect property to this EFX effect. + * @param passedProperty The EFX10 effect property + * @param passedValue The EFX10 effect value + */ + protected void addEffectf(int passedProperty, float passedValue) { + EFX10.alEffectf(effectIndex, passedProperty, passedValue); + } + + /** Applies an effect property to this EFX effect. + * @param passedProperty The EFX10 effect property + * @param passedValue The EFX10 effect value + */ + protected void addEffecti(int passedProperty, int passedValue) { + EFX10.alEffecti(effectIndex, passedProperty, passedValue); + } } \ No newline at end of file diff --git a/src/main/java/com/flibitijibibo/flibitEFX/EFXEffectEcho.java b/src/main/java/com/flibitijibibo/flibitEFX/EFXEffectEcho.java index 9e46ef3..a9ca33f 100644 --- a/src/main/java/com/flibitijibibo/flibitEFX/EFXEffectEcho.java +++ b/src/main/java/com/flibitijibibo/flibitEFX/EFXEffectEcho.java @@ -25,69 +25,69 @@ import org.lwjgl.openal.EFX10; */ public class EFXEffectEcho extends EFXEffect { - - /** Constructor creates a generic echo effect. */ - public EFXEffectEcho() { - super(EFX10.AL_EFFECT_ECHO); - } - - /** Sets the amount of high frequency damping to apply to the echo effect. - * @param passedValue The new damping value to apply to the echo effect - */ - public void setDamping(float passedValue) { - if (passedValue < EFX10.AL_ECHO_MIN_DAMPING) - addEffectf(EFX10.AL_ECHO_DAMPING, EFX10.AL_ECHO_MIN_DAMPING); - else if (passedValue > EFX10.AL_ECHO_MAX_DAMPING) - addEffectf(EFX10.AL_ECHO_DAMPING, EFX10.AL_ECHO_MAX_DAMPING); - else - addEffectf(EFX10.AL_ECHO_DAMPING, passedValue); - } - - /** Sets the echo effect's delay time. - * @param passedValue The echo effect's new delay time - */ - public void setDelay(float passedValue) { - if (passedValue < EFX10.AL_ECHO_MIN_DELAY) - addEffectf(EFX10.AL_ECHO_DELAY, EFX10.AL_ECHO_MIN_DELAY); - else if (passedValue > EFX10.AL_ECHO_MAX_DELAY) - addEffectf(EFX10.AL_ECHO_DELAY, EFX10.AL_ECHO_MAX_DELAY); - else - addEffectf(EFX10.AL_ECHO_DELAY, passedValue); - } - - /** Sets the amount of feedback to echo back. - * @param passedValue The new feedback volume of the echo effect - */ - public void setFeedback(float passedValue) { - if (passedValue < EFX10.AL_ECHO_MIN_FEEDBACK) - addEffectf(EFX10.AL_ECHO_FEEDBACK, EFX10.AL_ECHO_MIN_FEEDBACK); - else if (passedValue > EFX10.AL_ECHO_MAX_FEEDBACK) - addEffectf(EFX10.AL_ECHO_FEEDBACK, EFX10.AL_ECHO_MAX_FEEDBACK); - else - addEffectf(EFX10.AL_ECHO_FEEDBACK, passedValue); - } - - /** Sets the delay between each echo "tap". - * @param passedValue The new delay time between each echo "tap" - */ - public void setLRDelay(float passedValue) { - if (passedValue < EFX10.AL_ECHO_MIN_LRDELAY) - addEffectf(EFX10.AL_ECHO_LRDELAY, EFX10.AL_ECHO_MIN_LRDELAY); - else if (passedValue > EFX10.AL_ECHO_MAX_LRDELAY) - addEffectf(EFX10.AL_ECHO_LRDELAY, EFX10.AL_ECHO_MAX_LRDELAY); - else - addEffectf(EFX10.AL_ECHO_LRDELAY, passedValue); - } - - /** Sets the amount of hard panning allowed for each echo. - * @param passedValue The new level of flexibility for the echo effect's panning - */ - public void setSpread(float passedValue) { - if (passedValue < EFX10.AL_ECHO_MIN_SPREAD) - addEffectf(EFX10.AL_ECHO_SPREAD, EFX10.AL_ECHO_MIN_SPREAD); - else if (passedValue > EFX10.AL_ECHO_MAX_SPREAD) - addEffectf(EFX10.AL_ECHO_SPREAD, EFX10.AL_ECHO_MAX_SPREAD); - else - addEffectf(EFX10.AL_ECHO_SPREAD, passedValue); - } + + /** Constructor creates a generic echo effect. */ + public EFXEffectEcho() { + super(EFX10.AL_EFFECT_ECHO); + } + + /** Sets the amount of high frequency damping to apply to the echo effect. + * @param passedValue The new damping value to apply to the echo effect + */ + public void setDamping(float passedValue) { + if (passedValue < EFX10.AL_ECHO_MIN_DAMPING) + addEffectf(EFX10.AL_ECHO_DAMPING, EFX10.AL_ECHO_MIN_DAMPING); + else if (passedValue > EFX10.AL_ECHO_MAX_DAMPING) + addEffectf(EFX10.AL_ECHO_DAMPING, EFX10.AL_ECHO_MAX_DAMPING); + else + addEffectf(EFX10.AL_ECHO_DAMPING, passedValue); + } + + /** Sets the echo effect's delay time. + * @param passedValue The echo effect's new delay time + */ + public void setDelay(float passedValue) { + if (passedValue < EFX10.AL_ECHO_MIN_DELAY) + addEffectf(EFX10.AL_ECHO_DELAY, EFX10.AL_ECHO_MIN_DELAY); + else if (passedValue > EFX10.AL_ECHO_MAX_DELAY) + addEffectf(EFX10.AL_ECHO_DELAY, EFX10.AL_ECHO_MAX_DELAY); + else + addEffectf(EFX10.AL_ECHO_DELAY, passedValue); + } + + /** Sets the amount of feedback to echo back. + * @param passedValue The new feedback volume of the echo effect + */ + public void setFeedback(float passedValue) { + if (passedValue < EFX10.AL_ECHO_MIN_FEEDBACK) + addEffectf(EFX10.AL_ECHO_FEEDBACK, EFX10.AL_ECHO_MIN_FEEDBACK); + else if (passedValue > EFX10.AL_ECHO_MAX_FEEDBACK) + addEffectf(EFX10.AL_ECHO_FEEDBACK, EFX10.AL_ECHO_MAX_FEEDBACK); + else + addEffectf(EFX10.AL_ECHO_FEEDBACK, passedValue); + } + + /** Sets the delay between each echo "tap". + * @param passedValue The new delay time between each echo "tap" + */ + public void setLRDelay(float passedValue) { + if (passedValue < EFX10.AL_ECHO_MIN_LRDELAY) + addEffectf(EFX10.AL_ECHO_LRDELAY, EFX10.AL_ECHO_MIN_LRDELAY); + else if (passedValue > EFX10.AL_ECHO_MAX_LRDELAY) + addEffectf(EFX10.AL_ECHO_LRDELAY, EFX10.AL_ECHO_MAX_LRDELAY); + else + addEffectf(EFX10.AL_ECHO_LRDELAY, passedValue); + } + + /** Sets the amount of hard panning allowed for each echo. + * @param passedValue The new level of flexibility for the echo effect's panning + */ + public void setSpread(float passedValue) { + if (passedValue < EFX10.AL_ECHO_MIN_SPREAD) + addEffectf(EFX10.AL_ECHO_SPREAD, EFX10.AL_ECHO_MIN_SPREAD); + else if (passedValue > EFX10.AL_ECHO_MAX_SPREAD) + addEffectf(EFX10.AL_ECHO_SPREAD, EFX10.AL_ECHO_MAX_SPREAD); + else + addEffectf(EFX10.AL_ECHO_SPREAD, passedValue); + } } \ No newline at end of file diff --git a/src/main/java/com/flibitijibibo/flibitEFX/EFXEffectReverb.java b/src/main/java/com/flibitijibibo/flibitEFX/EFXEffectReverb.java index 87b13c0..3fe2762 100644 --- a/src/main/java/com/flibitijibibo/flibitEFX/EFXEffectReverb.java +++ b/src/main/java/com/flibitijibibo/flibitEFX/EFXEffectReverb.java @@ -25,11 +25,11 @@ import org.lwjgl.openal.EFX10; */ public class EFXEffectReverb extends EFXEffect { - - /** Constructor creates a generic reverb effect. */ - public EFXEffectReverb() { - super(EFX10.AL_EFFECT_REVERB); - } - - // TODO: Add methods for all AL_EFFECT_REVERB properties. + + /** Constructor creates a generic reverb effect. */ + public EFXEffectReverb() { + super(EFX10.AL_EFFECT_REVERB); + } + + // TODO: Add methods for all AL_EFFECT_REVERB properties. } \ No newline at end of file diff --git a/src/main/java/com/flibitijibibo/flibitEFX/EFXEffectRingModulator.java b/src/main/java/com/flibitijibibo/flibitEFX/EFXEffectRingModulator.java index 78d3d7b..6984287 100644 --- a/src/main/java/com/flibitijibibo/flibitEFX/EFXEffectRingModulator.java +++ b/src/main/java/com/flibitijibibo/flibitEFX/EFXEffectRingModulator.java @@ -25,46 +25,46 @@ import org.lwjgl.openal.EFX10; */ public class EFXEffectRingModulator extends EFXEffect { - - public static final int SINUSOID = EFX10.AL_RING_MODULATOR_SINUSOID; - public static final int SAWTOOTH = EFX10.AL_RING_MODULATOR_SAWTOOTH; - public static final int SQUARE = EFX10.AL_RING_MODULATOR_SQUARE; - - /** Constructor creates a generic ring modulator effect. */ - public EFXEffectRingModulator() { - super(EFX10.AL_EFFECT_RING_MODULATOR); - } - - /** Sets the frequency of the ring modulator. - * @param passedValue The new frequency of the ring modulator - */ - public void setFrequency(float passedValue) { - if (passedValue > EFX10.AL_RING_MODULATOR_MAX_FREQUENCY) - addEffectf(EFX10.AL_RING_MODULATOR_FREQUENCY, EFX10.AL_RING_MODULATOR_MAX_FREQUENCY); - else if (passedValue < EFX10.AL_RING_MODULATOR_MIN_FREQUENCY) - addEffectf(EFX10.AL_RING_MODULATOR_FREQUENCY, EFX10.AL_RING_MODULATOR_MIN_FREQUENCY); - else - addEffectf(EFX10.AL_RING_MODULATOR_FREQUENCY, passedValue); - } - - /** Sets the high-pass cutoff for the ring modulator. - * @param passedValue The new cutoff value for the ring modulator high-pass filter - */ - public void setHighPassCutoff(float passedValue) { - if (passedValue > EFX10.AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF) - addEffectf(EFX10.AL_RING_MODULATOR_HIGHPASS_CUTOFF, EFX10.AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF); - else if (passedValue < EFX10.AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF) - addEffectf(EFX10.AL_RING_MODULATOR_HIGHPASS_CUTOFF, EFX10.AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF); - else - addEffectf(EFX10.AL_RING_MODULATOR_HIGHPASS_CUTOFF, passedValue); - } - - /** Sets the waveform of the ring modulator. - * @param waveform Should be EFXEffectRingModulator.SINUSOID, SAWTOOTH or SQUARE - */ - public void setWaveform(int waveform) { - if (waveform != SINUSOID && waveform != SAWTOOTH && waveform != SQUARE) - return; - addEffecti(EFX10.AL_RING_MODULATOR_WAVEFORM, waveform); - } + + public static final int SINUSOID = EFX10.AL_RING_MODULATOR_SINUSOID; + public static final int SAWTOOTH = EFX10.AL_RING_MODULATOR_SAWTOOTH; + public static final int SQUARE = EFX10.AL_RING_MODULATOR_SQUARE; + + /** Constructor creates a generic ring modulator effect. */ + public EFXEffectRingModulator() { + super(EFX10.AL_EFFECT_RING_MODULATOR); + } + + /** Sets the frequency of the ring modulator. + * @param passedValue The new frequency of the ring modulator + */ + public void setFrequency(float passedValue) { + if (passedValue > EFX10.AL_RING_MODULATOR_MAX_FREQUENCY) + addEffectf(EFX10.AL_RING_MODULATOR_FREQUENCY, EFX10.AL_RING_MODULATOR_MAX_FREQUENCY); + else if (passedValue < EFX10.AL_RING_MODULATOR_MIN_FREQUENCY) + addEffectf(EFX10.AL_RING_MODULATOR_FREQUENCY, EFX10.AL_RING_MODULATOR_MIN_FREQUENCY); + else + addEffectf(EFX10.AL_RING_MODULATOR_FREQUENCY, passedValue); + } + + /** Sets the high-pass cutoff for the ring modulator. + * @param passedValue The new cutoff value for the ring modulator high-pass filter + */ + public void setHighPassCutoff(float passedValue) { + if (passedValue > EFX10.AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF) + addEffectf(EFX10.AL_RING_MODULATOR_HIGHPASS_CUTOFF, EFX10.AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF); + else if (passedValue < EFX10.AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF) + addEffectf(EFX10.AL_RING_MODULATOR_HIGHPASS_CUTOFF, EFX10.AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF); + else + addEffectf(EFX10.AL_RING_MODULATOR_HIGHPASS_CUTOFF, passedValue); + } + + /** Sets the waveform of the ring modulator. + * @param waveform Should be EFXEffectRingModulator.SINUSOID, SAWTOOTH or SQUARE + */ + public void setWaveform(int waveform) { + if (waveform != SINUSOID && waveform != SAWTOOTH && waveform != SQUARE) + return; + addEffecti(EFX10.AL_RING_MODULATOR_WAVEFORM, waveform); + } } \ No newline at end of file diff --git a/src/main/java/com/flibitijibibo/flibitEFX/EFXFilter.java b/src/main/java/com/flibitijibibo/flibitEFX/EFXFilter.java index 6f708a5..c06efbe 100644 --- a/src/main/java/com/flibitijibibo/flibitEFX/EFXFilter.java +++ b/src/main/java/com/flibitijibibo/flibitEFX/EFXFilter.java @@ -25,35 +25,35 @@ import org.lwjgl.openal.EFX10; */ public abstract class EFXFilter { - - private int filterIndex; - - /** Constructor creates an EFX effect slot containing a filter. - * @param efxFilter The EFX10 filter type (i.e. EFX10.AL_FILTER_HIGHPASS) - */ - public EFXFilter(int efxFilter) { - filterIndex = EFX10.alGenFilters(); - // TODO: Check to see if efxFilter is a valid AL_FILTER_TYPE. - EFX10.alFilteri(filterIndex, EFX10.AL_FILTER_TYPE, efxFilter); - } - - /** Unloads the EFX filter. */ - public void killFilter() { - EFX10.alDeleteFilters(filterIndex); - } - - /** Returns the index of the EFX filter. - * @return The index of the EFX filter - */ - public int getIndex() { - return filterIndex; - } - - /** Applies a filter property to this EFX filter. - * @param passedProperty The EFX10 filter property - * @param passedValue The EFX10 filter value - */ - protected void addFilter(int passedProperty, float passedValue) { - EFX10.alFilterf(filterIndex, passedProperty, passedValue); - } + + private int filterIndex; + + /** Constructor creates an EFX effect slot containing a filter. + * @param efxFilter The EFX10 filter type (i.e. EFX10.AL_FILTER_HIGHPASS) + */ + public EFXFilter(int efxFilter) { + filterIndex = EFX10.alGenFilters(); + // TODO: Check to see if efxFilter is a valid AL_FILTER_TYPE. + EFX10.alFilteri(filterIndex, EFX10.AL_FILTER_TYPE, efxFilter); + } + + /** Unloads the EFX filter. */ + public void killFilter() { + EFX10.alDeleteFilters(filterIndex); + } + + /** Returns the index of the EFX filter. + * @return The index of the EFX filter + */ + public int getIndex() { + return filterIndex; + } + + /** Applies a filter property to this EFX filter. + * @param passedProperty The EFX10 filter property + * @param passedValue The EFX10 filter value + */ + protected void addFilter(int passedProperty, float passedValue) { + EFX10.alFilterf(filterIndex, passedProperty, passedValue); + } } \ No newline at end of file diff --git a/src/main/java/com/flibitijibibo/flibitEFX/EFXFilterLowPass.java b/src/main/java/com/flibitijibibo/flibitEFX/EFXFilterLowPass.java index 1c7858d..b15bb62 100644 --- a/src/main/java/com/flibitijibibo/flibitEFX/EFXFilterLowPass.java +++ b/src/main/java/com/flibitijibibo/flibitEFX/EFXFilterLowPass.java @@ -26,22 +26,22 @@ import org.lwjgl.openal.EFX10; public class EFXFilterLowPass extends EFXFilter { - /** Constructor creates a generic low-pass filter. */ - public EFXFilterLowPass() { - super(EFX10.AL_FILTER_LOWPASS); - } - - /** Sets the gain of the low-pass filter. - * @param passedValue The new value of the low-pass filter gain - */ - public void setGain(float passedValue) { - addFilter(EFX10.AL_LOWPASS_GAIN, passedValue); - } - - /** Sets the gain of the low-pass filter's high frequencies. - * @param passedValue The new value of the low-pass filter's HF gain - */ - public void setGainHF(float passedValue) { - addFilter(EFX10.AL_LOWPASS_GAINHF, passedValue); - } + /** Constructor creates a generic low-pass filter. */ + public EFXFilterLowPass() { + super(EFX10.AL_FILTER_LOWPASS); + } + + /** Sets the gain of the low-pass filter. + * @param passedValue The new value of the low-pass filter gain + */ + public void setGain(float passedValue) { + addFilter(EFX10.AL_LOWPASS_GAIN, passedValue); + } + + /** Sets the gain of the low-pass filter's high frequencies. + * @param passedValue The new value of the low-pass filter's HF gain + */ + public void setGainHF(float passedValue) { + addFilter(EFX10.AL_LOWPASS_GAINHF, passedValue); + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/Defines.java b/src/main/java/lwjake2/Defines.java index 213a980..f167c84 100644 --- a/src/main/java/lwjake2/Defines.java +++ b/src/main/java/lwjake2/Defines.java @@ -31,7 +31,7 @@ public class Defines { public final static int EV_PLAYER_TELEPORT = 6; public final static int EV_OTHER_TELEPORT = 7; - // angle indexes + // angle indexes public final static int PITCH = 0; // up / down public final static int YAW = 1; // left / right public final static int ROLL = 2; // fall over @@ -43,7 +43,7 @@ public class Defines { public final static int MAX_QPATH = 64; // max length of a quake game pathname public final static int MAX_OSPATH = 128; // max length of a filesystem pathname - // per-level limits + // per-level limits public final static int MAX_CLIENTS = 256; // absolute limit public final static int MAX_EDICTS = 1024; // must change protocol to increase more public final static int MAX_LIGHTSTYLES = 256; @@ -53,7 +53,7 @@ public class Defines { public final static int MAX_ITEMS = 256; private final static int MAX_GENERAL = (MAX_CLIENTS * 2); // general config strings - // game print flags + // game print flags public final static int PRINT_MEDIUM = 1; // death messages public final static int PRINT_HIGH = 2; // critical messages public final static int PRINT_CHAT = 3; // chat messages @@ -65,7 +65,7 @@ public class Defines { public final static int PRINT_ALL = 0; public final static int PRINT_DEVELOPER = 1; // only print when "developer 1" - // key / value info strings + // key / value info strings public final static int MAX_INFO_KEY = 64; public final static int MAX_INFO_STRING = 512; @@ -456,26 +456,26 @@ public class Defines { public final static int SPLASH_SLIME = 4; public final static int SPLASH_LAVA = 5; - // sound channels - // channel 0 never willingly overrides - // other channels (1-7) allways override a playing sound on that channel + // sound channels + // channel 0 never willingly overrides + // other channels (1-7) allways override a playing sound on that channel public final static int CHAN_AUTO = 0; public final static int CHAN_WEAPON = 1; public final static int CHAN_VOICE = 2; public final static int CHAN_ITEM = 3; public final static int CHAN_BODY = 4; - // modifier flags + // modifier flags public final static int CHAN_NO_PHS_ADD = 8; // send to all clients, not just ones in PHS (ATTN 0 will also do this) public final static int CHAN_RELIABLE = 16; // send by reliable message, not datagram - // sound attenuation values + // sound attenuation values public final static int ATTN_NONE = 0; // full volume the entire level public final static int ATTN_NORM = 1; public final static int ATTN_IDLE = 2; public final static int ATTN_STATIC = 3; // diminish very rapidly with distance - // player_state->stats[] indexes + // player_state->stats[] indexes public final static int STAT_HEALTH_ICON = 0; public final static int STAT_HEALTH = 1; public final static int STAT_AMMO_ICON = 2; @@ -497,7 +497,7 @@ public class Defines { public final static int MAX_STATS = 32; - // dmflags->value flags + // dmflags->value flags public final static int DF_NO_HEALTH = 0x00000001; // 1 public final static int DF_NO_ITEMS = 0x00000002; // 2 public final static int DF_WEAPONS_STAY = 0x00000004; // 4 @@ -515,17 +515,17 @@ public class Defines { public final static int DF_QUAD_DROP = 0x00004000; // 16384 public final static int DF_FIXED_FOV = 0x00008000; // 32768 - // ROGUE + // ROGUE protected final static int DF_NO_MINES = 0x00020000; protected final static int DF_NO_STACK_DOUBLE = 0x00040000; protected final static int DF_NO_NUKES = 0x00080000; protected final static int DF_NO_SPHERES = 0x00100000; - // ROGUE + // ROGUE // - // config strings are a general means of communication from - // the server to all connected clients. - // Each config string can be at most MAX_QPATH characters. + // config strings are a general means of communication from + // the server to all connected clients. + // Each config string can be at most MAX_QPATH characters. // public final static int CS_NAME = 0; public final static int CS_CDTRACK = 1; @@ -611,7 +611,7 @@ public class Defines { public final static int TE_EXPLOSION1_NP = 54; public final static int TE_FLECHETTE = 55; - // content masks + // content masks public final static int MASK_SOLID = (CONTENTS_SOLID | CONTENTS_WINDOW); public final static int MASK_PLAYERSOLID = (CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER); public final static int MASK_DEADSOLID = (CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW); @@ -663,11 +663,11 @@ public class Defines { public final static int AMMO_CELLS = 4; public final static int AMMO_SLUGS = 5; - // view pitching times + // view pitching times public final static float DAMAGE_TIME = 0.5f; public final static float FALL_TIME = 0.3f; - // damage flags + // damage flags public final static int DAMAGE_RADIUS = 0x00000001; // damage was indirect public final static int DAMAGE_NO_ARMOR = 0x00000002; // armour does not protect from this damage public final static int DAMAGE_ENERGY = 0x00000004; // damage is from an energy based weapon @@ -680,7 +680,7 @@ public class Defines { public final static int DAMAGE_YES = 1; // will take damage if hit public final static int DAMAGE_AIM = 2; // auto targeting recognizes this - // means of death + // means of death public final static int MOD_UNKNOWN = 0; public final static int MOD_BLASTER = 1; public final static int MOD_SHOTGUN = 2; @@ -717,15 +717,15 @@ public class Defines { public final static int MOD_TARGET_BLASTER = 33; public final static int MOD_FRIENDLY_FIRE = 0x8000000; - // edict->spawnflags - // these are set with checkboxes on each entity in the map editor + // edict->spawnflags + // these are set with checkboxes on each entity in the map editor public final static int SPAWNFLAG_NOT_EASY = 0x00000100; public final static int SPAWNFLAG_NOT_MEDIUM = 0x00000200; public final static int SPAWNFLAG_NOT_HARD = 0x00000400; public final static int SPAWNFLAG_NOT_DEATHMATCH = 0x00000800; public final static int SPAWNFLAG_NOT_COOP = 0x00001000; - // edict->flags + // edict->flags public final static int FL_FLY = 0x00000001; public final static int FL_SWIM = 0x00000002; // implied immunity to drowining public final static int FL_IMMUNE_LASER = 0x00000004; @@ -746,21 +746,21 @@ public class Defines { public final static int BODY_QUEUE_SIZE = 8; - // deadflag + // deadflag public final static int DEAD_NO = 0; public final static int DEAD_DEAD = 2; - // range + // range public final static int RANGE_MELEE = 0; public final static int RANGE_NEAR = 1; public final static int RANGE_MID = 2; public final static int RANGE_FAR = 3; - // gib types + // gib types public final static int GIB_ORGANIC = 0; public final static int GIB_METALLIC = 1; - // monster ai flags + // monster ai flags public final static int AI_STAND_GROUND = 0x00000001; public final static int AI_TEMP_STAND_GROUND = 0x00000002; public final static int AI_SOUND_TARGET = 0x00000004; @@ -777,36 +777,36 @@ public class Defines { public final static int AI_MEDIC = 0x00002000; public final static int AI_RESURRECTING = 0x00004000; - // monster attack state + // monster attack state public final static int AS_STRAIGHT = 1; public final static int AS_SLIDING = 2; public final static int AS_MELEE = 3; public final static int AS_MISSILE = 4; - // armor types + // armor types public final static int ARMOR_JACKET = 1; public final static int ARMOR_COMBAT = 2; public final static int ARMOR_BODY = 3; public final static int ARMOR_SHARD = 4; - // power armor types + // power armor types public final static int POWER_ARMOR_NONE = 0; public final static int POWER_ARMOR_SCREEN = 1; public final static int POWER_ARMOR_SHIELD = 2; - // handedness values + // handedness values public final static int LEFT_HANDED = 1; public final static int CENTER_HANDED = 2; - // game.serverflags values + // game.serverflags values public final static int SFL_CROSS_TRIGGER_MASK = 0x000000ff; - // noise types for PlayerNoise + // noise types for PlayerNoise public final static int PNOISE_SELF = 0; public final static int PNOISE_WEAPON = 1; public final static int PNOISE_IMPACT = 2; - // gitem_t->flags + // gitem_t->flags public final static int IT_WEAPON = 1; // use makes active weapon public final static int IT_AMMO = 2; public final static int IT_ARMOR = 4; @@ -814,7 +814,7 @@ public class Defines { public final static int IT_KEY = 16; public final static int IT_POWERUP = 32; - // gitem_t->weapmodel for weapons indicates model index + // gitem_t->weapmodel for weapons indicates model index public final static int WEAP_BLASTER = 1; public final static int WEAP_SHOTGUN = 2; public final static int WEAP_SUPERSHOTGUN = 3; @@ -827,7 +827,7 @@ public class Defines { public final static int WEAP_RAILGUN = 10; public final static int WEAP_BFG = 11; - // edict->movetype values + // edict->movetype values public final static int MOVETYPE_NONE = 0; // never moves public final static int MOVETYPE_NOCLIP = 1; // origin and angles change with no interaction public final static int MOVETYPE_PUSH = 2; // no clip to world, push on box contact @@ -855,7 +855,7 @@ public class Defines { public final static int SOLID_BBOX = 2; // touch on edge public final static int SOLID_BSP = 3; // bsp clip, touch on edge - // edict->svflags + // edict->svflags public final static int SVF_NOCLIENT = 0x00000001; // don't send entity to clients, even if it has effects public final static int SVF_DEADMONSTER = 0x00000002; // treat as CONTENTS_DEADMONSTER for collision public final static int SVF_MONSTER = 0x00000004; // treat as CONTENTS_MONSTER for collision diff --git a/src/main/java/lwjake2/Globals.java b/src/main/java/lwjake2/Globals.java index ab1978f..6eeceee 100644 --- a/src/main/java/lwjake2/Globals.java +++ b/src/main/java/lwjake2/Globals.java @@ -46,344 +46,344 @@ import java.util.Random; */ public class Globals extends Defines { - public static final String __DATE__ = "2003"; + public static final String __DATE__ = "2003"; - public static final float VERSION = 3.21f; + public static final float VERSION = 3.21f; - public static final String BASEDIRNAME = "baseq2"; + public static final String BASEDIRNAME = "baseq2"; - /* - * global variables - */ - public static int curtime = 0; - public static boolean cmd_wait; + /* + * global variables + */ + public static int curtime = 0; + public static boolean cmd_wait; - public static int alias_count; - public static int c_traces; - public static int c_brush_traces; - public static int c_pointcontents; - public static int server_state; + public static int alias_count; + public static int c_traces; + public static int c_brush_traces; + public static int c_pointcontents; + public static int server_state; - public static cvar_t cl_add_blend; - public static cvar_t cl_add_entities; - public static cvar_t cl_add_lights; - public static cvar_t cl_add_particles; - public static cvar_t cl_anglespeedkey; - public static cvar_t cl_autoskins; - public static cvar_t cl_footsteps; - public static cvar_t cl_forwardspeed; - public static cvar_t cl_gun; - public static cvar_t cl_maxfps; - public static cvar_t cl_noskins; - public static cvar_t cl_pitchspeed; - public static cvar_t cl_predict; - public static cvar_t cl_run; - public static cvar_t cl_sidespeed; - public static cvar_t cl_stereo; - public static cvar_t cl_stereo_separation; - public static cvar_t cl_timedemo = new cvar_t(); - public static cvar_t cl_timeout; - public static cvar_t cl_upspeed; - public static cvar_t cl_yawspeed; - public static cvar_t dedicated; - public static cvar_t developer; - public static cvar_t fixedtime; - public static cvar_t freelook; - public static cvar_t host_speeds; - public static cvar_t log_stats; - public static cvar_t logfile_active; - public static cvar_t lookspring; - public static cvar_t lookstrafe; - public static cvar_t nostdout; - public static cvar_t sensitivity; - public static cvar_t showtrace; - public static cvar_t timescale; - public static cvar_t in_mouse; - public static cvar_t in_joystick; + public static cvar_t cl_add_blend; + public static cvar_t cl_add_entities; + public static cvar_t cl_add_lights; + public static cvar_t cl_add_particles; + public static cvar_t cl_anglespeedkey; + public static cvar_t cl_autoskins; + public static cvar_t cl_footsteps; + public static cvar_t cl_forwardspeed; + public static cvar_t cl_gun; + public static cvar_t cl_maxfps; + public static cvar_t cl_noskins; + public static cvar_t cl_pitchspeed; + public static cvar_t cl_predict; + public static cvar_t cl_run; + public static cvar_t cl_sidespeed; + public static cvar_t cl_stereo; + public static cvar_t cl_stereo_separation; + public static cvar_t cl_timedemo = new cvar_t(); + public static cvar_t cl_timeout; + public static cvar_t cl_upspeed; + public static cvar_t cl_yawspeed; + public static cvar_t dedicated; + public static cvar_t developer; + public static cvar_t fixedtime; + public static cvar_t freelook; + public static cvar_t host_speeds; + public static cvar_t log_stats; + public static cvar_t logfile_active; + public static cvar_t lookspring; + public static cvar_t lookstrafe; + public static cvar_t nostdout; + public static cvar_t sensitivity; + public static cvar_t showtrace; + public static cvar_t timescale; + public static cvar_t in_mouse; + public static cvar_t in_joystick; - public static sizebuf_t net_message = new sizebuf_t(); + public static sizebuf_t net_message = new sizebuf_t(); - /* - ============================================================================= - - COMMAND BUFFER - - ============================================================================= - */ + /* + ============================================================================= + + COMMAND BUFFER + + ============================================================================= + */ - public static sizebuf_t cmd_text = new sizebuf_t(); + public static sizebuf_t cmd_text = new sizebuf_t(); - public static byte defer_text_buf[] = new byte[8192]; + public static byte defer_text_buf[] = new byte[8192]; - public static byte cmd_text_buf[] = new byte[8192]; - public static cmdalias_t cmd_alias; + public static byte cmd_text_buf[] = new byte[8192]; + public static cmdalias_t cmd_alias; - //============================================================================= + //============================================================================= - public static byte[] net_message_buffer = new byte[MAX_MSGLEN]; + public static byte[] net_message_buffer = new byte[MAX_MSGLEN]; - public static int time_before_game; - public static int time_after_game; - public static int time_before_ref; - public static int time_after_ref; + public static int time_before_game; + public static int time_after_game; + public static int time_before_ref; + public static int time_after_ref; - public static FileWriter log_stats_file = null; + public static FileWriter log_stats_file = null; - public static cvar_t m_pitch; - public static cvar_t m_yaw; - public static cvar_t m_forward; - public static cvar_t m_side; + public static cvar_t m_pitch; + public static cvar_t m_yaw; + public static cvar_t m_forward; + public static cvar_t m_side; - public static cvar_t cl_lightlevel; + public static cvar_t cl_lightlevel; - // - // userinfo - // - public static cvar_t info_password; - public static cvar_t info_spectator; - public static cvar_t name; - public static cvar_t skin; - public static cvar_t rate; - public static cvar_t fov; - public static cvar_t msg; - public static cvar_t hand; - public static cvar_t gender; - public static cvar_t gender_auto; + // + // userinfo + // + public static cvar_t info_password; + public static cvar_t info_spectator; + public static cvar_t name; + public static cvar_t skin; + public static cvar_t rate; + public static cvar_t fov; + public static cvar_t msg; + public static cvar_t hand; + public static cvar_t gender; + public static cvar_t gender_auto; - public static cvar_t cl_vwep; + public static cvar_t cl_vwep; - public static client_static_t cls = new client_static_t(); - public static client_state_t cl = new client_state_t(); + public static client_static_t cls = new client_static_t(); + public static client_state_t cl = new client_state_t(); - public static centity_t cl_entities[] = new centity_t[MAX_EDICTS]; - static { - for (int i = 0; i < cl_entities.length; i++) { - cl_entities[i] = new centity_t(); - } - } + public static centity_t cl_entities[] = new centity_t[MAX_EDICTS]; + static { + for (int i = 0; i < cl_entities.length; i++) { + cl_entities[i] = new centity_t(); + } + } - public static entity_state_t cl_parse_entities[] = new entity_state_t[MAX_PARSE_ENTITIES]; - - static { - for (int i = 0; i < cl_parse_entities.length; i++) - { - cl_parse_entities[i] = new entity_state_t(null); - } - } + public static entity_state_t cl_parse_entities[] = new entity_state_t[MAX_PARSE_ENTITIES]; + + static { + for (int i = 0; i < cl_parse_entities.length; i++) + { + cl_parse_entities[i] = new entity_state_t(null); + } + } - public static cvar_t rcon_client_password; - public static cvar_t rcon_address; + public static cvar_t rcon_client_password; + public static cvar_t rcon_address; - public static cvar_t cl_shownet; - public static cvar_t cl_showmiss; - public static cvar_t cl_showclamp; + public static cvar_t cl_shownet; + public static cvar_t cl_showmiss; + public static cvar_t cl_showclamp; - public static cvar_t cl_paused; + public static cvar_t cl_paused; - // client/anorms.h - public static final float bytedirs[][] = { /** - */ - { -0.525731f, 0.000000f, 0.850651f }, { - -0.442863f, 0.238856f, 0.864188f }, { - -0.295242f, 0.000000f, 0.955423f }, { - -0.309017f, 0.500000f, 0.809017f }, { - -0.162460f, 0.262866f, 0.951056f }, { - 0.000000f, 0.000000f, 1.000000f }, { - 0.000000f, 0.850651f, 0.525731f }, { - -0.147621f, 0.716567f, 0.681718f }, { - 0.147621f, 0.716567f, 0.681718f }, { - 0.000000f, 0.525731f, 0.850651f }, { - 0.309017f, 0.500000f, 0.809017f }, { - 0.525731f, 0.000000f, 0.850651f }, { - 0.295242f, 0.000000f, 0.955423f }, { - 0.442863f, 0.238856f, 0.864188f }, { - 0.162460f, 0.262866f, 0.951056f }, { - -0.681718f, 0.147621f, 0.716567f }, { - -0.809017f, 0.309017f, 0.500000f }, { - -0.587785f, 0.425325f, 0.688191f }, { - -0.850651f, 0.525731f, 0.000000f }, { - -0.864188f, 0.442863f, 0.238856f }, { - -0.716567f, 0.681718f, 0.147621f }, { - -0.688191f, 0.587785f, 0.425325f }, { - -0.500000f, 0.809017f, 0.309017f }, { - -0.238856f, 0.864188f, 0.442863f }, { - -0.425325f, 0.688191f, 0.587785f }, { - -0.716567f, 0.681718f, -0.147621f }, { - -0.500000f, 0.809017f, -0.309017f }, { - -0.525731f, 0.850651f, 0.000000f }, { - 0.000000f, 0.850651f, -0.525731f }, { - -0.238856f, 0.864188f, -0.442863f }, { - 0.000000f, 0.955423f, -0.295242f }, { - -0.262866f, 0.951056f, -0.162460f }, { - 0.000000f, 1.000000f, 0.000000f }, { - 0.000000f, 0.955423f, 0.295242f }, { - -0.262866f, 0.951056f, 0.162460f }, { - 0.238856f, 0.864188f, 0.442863f }, { - 0.262866f, 0.951056f, 0.162460f }, { - 0.500000f, 0.809017f, 0.309017f }, { - 0.238856f, 0.864188f, -0.442863f }, { - 0.262866f, 0.951056f, -0.162460f }, { - 0.500000f, 0.809017f, -0.309017f }, { - 0.850651f, 0.525731f, 0.000000f }, { - 0.716567f, 0.681718f, 0.147621f }, { - 0.716567f, 0.681718f, -0.147621f }, { - 0.525731f, 0.850651f, 0.000000f }, { - 0.425325f, 0.688191f, 0.587785f }, { - 0.864188f, 0.442863f, 0.238856f }, { - 0.688191f, 0.587785f, 0.425325f }, { - 0.809017f, 0.309017f, 0.500000f }, { - 0.681718f, 0.147621f, 0.716567f }, { - 0.587785f, 0.425325f, 0.688191f }, { - 0.955423f, 0.295242f, 0.000000f }, { - 1.000000f, 0.000000f, 0.000000f }, { - 0.951056f, 0.162460f, 0.262866f }, { - 0.850651f, -0.525731f, 0.000000f }, { - 0.955423f, -0.295242f, 0.000000f }, { - 0.864188f, -0.442863f, 0.238856f }, { - 0.951056f, -0.162460f, 0.262866f }, { - 0.809017f, -0.309017f, 0.500000f }, { - 0.681718f, -0.147621f, 0.716567f }, { - 0.850651f, 0.000000f, 0.525731f }, { - 0.864188f, 0.442863f, -0.238856f }, { - 0.809017f, 0.309017f, -0.500000f }, { - 0.951056f, 0.162460f, -0.262866f }, { - 0.525731f, 0.000000f, -0.850651f }, { - 0.681718f, 0.147621f, -0.716567f }, { - 0.681718f, -0.147621f, -0.716567f }, { - 0.850651f, 0.000000f, -0.525731f }, { - 0.809017f, -0.309017f, -0.500000f }, { - 0.864188f, -0.442863f, -0.238856f }, { - 0.951056f, -0.162460f, -0.262866f }, { - 0.147621f, 0.716567f, -0.681718f }, { - 0.309017f, 0.500000f, -0.809017f }, { - 0.425325f, 0.688191f, -0.587785f }, { - 0.442863f, 0.238856f, -0.864188f }, { - 0.587785f, 0.425325f, -0.688191f }, { - 0.688191f, 0.587785f, -0.425325f }, { - -0.147621f, 0.716567f, -0.681718f }, { - -0.309017f, 0.500000f, -0.809017f }, { - 0.000000f, 0.525731f, -0.850651f }, { - -0.525731f, 0.000000f, -0.850651f }, { - -0.442863f, 0.238856f, -0.864188f }, { - -0.295242f, 0.000000f, -0.955423f }, { - -0.162460f, 0.262866f, -0.951056f }, { - 0.000000f, 0.000000f, -1.000000f }, { - 0.295242f, 0.000000f, -0.955423f }, { - 0.162460f, 0.262866f, -0.951056f }, { - -0.442863f, -0.238856f, -0.864188f }, { - -0.309017f, -0.500000f, -0.809017f }, { - -0.162460f, -0.262866f, -0.951056f }, { - 0.000000f, -0.850651f, -0.525731f }, { - -0.147621f, -0.716567f, -0.681718f }, { - 0.147621f, -0.716567f, -0.681718f }, { - 0.000000f, -0.525731f, -0.850651f }, { - 0.309017f, -0.500000f, -0.809017f }, { - 0.442863f, -0.238856f, -0.864188f }, { - 0.162460f, -0.262866f, -0.951056f }, { - 0.238856f, -0.864188f, -0.442863f }, { - 0.500000f, -0.809017f, -0.309017f }, { - 0.425325f, -0.688191f, -0.587785f }, { - 0.716567f, -0.681718f, -0.147621f }, { - 0.688191f, -0.587785f, -0.425325f }, { - 0.587785f, -0.425325f, -0.688191f }, { - 0.000000f, -0.955423f, -0.295242f }, { - 0.000000f, -1.000000f, 0.000000f }, { - 0.262866f, -0.951056f, -0.162460f }, { - 0.000000f, -0.850651f, 0.525731f }, { - 0.000000f, -0.955423f, 0.295242f }, { - 0.238856f, -0.864188f, 0.442863f }, { - 0.262866f, -0.951056f, 0.162460f }, { - 0.500000f, -0.809017f, 0.309017f }, { - 0.716567f, -0.681718f, 0.147621f }, { - 0.525731f, -0.850651f, 0.000000f }, { - -0.238856f, -0.864188f, -0.442863f }, { - -0.500000f, -0.809017f, -0.309017f }, { - -0.262866f, -0.951056f, -0.162460f }, { - -0.850651f, -0.525731f, 0.000000f }, { - -0.716567f, -0.681718f, -0.147621f }, { - -0.716567f, -0.681718f, 0.147621f }, { - -0.525731f, -0.850651f, 0.000000f }, { - -0.500000f, -0.809017f, 0.309017f }, { - -0.238856f, -0.864188f, 0.442863f }, { - -0.262866f, -0.951056f, 0.162460f }, { - -0.864188f, -0.442863f, 0.238856f }, { - -0.809017f, -0.309017f, 0.500000f }, { - -0.688191f, -0.587785f, 0.425325f }, { - -0.681718f, -0.147621f, 0.716567f }, { - -0.442863f, -0.238856f, 0.864188f }, { - -0.587785f, -0.425325f, 0.688191f }, { - -0.309017f, -0.500000f, 0.809017f }, { - -0.147621f, -0.716567f, 0.681718f }, { - -0.425325f, -0.688191f, 0.587785f }, { - -0.162460f, -0.262866f, 0.951056f }, { - 0.442863f, -0.238856f, 0.864188f }, { - 0.162460f, -0.262866f, 0.951056f }, { - 0.309017f, -0.500000f, 0.809017f }, { - 0.147621f, -0.716567f, 0.681718f }, { - 0.000000f, -0.525731f, 0.850651f }, { - 0.425325f, -0.688191f, 0.587785f }, { - 0.587785f, -0.425325f, 0.688191f }, { - 0.688191f, -0.587785f, 0.425325f }, { - -0.955423f, 0.295242f, 0.000000f }, { - -0.951056f, 0.162460f, 0.262866f }, { - -1.000000f, 0.000000f, 0.000000f }, { - -0.850651f, 0.000000f, 0.525731f }, { - -0.955423f, -0.295242f, 0.000000f }, { - -0.951056f, -0.162460f, 0.262866f }, { - -0.864188f, 0.442863f, -0.238856f }, { - -0.951056f, 0.162460f, -0.262866f }, { - -0.809017f, 0.309017f, -0.500000f }, { - -0.864188f, -0.442863f, -0.238856f }, { - -0.951056f, -0.162460f, -0.262866f }, { - -0.809017f, -0.309017f, -0.500000f }, { - -0.681718f, 0.147621f, -0.716567f }, { - -0.681718f, -0.147621f, -0.716567f }, { - -0.850651f, 0.000000f, -0.525731f }, { - -0.688191f, 0.587785f, -0.425325f }, { - -0.587785f, 0.425325f, -0.688191f }, { - -0.425325f, 0.688191f, -0.587785f }, { - -0.425325f, -0.688191f, -0.587785f }, { - -0.587785f, -0.425325f, -0.688191f }, { - -0.688191f, -0.587785f, -0.425325f } - }; + // client/anorms.h + public static final float bytedirs[][] = { /** + */ + { -0.525731f, 0.000000f, 0.850651f }, { + -0.442863f, 0.238856f, 0.864188f }, { + -0.295242f, 0.000000f, 0.955423f }, { + -0.309017f, 0.500000f, 0.809017f }, { + -0.162460f, 0.262866f, 0.951056f }, { + 0.000000f, 0.000000f, 1.000000f }, { + 0.000000f, 0.850651f, 0.525731f }, { + -0.147621f, 0.716567f, 0.681718f }, { + 0.147621f, 0.716567f, 0.681718f }, { + 0.000000f, 0.525731f, 0.850651f }, { + 0.309017f, 0.500000f, 0.809017f }, { + 0.525731f, 0.000000f, 0.850651f }, { + 0.295242f, 0.000000f, 0.955423f }, { + 0.442863f, 0.238856f, 0.864188f }, { + 0.162460f, 0.262866f, 0.951056f }, { + -0.681718f, 0.147621f, 0.716567f }, { + -0.809017f, 0.309017f, 0.500000f }, { + -0.587785f, 0.425325f, 0.688191f }, { + -0.850651f, 0.525731f, 0.000000f }, { + -0.864188f, 0.442863f, 0.238856f }, { + -0.716567f, 0.681718f, 0.147621f }, { + -0.688191f, 0.587785f, 0.425325f }, { + -0.500000f, 0.809017f, 0.309017f }, { + -0.238856f, 0.864188f, 0.442863f }, { + -0.425325f, 0.688191f, 0.587785f }, { + -0.716567f, 0.681718f, -0.147621f }, { + -0.500000f, 0.809017f, -0.309017f }, { + -0.525731f, 0.850651f, 0.000000f }, { + 0.000000f, 0.850651f, -0.525731f }, { + -0.238856f, 0.864188f, -0.442863f }, { + 0.000000f, 0.955423f, -0.295242f }, { + -0.262866f, 0.951056f, -0.162460f }, { + 0.000000f, 1.000000f, 0.000000f }, { + 0.000000f, 0.955423f, 0.295242f }, { + -0.262866f, 0.951056f, 0.162460f }, { + 0.238856f, 0.864188f, 0.442863f }, { + 0.262866f, 0.951056f, 0.162460f }, { + 0.500000f, 0.809017f, 0.309017f }, { + 0.238856f, 0.864188f, -0.442863f }, { + 0.262866f, 0.951056f, -0.162460f }, { + 0.500000f, 0.809017f, -0.309017f }, { + 0.850651f, 0.525731f, 0.000000f }, { + 0.716567f, 0.681718f, 0.147621f }, { + 0.716567f, 0.681718f, -0.147621f }, { + 0.525731f, 0.850651f, 0.000000f }, { + 0.425325f, 0.688191f, 0.587785f }, { + 0.864188f, 0.442863f, 0.238856f }, { + 0.688191f, 0.587785f, 0.425325f }, { + 0.809017f, 0.309017f, 0.500000f }, { + 0.681718f, 0.147621f, 0.716567f }, { + 0.587785f, 0.425325f, 0.688191f }, { + 0.955423f, 0.295242f, 0.000000f }, { + 1.000000f, 0.000000f, 0.000000f }, { + 0.951056f, 0.162460f, 0.262866f }, { + 0.850651f, -0.525731f, 0.000000f }, { + 0.955423f, -0.295242f, 0.000000f }, { + 0.864188f, -0.442863f, 0.238856f }, { + 0.951056f, -0.162460f, 0.262866f }, { + 0.809017f, -0.309017f, 0.500000f }, { + 0.681718f, -0.147621f, 0.716567f }, { + 0.850651f, 0.000000f, 0.525731f }, { + 0.864188f, 0.442863f, -0.238856f }, { + 0.809017f, 0.309017f, -0.500000f }, { + 0.951056f, 0.162460f, -0.262866f }, { + 0.525731f, 0.000000f, -0.850651f }, { + 0.681718f, 0.147621f, -0.716567f }, { + 0.681718f, -0.147621f, -0.716567f }, { + 0.850651f, 0.000000f, -0.525731f }, { + 0.809017f, -0.309017f, -0.500000f }, { + 0.864188f, -0.442863f, -0.238856f }, { + 0.951056f, -0.162460f, -0.262866f }, { + 0.147621f, 0.716567f, -0.681718f }, { + 0.309017f, 0.500000f, -0.809017f }, { + 0.425325f, 0.688191f, -0.587785f }, { + 0.442863f, 0.238856f, -0.864188f }, { + 0.587785f, 0.425325f, -0.688191f }, { + 0.688191f, 0.587785f, -0.425325f }, { + -0.147621f, 0.716567f, -0.681718f }, { + -0.309017f, 0.500000f, -0.809017f }, { + 0.000000f, 0.525731f, -0.850651f }, { + -0.525731f, 0.000000f, -0.850651f }, { + -0.442863f, 0.238856f, -0.864188f }, { + -0.295242f, 0.000000f, -0.955423f }, { + -0.162460f, 0.262866f, -0.951056f }, { + 0.000000f, 0.000000f, -1.000000f }, { + 0.295242f, 0.000000f, -0.955423f }, { + 0.162460f, 0.262866f, -0.951056f }, { + -0.442863f, -0.238856f, -0.864188f }, { + -0.309017f, -0.500000f, -0.809017f }, { + -0.162460f, -0.262866f, -0.951056f }, { + 0.000000f, -0.850651f, -0.525731f }, { + -0.147621f, -0.716567f, -0.681718f }, { + 0.147621f, -0.716567f, -0.681718f }, { + 0.000000f, -0.525731f, -0.850651f }, { + 0.309017f, -0.500000f, -0.809017f }, { + 0.442863f, -0.238856f, -0.864188f }, { + 0.162460f, -0.262866f, -0.951056f }, { + 0.238856f, -0.864188f, -0.442863f }, { + 0.500000f, -0.809017f, -0.309017f }, { + 0.425325f, -0.688191f, -0.587785f }, { + 0.716567f, -0.681718f, -0.147621f }, { + 0.688191f, -0.587785f, -0.425325f }, { + 0.587785f, -0.425325f, -0.688191f }, { + 0.000000f, -0.955423f, -0.295242f }, { + 0.000000f, -1.000000f, 0.000000f }, { + 0.262866f, -0.951056f, -0.162460f }, { + 0.000000f, -0.850651f, 0.525731f }, { + 0.000000f, -0.955423f, 0.295242f }, { + 0.238856f, -0.864188f, 0.442863f }, { + 0.262866f, -0.951056f, 0.162460f }, { + 0.500000f, -0.809017f, 0.309017f }, { + 0.716567f, -0.681718f, 0.147621f }, { + 0.525731f, -0.850651f, 0.000000f }, { + -0.238856f, -0.864188f, -0.442863f }, { + -0.500000f, -0.809017f, -0.309017f }, { + -0.262866f, -0.951056f, -0.162460f }, { + -0.850651f, -0.525731f, 0.000000f }, { + -0.716567f, -0.681718f, -0.147621f }, { + -0.716567f, -0.681718f, 0.147621f }, { + -0.525731f, -0.850651f, 0.000000f }, { + -0.500000f, -0.809017f, 0.309017f }, { + -0.238856f, -0.864188f, 0.442863f }, { + -0.262866f, -0.951056f, 0.162460f }, { + -0.864188f, -0.442863f, 0.238856f }, { + -0.809017f, -0.309017f, 0.500000f }, { + -0.688191f, -0.587785f, 0.425325f }, { + -0.681718f, -0.147621f, 0.716567f }, { + -0.442863f, -0.238856f, 0.864188f }, { + -0.587785f, -0.425325f, 0.688191f }, { + -0.309017f, -0.500000f, 0.809017f }, { + -0.147621f, -0.716567f, 0.681718f }, { + -0.425325f, -0.688191f, 0.587785f }, { + -0.162460f, -0.262866f, 0.951056f }, { + 0.442863f, -0.238856f, 0.864188f }, { + 0.162460f, -0.262866f, 0.951056f }, { + 0.309017f, -0.500000f, 0.809017f }, { + 0.147621f, -0.716567f, 0.681718f }, { + 0.000000f, -0.525731f, 0.850651f }, { + 0.425325f, -0.688191f, 0.587785f }, { + 0.587785f, -0.425325f, 0.688191f }, { + 0.688191f, -0.587785f, 0.425325f }, { + -0.955423f, 0.295242f, 0.000000f }, { + -0.951056f, 0.162460f, 0.262866f }, { + -1.000000f, 0.000000f, 0.000000f }, { + -0.850651f, 0.000000f, 0.525731f }, { + -0.955423f, -0.295242f, 0.000000f }, { + -0.951056f, -0.162460f, 0.262866f }, { + -0.864188f, 0.442863f, -0.238856f }, { + -0.951056f, 0.162460f, -0.262866f }, { + -0.809017f, 0.309017f, -0.500000f }, { + -0.864188f, -0.442863f, -0.238856f }, { + -0.951056f, -0.162460f, -0.262866f }, { + -0.809017f, -0.309017f, -0.500000f }, { + -0.681718f, 0.147621f, -0.716567f }, { + -0.681718f, -0.147621f, -0.716567f }, { + -0.850651f, 0.000000f, -0.525731f }, { + -0.688191f, 0.587785f, -0.425325f }, { + -0.587785f, 0.425325f, -0.688191f }, { + -0.425325f, 0.688191f, -0.587785f }, { + -0.425325f, -0.688191f, -0.587785f }, { + -0.587785f, -0.425325f, -0.688191f }, { + -0.688191f, -0.587785f, -0.425325f } + }; - public static boolean userinfo_modified = false; + public static boolean userinfo_modified = false; - public static cvar_t cvar_vars; - public static final console_t con = new console_t(); - public static cvar_t con_notifytime; - public static viddef_t viddef = new viddef_t(); - // Renderer interface used by VID, SCR, ... - public static refexport_t re = new DummyRenderer(); + public static cvar_t cvar_vars; + public static final console_t con = new console_t(); + public static cvar_t con_notifytime; + public static viddef_t viddef = new viddef_t(); + // Renderer interface used by VID, SCR, ... + public static refexport_t re = new DummyRenderer(); - public static String[] keybindings = new String[256]; - public static boolean[] keydown = new boolean[256]; - public static boolean chat_team = false; - public static String chat_buffer = ""; - public static byte[][] key_lines = new byte[32][]; - public static int key_linepos; - static { - for (int i = 0; i < key_lines.length; i++) - key_lines[i] = new byte[MAXCMDLINE]; - }; - public static int edit_line; + public static String[] keybindings = new String[256]; + public static boolean[] keydown = new boolean[256]; + public static boolean chat_team = false; + public static String chat_buffer = ""; + public static byte[][] key_lines = new byte[32][]; + public static int key_linepos; + static { + for (int i = 0; i < key_lines.length; i++) + key_lines[i] = new byte[MAXCMDLINE]; + }; + public static int edit_line; - public static cvar_t crosshair; - public static vrect_t scr_vrect = new vrect_t(); - public static int sys_frame_time; - public static int chat_bufferlen = 0; - public static int gun_frame; - public static model_t gun_model; - public static netadr_t net_from = new netadr_t(); - - // logfile - public static RandomAccessFile logfile = null; - - public static float vec3_origin[] = { 0.0f, 0.0f, 0.0f }; + public static cvar_t crosshair; + public static vrect_t scr_vrect = new vrect_t(); + public static int sys_frame_time; + public static int chat_bufferlen = 0; + public static int gun_frame; + public static model_t gun_model; + public static netadr_t net_from = new netadr_t(); + + // logfile + public static RandomAccessFile logfile = null; + + public static float vec3_origin[] = { 0.0f, 0.0f, 0.0f }; - public static cvar_t m_filter; - public static int vidref_val = VIDREF_GL; - - public static Random rnd = new Random(); + public static cvar_t m_filter; + public static int vidref_val = VIDREF_GL; + + public static Random rnd = new Random(); } diff --git a/src/main/java/lwjake2/LWJake2.java b/src/main/java/lwjake2/LWJake2.java index 7949e1d..f317ab3 100644 --- a/src/main/java/lwjake2/LWJake2.java +++ b/src/main/java/lwjake2/LWJake2.java @@ -36,37 +36,37 @@ public final class LWJake2 { * @param args */ public static void main(@NonNull String[] args) { - - boolean dedicated = false; + + boolean dedicated = false; - // check if we are in dedicated mode to hide the java dialog. - for (int n = 0; n < args.length; n++) - { - if (args[n].equals("+set")) - { - if (n++ >= args.length) - break; - - if (!args[n].equals("dedicated")) - continue; + // check if we are in dedicated mode to hide the java dialog. + for (int n = 0; n < args.length; n++) + { + if (args[n].equals("+set")) + { + if (n++ >= args.length) + break; + + if (!args[n].equals("dedicated")) + continue; - if (n++ >= args.length) - break; + if (n++ >= args.length) + break; - if (args[n].equals("1") || args[n].equals("\"1\"")) - { - Com.Printf("Starting in dedicated mode.\n"); - dedicated = true; - } - } - } - - // TODO: check if dedicated is set in config file - - Globals.dedicated= Cvar.Get("dedicated", "0", Qcommon.CVAR_NOSET); + if (args[n].equals("1") || args[n].equals("\"1\"")) + { + Com.Printf("Starting in dedicated mode.\n"); + dedicated = true; + } + } + } + + // TODO: check if dedicated is set in config file + + Globals.dedicated= Cvar.Get("dedicated", "0", Qcommon.CVAR_NOSET); - if (dedicated) - Globals.dedicated.value = 1.0f; + if (dedicated) + Globals.dedicated.value = 1.0f; // in C the first arg is the filename int argc = (args == null) ? 1 : args.length + 1; diff --git a/src/main/java/lwjake2/client/CL.java b/src/main/java/lwjake2/client/CL.java index 100925e..6c568cf 100644 --- a/src/main/java/lwjake2/client/CL.java +++ b/src/main/java/lwjake2/client/CL.java @@ -114,7 +114,7 @@ public final class CL { return; } - // finish up + // finish up len = -1; Globals.cls.demofile.writeInt(EndianHandler.swapInt(len)); Globals.cls.demofile.close(); @@ -509,7 +509,7 @@ public final class CL { CL_parse.RegisterSounds(); }; - // ENV_CNT is map load, ENV_CNT+1 is first env map + // ENV_CNT is map load, ENV_CNT+1 is first env map public static final int ENV_CNT = (Defines.CS_PLAYERSKINS + Defines.MAX_CLIENTS * CL.PLAYER_MULT); @@ -545,7 +545,7 @@ public final class CL { private static int extratime; - // ============================================================================ + // ============================================================================ /** * Shutdown @@ -590,7 +590,7 @@ public final class CL { } if (adr.port == 0) adr.port = Defines.PORT_SERVER; - // adr.port = BigShort(PORT_SERVER); + // adr.port = BigShort(PORT_SERVER); port = (int) Cvar.VariableValue("qport"); Globals.userinfo_modified = false; @@ -823,12 +823,12 @@ public final class CL { // // remote command packet - // + // if (Globals.net_message.data[0] == -1 && Globals.net_message.data[1] == -1 && Globals.net_message.data[2] == -1 && Globals.net_message.data[3] == -1) { - // if (*(int *)net_message.data == -1) + // if (*(int *)net_message.data == -1) ConnectionlessPacket(); continue; } @@ -871,7 +871,7 @@ public final class CL { Globals.cl.timeoutcount = 0; } - // ============================================================================= + // ============================================================================= /** * FixUpGender_f @@ -912,7 +912,7 @@ public final class CL { if (SV_MAIN.allow_download.value == 0 && CL.precache_check < ENV_CNT) CL.precache_check = ENV_CNT; - // ZOID + // ZOID if (CL.precache_check == Defines.CS_MODELS) { // confirm map CL.precache_check = Defines.CS_MODELS + 2; // 0 isn't used if (SV_MAIN.allow_download_maps.value != 0) @@ -1204,7 +1204,7 @@ public final class CL { CL.precache_check = TEXTURE_CNT + 999; } - // ZOID + // ZOID CL_parse.RegisterSounds(); CL_view.PrepRefresh(); @@ -1427,7 +1427,7 @@ public final class CL { } } - // ============================================================= + // ============================================================= /** * SendCommand @@ -1452,7 +1452,7 @@ public final class CL { CheckForResend(); } - // private static int lasttimecalled; + // private static int lasttimecalled; /** * Frame diff --git a/src/main/java/lwjake2/client/CL_ents.java b/src/main/java/lwjake2/client/CL_ents.java index a71fb5a..909a597 100644 --- a/src/main/java/lwjake2/client/CL_ents.java +++ b/src/main/java/lwjake2/client/CL_ents.java @@ -32,7 +32,7 @@ import lwjake2.util.Math3D; /** * CL_ents */ -// cl_ents.c -- entity parsing and management +// cl_ents.c -- entity parsing and management /* * ========================================================================= * @@ -41,1174 +41,1174 @@ import lwjake2.util.Math3D; * ========================================================================= */ public class CL_ents { - private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); - - static int bitcounts[] = new int[32]; /// just for protocol profiling - - static int bfg_lightramp[] = { 300, 400, 600, 300, 150, 75 }; - - /* - * ================= CL_ParseEntityBits - * - * Returns the entity number and the header bits ================= - */ - public static int ParseEntityBits(int bits[]) { - int b, total; - int i; - int number; - - total = MSG.ReadByte(Globals.net_message); - if ((total & Defines.U_MOREBITS1) != 0) { - - b = MSG.ReadByte(Globals.net_message); - total |= b << 8; - } - if ((total & Defines.U_MOREBITS2) != 0) { - - b = MSG.ReadByte(Globals.net_message); - total |= b << 16; - } - if ((total & Defines.U_MOREBITS3) != 0) { - - b = MSG.ReadByte(Globals.net_message); - total |= b << 24; - } - - // count the bits for net profiling - for (i = 0; i < 32; i++) - if ((total & (1 << i)) != 0) - bitcounts[i]++; - - if ((total & Defines.U_NUMBER16) != 0) - number = MSG.ReadShort(Globals.net_message); - else - number = MSG.ReadByte(Globals.net_message); - - bits[0] = total; - - return number; - } - - /* - * ================== CL_ParseDelta - * - * Can go from either a baseline or a previous packet_entity - * ================== - */ - public static void ParseDelta(entity_state_t from, entity_state_t to, int number, int bits) { - // set everything to the state we are delta'ing from - to.set(from); - - Math3D.VectorCopy(from.origin, to.old_origin); - to.number = number; - - if ((bits & Defines.U_MODEL) != 0) - to.modelindex = MSG.ReadByte(Globals.net_message); - if ((bits & Defines.U_MODEL2) != 0) - to.modelindex2 = MSG.ReadByte(Globals.net_message); - if ((bits & Defines.U_MODEL3) != 0) - to.modelindex3 = MSG.ReadByte(Globals.net_message); - if ((bits & Defines.U_MODEL4) != 0) - to.modelindex4 = MSG.ReadByte(Globals.net_message); - - if ((bits & Defines.U_FRAME8) != 0) - to.frame = MSG.ReadByte(Globals.net_message); - if ((bits & Defines.U_FRAME16) != 0) - to.frame = MSG.ReadShort(Globals.net_message); - - if ((bits & Defines.U_SKIN8) != 0 && (bits & Defines.U_SKIN16) != 0) //used - // for - // laser - // colors - to.skinnum = MSG.ReadLong(Globals.net_message); - else if ((bits & Defines.U_SKIN8) != 0) - to.skinnum = MSG.ReadByte(Globals.net_message); - else if ((bits & Defines.U_SKIN16) != 0) - to.skinnum = MSG.ReadShort(Globals.net_message); - - if ((bits & (Defines.U_EFFECTS8 | Defines.U_EFFECTS16)) == (Defines.U_EFFECTS8 | Defines.U_EFFECTS16)) - to.effects = MSG.ReadLong(Globals.net_message); - else if ((bits & Defines.U_EFFECTS8) != 0) - to.effects = MSG.ReadByte(Globals.net_message); - else if ((bits & Defines.U_EFFECTS16) != 0) - to.effects = MSG.ReadShort(Globals.net_message); - - if ((bits & (Defines.U_RENDERFX8 | Defines.U_RENDERFX16)) == (Defines.U_RENDERFX8 | Defines.U_RENDERFX16)) - to.renderfx = MSG.ReadLong(Globals.net_message); - else if ((bits & Defines.U_RENDERFX8) != 0) - to.renderfx = MSG.ReadByte(Globals.net_message); - else if ((bits & Defines.U_RENDERFX16) != 0) - to.renderfx = MSG.ReadShort(Globals.net_message); - - if ((bits & Defines.U_ORIGIN1) != 0) - to.origin[0] = MSG.ReadCoord(Globals.net_message); - if ((bits & Defines.U_ORIGIN2) != 0) - to.origin[1] = MSG.ReadCoord(Globals.net_message); - if ((bits & Defines.U_ORIGIN3) != 0) - to.origin[2] = MSG.ReadCoord(Globals.net_message); - - if ((bits & Defines.U_ANGLE1) != 0) - to.angles[0] = MSG.ReadAngle(Globals.net_message); - if ((bits & Defines.U_ANGLE2) != 0) - to.angles[1] = MSG.ReadAngle(Globals.net_message); - if ((bits & Defines.U_ANGLE3) != 0) - to.angles[2] = MSG.ReadAngle(Globals.net_message); - - if ((bits & Defines.U_OLDORIGIN) != 0) - MSG.ReadPos(Globals.net_message, to.old_origin); - - if ((bits & Defines.U_SOUND) != 0) - to.sound = MSG.ReadByte(Globals.net_message); - - if ((bits & Defines.U_EVENT) != 0) - to.event = MSG.ReadByte(Globals.net_message); - else - to.event = 0; - - if ((bits & Defines.U_SOLID) != 0) - to.solid = MSG.ReadShort(Globals.net_message); - } - - /* - * ================== CL_DeltaEntity - * - * Parses deltas from the given base and adds the resulting entity to the - * current frame ================== - */ - public static void DeltaEntity(frame_t frame, int newnum, entity_state_t old, int bits) { - centity_t ent; - entity_state_t state; - - ent = Globals.cl_entities[newnum]; - - state = Globals.cl_parse_entities[Globals.cl.parse_entities & (Defines.MAX_PARSE_ENTITIES - 1)]; - Globals.cl.parse_entities++; - frame.num_entities++; - - ParseDelta(old, state, newnum, bits); - - // some data changes will force no lerping - if (state.modelindex != ent.current.modelindex || state.modelindex2 != ent.current.modelindex2 - || state.modelindex3 != ent.current.modelindex3 || state.modelindex4 != ent.current.modelindex4 - || Math.abs(state.origin[0] - ent.current.origin[0]) > 512 || Math.abs(state.origin[1] - ent.current.origin[1]) > 512 - || Math.abs(state.origin[2] - ent.current.origin[2]) > 512 || state.event == Defines.EV_PLAYER_TELEPORT - || state.event == Defines.EV_OTHER_TELEPORT) { - ent.serverframe = -99; - } - - if (ent.serverframe != Globals.cl.frame.serverframe - 1) { // wasn't in - // last - // update, so - // initialize - // some - // things - ent.trailcount = 1024; // for diminishing rocket / grenade trails - // duplicate the current state so lerping doesn't hurt anything - ent.prev.set(state); - if (state.event == Defines.EV_OTHER_TELEPORT) { - Math3D.VectorCopy(state.origin, ent.prev.origin); - Math3D.VectorCopy(state.origin, ent.lerp_origin); - } else { - Math3D.VectorCopy(state.old_origin, ent.prev.origin); - Math3D.VectorCopy(state.old_origin, ent.lerp_origin); - } - } else { // shuffle the last state to previous - // Copy ! - ent.prev.set(ent.current); - } - - ent.serverframe = Globals.cl.frame.serverframe; - // Copy ! - ent.current.set(state); - } - - // call by reference - private static final int[] iw = {0}; - /* - * ================== CL_ParsePacketEntities - * - * An svc_packetentities has just been parsed, deal with the rest of the - * data stream. ================== - */ - public static void ParsePacketEntities(frame_t oldframe, frame_t newframe) { - int newnum; - int bits = 0; - - entity_state_t oldstate = null; - int oldnum; - - newframe.parse_entities = Globals.cl.parse_entities; - newframe.num_entities = 0; - - // delta from the entities present in oldframe - int oldindex = 0; - if (oldframe == null) - oldnum = 99999; - else { - // oldindex == 0. hoz - // if (oldindex >= oldframe.num_entities) - // oldnum = 99999; - // else { - oldstate = Globals.cl_parse_entities[(oldframe.parse_entities + oldindex) & (Defines.MAX_PARSE_ENTITIES - 1)]; - oldnum = oldstate.number; - // } - } - - while (true) { - //int iw[] = { bits }; - iw[0] = bits; - newnum = ParseEntityBits(iw); - bits = iw[0]; - - if (newnum >= Defines.MAX_EDICTS) - Com.Error(Defines.ERR_DROP, "CL_ParsePacketEntities: bad number:" + newnum); - - if (Globals.net_message.readcount > Globals.net_message.cursize) - Com.Error(Defines.ERR_DROP, "CL_ParsePacketEntities: end of message"); - - if (0 == newnum) - break; - - while (oldnum < newnum) { // one or more entities from the old - // packet are unchanged - if (Globals.cl_shownet.value == 3) - Com.Printf(" unchanged: " + oldnum + "\n"); - DeltaEntity(newframe, oldnum, oldstate, 0); - - oldindex++; - - if (oldindex >= oldframe.num_entities) - oldnum = 99999; - else { - oldstate = Globals.cl_parse_entities[(oldframe.parse_entities + oldindex) & (Defines.MAX_PARSE_ENTITIES - 1)]; - oldnum = oldstate.number; - } - } - - if ((bits & Defines.U_REMOVE) != 0) { // the entity present in - // oldframe is not in the - // current frame - if (Globals.cl_shownet.value == 3) - Com.Printf(" remove: " + newnum + "\n"); - if (oldnum != newnum) - Com.Printf("U_REMOVE: oldnum != newnum\n"); - - oldindex++; - - if (oldindex >= oldframe.num_entities) - oldnum = 99999; - else { - oldstate = Globals.cl_parse_entities[(oldframe.parse_entities + oldindex) & (Defines.MAX_PARSE_ENTITIES - 1)]; - oldnum = oldstate.number; - } - continue; - } - - if (oldnum == newnum) { // delta from previous state - if (Globals.cl_shownet.value == 3) - Com.Printf(" delta: " + newnum + "\n"); - DeltaEntity(newframe, newnum, oldstate, bits); - - oldindex++; - - if (oldindex >= oldframe.num_entities) - oldnum = 99999; - else { - oldstate = Globals.cl_parse_entities[(oldframe.parse_entities + oldindex) & (Defines.MAX_PARSE_ENTITIES - 1)]; - oldnum = oldstate.number; - } - continue; - } - - if (oldnum > newnum) { // delta from baseline - if (Globals.cl_shownet.value == 3) - Com.Printf(" baseline: " + newnum + "\n"); - DeltaEntity(newframe, newnum, Globals.cl_entities[newnum].baseline, bits); - continue; - } - - } - - // any remaining entities in the old frame are copied over - while (oldnum != 99999) { // one or more entities from the old packet - // are unchanged - if (Globals.cl_shownet.value == 3) - Com.Printf(" unchanged: " + oldnum + "\n"); - DeltaEntity(newframe, oldnum, oldstate, 0); - - oldindex++; - - if (oldindex >= oldframe.num_entities) - oldnum = 99999; - else { - oldstate = Globals.cl_parse_entities[(oldframe.parse_entities + oldindex) & (Defines.MAX_PARSE_ENTITIES - 1)]; - oldnum = oldstate.number; - } - } - } - - /* - * =================== CL_ParsePlayerstate =================== - */ - public static void ParsePlayerstate(frame_t oldframe, frame_t newframe) { - int flags; - player_state_t state; - int i; - int statbits; - - state = newframe.playerstate; - - // clear to old value before delta parsing - if (oldframe != null) - state.set(oldframe.playerstate); - else - //memset (state, 0, sizeof(*state)); - state.clear(); - - flags = MSG.ReadShort(Globals.net_message); - - // - // parse the pmove_state_t - // - if ((flags & Defines.PS_M_TYPE) != 0) - state.pmove.pm_type = MSG.ReadByte(Globals.net_message); - - if ((flags & Defines.PS_M_ORIGIN) != 0) { - state.pmove.origin[0] = MSG.ReadShort(Globals.net_message); - state.pmove.origin[1] = MSG.ReadShort(Globals.net_message); - state.pmove.origin[2] = MSG.ReadShort(Globals.net_message); - } - - if ((flags & Defines.PS_M_VELOCITY) != 0) { - state.pmove.velocity[0] = MSG.ReadShort(Globals.net_message); - state.pmove.velocity[1] = MSG.ReadShort(Globals.net_message); - state.pmove.velocity[2] = MSG.ReadShort(Globals.net_message); - } - - if ((flags & Defines.PS_M_TIME) != 0) { - state.pmove.pm_time = (byte) MSG.ReadByte(Globals.net_message); - } - - if ((flags & Defines.PS_M_FLAGS) != 0) - state.pmove.pm_flags = (byte) MSG.ReadByte(Globals.net_message); - - if ((flags & Defines.PS_M_GRAVITY) != 0) - state.pmove.gravity = MSG.ReadShort(Globals.net_message); - - if ((flags & Defines.PS_M_DELTA_ANGLES) != 0) { - state.pmove.delta_angles[0] = MSG.ReadShort(Globals.net_message); - state.pmove.delta_angles[1] = MSG.ReadShort(Globals.net_message); - state.pmove.delta_angles[2] = MSG.ReadShort(Globals.net_message); - } - - if (Globals.cl.attractloop) - state.pmove.pm_type = Defines.PM_FREEZE; // demo playback - - // - // parse the rest of the player_state_t - // - if ((flags & Defines.PS_VIEWOFFSET) != 0) { - state.viewoffset[0] = MSG.ReadChar(Globals.net_message) * 0.25f; - state.viewoffset[1] = MSG.ReadChar(Globals.net_message) * 0.25f; - state.viewoffset[2] = MSG.ReadChar(Globals.net_message) * 0.25f; - } - - if ((flags & Defines.PS_VIEWANGLES) != 0) { - state.viewangles[0] = MSG.ReadAngle16(Globals.net_message); - state.viewangles[1] = MSG.ReadAngle16(Globals.net_message); - state.viewangles[2] = MSG.ReadAngle16(Globals.net_message); - } - - if ((flags & Defines.PS_KICKANGLES) != 0) { - - state.kick_angles[0] = MSG.ReadChar(Globals.net_message) * 0.25f; - state.kick_angles[1] = MSG.ReadChar(Globals.net_message) * 0.25f; - state.kick_angles[2] = MSG.ReadChar(Globals.net_message) * 0.25f; - - } - - if ((flags & Defines.PS_WEAPONINDEX) != 0) { - state.gunindex = MSG.ReadByte(Globals.net_message); - } - - if ((flags & Defines.PS_WEAPONFRAME) != 0) { - state.gunframe = MSG.ReadByte(Globals.net_message); - state.gunoffset[0] = MSG.ReadChar(Globals.net_message) * 0.25f; - state.gunoffset[1] = MSG.ReadChar(Globals.net_message) * 0.25f; - state.gunoffset[2] = MSG.ReadChar(Globals.net_message) * 0.25f; - state.gunangles[0] = MSG.ReadChar(Globals.net_message) * 0.25f; - state.gunangles[1] = MSG.ReadChar(Globals.net_message) * 0.25f; - state.gunangles[2] = MSG.ReadChar(Globals.net_message) * 0.25f; - } - - if ((flags & Defines.PS_BLEND) != 0) { - state.blend[0] = MSG.ReadByte(Globals.net_message) / 255.0f; - state.blend[1] = MSG.ReadByte(Globals.net_message) / 255.0f; - state.blend[2] = MSG.ReadByte(Globals.net_message) / 255.0f; - state.blend[3] = MSG.ReadByte(Globals.net_message) / 255.0f; - } - - if ((flags & Defines.PS_FOV) != 0) - state.fov = MSG.ReadByte(Globals.net_message); - - if ((flags & Defines.PS_RDFLAGS) != 0) - state.rdflags = MSG.ReadByte(Globals.net_message); - - // parse stats - statbits = MSG.ReadLong(Globals.net_message); - for (i = 0; i < Defines.MAX_STATS; i++) - if ((statbits & (1 << i)) != 0) - state.stats[i] = MSG.ReadShort(Globals.net_message); - } - - /* - * ================== CL_FireEntityEvents - * - * ================== - */ - public static void FireEntityEvents(frame_t frame) { - entity_state_t s1; - int pnum, num; - - for (pnum = 0; pnum < frame.num_entities; pnum++) { - num = (frame.parse_entities + pnum) & (Defines.MAX_PARSE_ENTITIES - 1); - s1 = Globals.cl_parse_entities[num]; - if (s1.event != 0) - CL_fx.EntityEvent(s1); - - // EF_TELEPORTER acts like an event, but is not cleared each frame - if ((s1.effects & Defines.EF_TELEPORTER) != 0) - CL_fx.TeleporterParticles(s1); - } - } - - /* - * ================ CL_ParseFrame ================ - */ - public static void ParseFrame() { - int cmd; - int len; - frame_t old; - - //memset( cl.frame, 0, sizeof(cl.frame)); - Globals.cl.frame.reset(); - - Globals.cl.frame.serverframe = MSG.ReadLong(Globals.net_message); - Globals.cl.frame.deltaframe = MSG.ReadLong(Globals.net_message); - Globals.cl.frame.servertime = Globals.cl.frame.serverframe * 100; - - // BIG HACK to let old demos continue to work - if (Globals.cls.serverProtocol != 26) - Globals.cl.surpressCount = MSG.ReadByte(Globals.net_message); - - if (Globals.cl_shownet.value == 3) - Com.Printf(" frame:" + Globals.cl.frame.serverframe + " delta:" + Globals.cl.frame.deltaframe + "\n"); - - // If the frame is delta compressed from data that we - // no longer have available, we must suck up the rest of - // the frame, but not use it, then ask for a non-compressed - // message - if (Globals.cl.frame.deltaframe <= 0) { - Globals.cl.frame.valid = true; // uncompressed frame - old = null; - Globals.cls.demowaiting = false; // we can start recording now - } else { - old = Globals.cl.frames[Globals.cl.frame.deltaframe & Defines.UPDATE_MASK]; - if (!old.valid) { // should never happen - Com.Printf("Delta from invalid frame (not supposed to happen!).\n"); - } - if (old.serverframe != Globals.cl.frame.deltaframe) { // The frame - // that the - // server did - // the delta - // from - // is too old, so we can't reconstruct it properly. - Com.Printf("Delta frame too old.\n"); - } else if (Globals.cl.parse_entities - old.parse_entities > Defines.MAX_PARSE_ENTITIES - 128) { - Com.Printf("Delta parse_entities too old.\n"); - } else - Globals.cl.frame.valid = true; // valid delta parse - } - - // clamp time - if (Globals.cl.time > Globals.cl.frame.servertime) - Globals.cl.time = Globals.cl.frame.servertime; - else if (Globals.cl.time < Globals.cl.frame.servertime - 100) - Globals.cl.time = Globals.cl.frame.servertime - 100; - - // read areabits - len = MSG.ReadByte(Globals.net_message); - MSG.ReadData(Globals.net_message, Globals.cl.frame.areabits, len); - - // read playerinfo - cmd = MSG.ReadByte(Globals.net_message); - CL_parse.SHOWNET(CL_parse.svc_strings[cmd]); - if (cmd != Defines.svc_playerinfo) - Com.Error(Defines.ERR_DROP, "CL_ParseFrame: not playerinfo"); - ParsePlayerstate(old, Globals.cl.frame); - - // read packet entities - cmd = MSG.ReadByte(Globals.net_message); - CL_parse.SHOWNET(CL_parse.svc_strings[cmd]); - if (cmd != Defines.svc_packetentities) - Com.Error(Defines.ERR_DROP, "CL_ParseFrame: not packetentities"); - - ParsePacketEntities(old, Globals.cl.frame); - - // save the frame off in the backup array for later delta comparisons - Globals.cl.frames[Globals.cl.frame.serverframe & Defines.UPDATE_MASK].set(Globals.cl.frame); - - if (Globals.cl.frame.valid) { - // getting a valid frame message ends the connection process - if (Globals.cls.state != Defines.ca_active) { - Globals.cls.state = Defines.ca_active; - Globals.cl.force_refdef = true; - - Globals.cl.predicted_origin[0] = Globals.cl.frame.playerstate.pmove.origin[0] * 0.125f; - Globals.cl.predicted_origin[1] = Globals.cl.frame.playerstate.pmove.origin[1] * 0.125f; - Globals.cl.predicted_origin[2] = Globals.cl.frame.playerstate.pmove.origin[2] * 0.125f; - - Math3D.VectorCopy(Globals.cl.frame.playerstate.viewangles, Globals.cl.predicted_angles); - if (Globals.cls.disable_servercount != Globals.cl.servercount && Globals.cl.refresh_prepped) - SCR.EndLoadingPlaque(); // get rid of loading plaque - } - Globals.cl.sound_prepped = true; // can start mixing ambient sounds - - // fire entity events - FireEntityEvents(Globals.cl.frame); - CL_pred.CheckPredictionError(); - } - } - - /* - * ========================================================================== - * - * INTERPOLATE BETWEEN FRAMES TO GET RENDERING PARMS - * - * ========================================================================== - */ - - // stack variable - private static final entity_t ent = new entity_t(); - /* - * =============== - * CL_AddPacketEntities - * =============== - */ - static void AddPacketEntities(frame_t frame) { - entity_state_t s1; - float autorotate; - int i; - int pnum; - centity_t cent; - int autoanim; - clientinfo_t ci; - int effects, renderfx; - - // bonus items rotate at a fixed rate - autorotate = Math3D.anglemod(Globals.cl.time / 10); - - // brush models can auto animate their frames - autoanim = 2 * Globals.cl.time / 1000; - - //memset( ent, 0, sizeof(ent)); - ent.clear(); - - for (pnum = 0; pnum < frame.num_entities; pnum++) { - s1 = Globals.cl_parse_entities[(frame.parse_entities + pnum) & (Defines.MAX_PARSE_ENTITIES - 1)]; - - cent = Globals.cl_entities[s1.number]; - - effects = s1.effects; - renderfx = s1.renderfx; - - // set frame - if ((effects & Defines.EF_ANIM01) != 0) - ent.frame = autoanim & 1; - else if ((effects & Defines.EF_ANIM23) != 0) - ent.frame = 2 + (autoanim & 1); - else if ((effects & Defines.EF_ANIM_ALL) != 0) - ent.frame = autoanim; - else if ((effects & Defines.EF_ANIM_ALLFAST) != 0) - ent.frame = Globals.cl.time / 100; - else - ent.frame = s1.frame; - - // quad and pent can do different things on client - if ((effects & Defines.EF_PENT) != 0) { - effects &= ~Defines.EF_PENT; - effects |= Defines.EF_COLOR_SHELL; - renderfx |= Defines.RF_SHELL_RED; - } - - if ((effects & Defines.EF_QUAD) != 0) { - effects &= ~Defines.EF_QUAD; - effects |= Defines.EF_COLOR_SHELL; - renderfx |= Defines.RF_SHELL_BLUE; - } - // ====== - // PMM - if ((effects & Defines.EF_DOUBLE) != 0) { - effects &= ~Defines.EF_DOUBLE; - effects |= Defines.EF_COLOR_SHELL; - renderfx |= Defines.RF_SHELL_DOUBLE; - } - - if ((effects & Defines.EF_HALF_DAMAGE) != 0) { - effects &= ~Defines.EF_HALF_DAMAGE; - effects |= Defines.EF_COLOR_SHELL; - renderfx |= Defines.RF_SHELL_HALF_DAM; - } - // pmm - // ====== - ent.oldframe = cent.prev.frame; - ent.backlerp = 1.0f - Globals.cl.lerpfrac; - - if ((renderfx & (Defines.RF_FRAMELERP | Defines.RF_BEAM)) != 0) { - // step origin discretely, because the frames - // do the animation properly - Math3D.VectorCopy(cent.current.origin, ent.origin); - Math3D.VectorCopy(cent.current.old_origin, ent.oldorigin); - } else { // interpolate origin - for (i = 0; i < 3; i++) { - ent.origin[i] = ent.oldorigin[i] = cent.prev.origin[i] + Globals.cl.lerpfrac - * (cent.current.origin[i] - cent.prev.origin[i]); - } - } - - // create a new entity - - // tweak the color of beams - if ((renderfx & Defines.RF_BEAM) != 0) { // the four beam colors are - // encoded in 32 bits of - // skinnum (hack) - ent.alpha = 0.30f; - ent.skinnum = (s1.skinnum >> ((Globals.rnd.nextInt(4)) * 8)) & 0xff; - Math.random(); - ent.model = null; - } else { - // set skin - if (s1.modelindex == 255) { // use custom player skin - ent.skinnum = 0; - ci = Globals.cl.clientinfo[s1.skinnum & 0xff]; - ent.skin = ci.skin; - ent.model = ci.model; - if (null == ent.skin || null == ent.model) { - ent.skin = Globals.cl.baseclientinfo.skin; - ent.model = Globals.cl.baseclientinfo.model; - } - - // ============ - // PGM - if ((renderfx & Defines.RF_USE_DISGUISE) != 0) { - if (ent.skin.name.startsWith("players/male")) { - ent.skin = Globals.re.RegisterSkin("players/male/disguise.pcx"); - ent.model = Globals.re.RegisterModel("players/male/tris.md2"); - } else if (ent.skin.name.startsWith("players/female")) { - ent.skin = Globals.re.RegisterSkin("players/female/disguise.pcx"); - ent.model = Globals.re.RegisterModel("players/female/tris.md2"); - } else if (ent.skin.name.startsWith("players/cyborg")) { - ent.skin = Globals.re.RegisterSkin("players/cyborg/disguise.pcx"); - ent.model = Globals.re.RegisterModel("players/cyborg/tris.md2"); - } - } - // PGM - // ============ - } else { - ent.skinnum = s1.skinnum; - ent.skin = null; - ent.model = Globals.cl.model_draw[s1.modelindex]; - } - } - - // only used for black hole model right now, FIXME: do better - if (renderfx == Defines.RF_TRANSLUCENT) - ent.alpha = 0.70f; - - // render effects (fullbright, translucent, etc) - if ((effects & Defines.EF_COLOR_SHELL) != 0) - ent.flags = 0; // renderfx go on color shell entity - else - ent.flags = renderfx; - - // calculate angles - if ((effects & Defines.EF_ROTATE) != 0) { // some bonus items - // auto-rotate - ent.angles[0] = 0; - ent.angles[1] = autorotate; - ent.angles[2] = 0; - } - // RAFAEL - else if ((effects & Defines.EF_SPINNINGLIGHTS) != 0) { - ent.angles[0] = 0; - ent.angles[1] = Math3D.anglemod(Globals.cl.time / 2) + s1.angles[1]; - ent.angles[2] = 180; - { - float[] forward = { 0, 0, 0 }; - float[] start = { 0, 0, 0 }; - - Math3D.AngleVectors(ent.angles, forward, null, null); - Math3D.VectorMA(ent.origin, 64, forward, start); - V.AddLight(start, 100, 1, 0, 0); - } - } else { // interpolate angles - float a1, a2; - - for (i = 0; i < 3; i++) { - a1 = cent.current.angles[i]; - a2 = cent.prev.angles[i]; - ent.angles[i] = Math3D.LerpAngle(a2, a1, Globals.cl.lerpfrac); - } - } - - if (s1.number == Globals.cl.playernum + 1) { - ent.flags |= Defines.RF_VIEWERMODEL; // only draw from mirrors - // FIXME: still pass to refresh - - if ((effects & Defines.EF_FLAG1) != 0) - V.AddLight(ent.origin, 225, 1.0f, 0.1f, 0.1f); - else if ((effects & Defines.EF_FLAG2) != 0) - V.AddLight(ent.origin, 225, 0.1f, 0.1f, 1.0f); - else if ((effects & Defines.EF_TAGTRAIL) != 0) //PGM - V.AddLight(ent.origin, 225, 1.0f, 1.0f, 0.0f); //PGM - else if ((effects & Defines.EF_TRACKERTRAIL) != 0) //PGM - V.AddLight(ent.origin, 225, -1.0f, -1.0f, -1.0f); //PGM - - continue; - } - - // if set to invisible, skip - if (s1.modelindex == 0) - continue; - - if ((effects & Defines.EF_BFG) != 0) { - ent.flags |= Defines.RF_TRANSLUCENT; - ent.alpha = 0.30f; - } - - // RAFAEL - if ((effects & Defines.EF_PLASMA) != 0) { - ent.flags |= Defines.RF_TRANSLUCENT; - ent.alpha = 0.6f; - } - - if ((effects & Defines.EF_SPHERETRANS) != 0) { - ent.flags |= Defines.RF_TRANSLUCENT; - // PMM - *sigh* yet more EF overloading - if ((effects & Defines.EF_TRACKERTRAIL) != 0) - ent.alpha = 0.6f; - else - ent.alpha = 0.3f; - } - // pmm - - // add to refresh list - V.AddEntity(ent); - - // color shells generate a seperate entity for the main model - if ((effects & Defines.EF_COLOR_SHELL) != 0) { - /* - * PMM - at this point, all of the shells have been handled if - * we're in the rogue pack, set up the custom mixing, otherwise - * just keep going if(Developer_searchpath(2) == 2) { all of the - * solo colors are fine. we need to catch any of the - * combinations that look bad (double & half) and turn them into - * the appropriate color, and make double/quad something special - * - */ - if ((renderfx & Defines.RF_SHELL_HALF_DAM) != 0) { - if (fileSystem.developer_searchpath(2) == 2) { - // ditch the half damage shell if any of red, blue, or - // double are on - if ((renderfx & (Defines.RF_SHELL_RED | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE)) != 0) - renderfx &= ~Defines.RF_SHELL_HALF_DAM; - } - } - - if ((renderfx & Defines.RF_SHELL_DOUBLE) != 0) { - if (fileSystem.developer_searchpath(2) == 2) { - // lose the yellow shell if we have a red, blue, or - // green shell - if ((renderfx & (Defines.RF_SHELL_RED | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_GREEN)) != 0) - renderfx &= ~Defines.RF_SHELL_DOUBLE; - // if we have a red shell, turn it to purple by adding - // blue - if ((renderfx & Defines.RF_SHELL_RED) != 0) - renderfx |= Defines.RF_SHELL_BLUE; - // if we have a blue shell (and not a red shell), turn - // it to cyan by adding green - else if ((renderfx & Defines.RF_SHELL_BLUE) != 0) - // go to green if it's on already, otherwise do cyan - // (flash green) - if ((renderfx & Defines.RF_SHELL_GREEN) != 0) - renderfx &= ~Defines.RF_SHELL_BLUE; - else - renderfx |= Defines.RF_SHELL_GREEN; - } - } - // } - // pmm - ent.flags = renderfx | Defines.RF_TRANSLUCENT; - ent.alpha = 0.30f; - V.AddEntity(ent); - } - - ent.skin = null; // never use a custom skin on others - ent.skinnum = 0; - ent.flags = 0; - ent.alpha = 0; - - // duplicate for linked models - if (s1.modelindex2 != 0) { - if (s1.modelindex2 == 255) { // custom weapon - ci = Globals.cl.clientinfo[s1.skinnum & 0xff]; - i = (s1.skinnum >> 8); // 0 is default weapon model - if (0 == Globals.cl_vwep.value || i > Defines.MAX_CLIENTWEAPONMODELS - 1) - i = 0; - ent.model = ci.weaponmodel[i]; - if (null == ent.model) { - if (i != 0) - ent.model = ci.weaponmodel[0]; - if (null == ent.model) - ent.model = Globals.cl.baseclientinfo.weaponmodel[0]; - } - } else - ent.model = Globals.cl.model_draw[s1.modelindex2]; - - // PMM - check for the defender sphere shell .. make it - // translucent - // replaces the previous version which used the high bit on - // modelindex2 to determine transparency - if (Globals.cl.configstrings[Defines.CS_MODELS + (s1.modelindex2)].equalsIgnoreCase("models/items/shell/tris.md2")) { - ent.alpha = 0.32f; - ent.flags = Defines.RF_TRANSLUCENT; - } - // pmm - - V.AddEntity(ent); - - //PGM - make sure these get reset. - ent.flags = 0; - ent.alpha = 0; - //PGM - } - if (s1.modelindex3 != 0) { - ent.model = Globals.cl.model_draw[s1.modelindex3]; - V.AddEntity(ent); - } - if (s1.modelindex4 != 0) { - ent.model = Globals.cl.model_draw[s1.modelindex4]; - V.AddEntity(ent); - } - - if ((effects & Defines.EF_POWERSCREEN) != 0) { - ent.model = CL_tent.cl_mod_powerscreen; - ent.oldframe = 0; - ent.frame = 0; - ent.flags |= (Defines.RF_TRANSLUCENT | Defines.RF_SHELL_GREEN); - ent.alpha = 0.30f; - V.AddEntity(ent); - } - - // add automatic particle trails - if ((effects & ~Defines.EF_ROTATE) != 0) { - if ((effects & Defines.EF_ROCKET) != 0) { - CL_fx.RocketTrail(cent.lerp_origin, ent.origin, cent); - V.AddLight(ent.origin, 200, 1, 1, 0); - } - // PGM - Do not reorder EF_BLASTER and EF_HYPERBLASTER. - // EF_BLASTER | EF_TRACKER is a special case for EF_BLASTER2... - // Cheese! - else if ((effects & Defines.EF_BLASTER) != 0) { - // CL_BlasterTrail (cent.lerp_origin, ent.origin); - // PGM - if ((effects & Defines.EF_TRACKER) != 0) // lame... - // problematic? - { - CL_newfx.BlasterTrail2(cent.lerp_origin, ent.origin); - V.AddLight(ent.origin, 200, 0, 1, 0); - } else { - CL_fx.BlasterTrail(cent.lerp_origin, ent.origin); - V.AddLight(ent.origin, 200, 1, 1, 0); - } - // PGM - } else if ((effects & Defines.EF_HYPERBLASTER) != 0) { - if ((effects & Defines.EF_TRACKER) != 0) // PGM overloaded - // for blaster2. - V.AddLight(ent.origin, 200, 0, 1, 0); // PGM - else - // PGM - V.AddLight(ent.origin, 200, 1, 1, 0); - } else if ((effects & Defines.EF_GIB) != 0) { - CL_fx.DiminishingTrail(cent.lerp_origin, ent.origin, cent, effects); - } else if ((effects & Defines.EF_GRENADE) != 0) { - CL_fx.DiminishingTrail(cent.lerp_origin, ent.origin, cent, effects); - } else if ((effects & Defines.EF_FLIES) != 0) { - CL_fx.FlyEffect(cent, ent.origin); - } else if ((effects & Defines.EF_BFG) != 0) { - - if ((effects & Defines.EF_ANIM_ALLFAST) != 0) { - CL_fx.BfgParticles(ent); - i = 200; - } else { - i = bfg_lightramp[s1.frame]; - } - V.AddLight(ent.origin, i, 0, 1, 0); - } - // RAFAEL - else if ((effects & Defines.EF_TRAP) != 0) { - ent.origin[2] += 32; - CL_fx.TrapParticles(ent); - i = (Globals.rnd.nextInt(100)) + 100; - V.AddLight(ent.origin, i, 1, 0.8f, 0.1f); - } else if ((effects & Defines.EF_FLAG1) != 0) { - CL_fx.FlagTrail(cent.lerp_origin, ent.origin, 242); - V.AddLight(ent.origin, 225, 1, 0.1f, 0.1f); - } else if ((effects & Defines.EF_FLAG2) != 0) { - CL_fx.FlagTrail(cent.lerp_origin, ent.origin, 115); - V.AddLight(ent.origin, 225, 0.1f, 0.1f, 1); - } - // ====== - // ROGUE - else if ((effects & Defines.EF_TAGTRAIL) != 0) { - CL_newfx.TagTrail(cent.lerp_origin, ent.origin, 220); - V.AddLight(ent.origin, 225, 1.0f, 1.0f, 0.0f); - } else if ((effects & Defines.EF_TRACKERTRAIL) != 0) { - if ((effects & Defines.EF_TRACKER) != 0) { - float intensity; - - intensity = (float) (50 + (500 * (Math.sin(Globals.cl.time / 500.0) + 1.0))); - // FIXME - check out this effect in rendition - if (Globals.vidref_val == Defines.VIDREF_GL) - V.AddLight(ent.origin, intensity, -1.0f, -1.0f, -1.0f); - else - V.AddLight(ent.origin, -1.0f * intensity, 1.0f, 1.0f, 1.0f); - } else { - CL_newfx.Tracker_Shell(cent.lerp_origin); - V.AddLight(ent.origin, 155, -1.0f, -1.0f, -1.0f); - } - } else if ((effects & Defines.EF_TRACKER) != 0) { - CL_newfx.TrackerTrail(cent.lerp_origin, ent.origin, 0); - // FIXME - check out this effect in rendition - if (Globals.vidref_val == Defines.VIDREF_GL) - V.AddLight(ent.origin, 200, -1, -1, -1); - else - V.AddLight(ent.origin, -200, 1, 1, 1); - } - // ROGUE - // ====== - // RAFAEL - else if ((effects & Defines.EF_GREENGIB) != 0) { - CL_fx.DiminishingTrail(cent.lerp_origin, ent.origin, cent, effects); - } - // RAFAEL - else if ((effects & Defines.EF_IONRIPPER) != 0) { - CL_fx.IonripperTrail(cent.lerp_origin, ent.origin); - V.AddLight(ent.origin, 100, 1, 0.5f, 0.5f); - } - // RAFAEL - else if ((effects & Defines.EF_BLUEHYPERBLASTER) != 0) { - V.AddLight(ent.origin, 200, 0, 0, 1); - } - // RAFAEL - else if ((effects & Defines.EF_PLASMA) != 0) { - if ((effects & Defines.EF_ANIM_ALLFAST) != 0) { - CL_fx.BlasterTrail(cent.lerp_origin, ent.origin); - } - V.AddLight(ent.origin, 130, 1, 0.5f, 0.5f); - } - } - - Math3D.VectorCopy(ent.origin, cent.lerp_origin); - } - } - - // stack variable - private static final entity_t gun = new entity_t(); - /* - * ============== CL_AddViewWeapon ============== - */ - static void AddViewWeapon(player_state_t ps, player_state_t ops) { - int i; - - // allow the gun to be completely removed - if (0 == Globals.cl_gun.value) - return; - - // Nope. -flibit - // don't draw gun if in wide angle view - // if (ps.fov > 90) - // return; - - //memset( gun, 0, sizeof(gun)); - gun.clear(); - - if (Globals.gun_model != null) - gun.model = Globals.gun_model; // development tool - else - gun.model = Globals.cl.model_draw[ps.gunindex]; - - if (gun.model == null) - return; - - // set up gun position - for (i = 0; i < 3; i++) { - gun.origin[i] = Globals.cl.refdef.vieworg[i] + ops.gunoffset[i] + Globals.cl.lerpfrac - * (ps.gunoffset[i] - ops.gunoffset[i]); - gun.angles[i] = Globals.cl.refdef.viewangles[i] + Math3D.LerpAngle(ops.gunangles[i], ps.gunangles[i], Globals.cl.lerpfrac); - } - - if (Globals.gun_frame != 0) { - gun.frame = Globals.gun_frame; // development tool - gun.oldframe = Globals.gun_frame; // development tool - } else { - gun.frame = ps.gunframe; - if (gun.frame == 0) - gun.oldframe = 0; // just changed weapons, don't lerp from old - else - gun.oldframe = ops.gunframe; - } - - gun.flags = Defines.RF_MINLIGHT | Defines.RF_DEPTHHACK | Defines.RF_WEAPONMODEL; - gun.backlerp = 1.0f - Globals.cl.lerpfrac; - Math3D.VectorCopy(gun.origin, gun.oldorigin); // don't lerp at all - V.AddEntity(gun); - } - - /* - * =============== CL_CalcViewValues - * - * Sets cl.refdef view values =============== - */ - static void CalcViewValues() { - int i; - float lerp, backlerp; - frame_t oldframe; - player_state_t ps, ops; - - // find the previous frame to interpolate from - ps = Globals.cl.frame.playerstate; - - i = (Globals.cl.frame.serverframe - 1) & Defines.UPDATE_MASK; - oldframe = Globals.cl.frames[i]; - - if (oldframe.serverframe != Globals.cl.frame.serverframe - 1 || !oldframe.valid) - oldframe = Globals.cl.frame; // previous frame was dropped or - // involid - ops = oldframe.playerstate; - - // see if the player entity was teleported this frame - if (Math.abs(ops.pmove.origin[0] - ps.pmove.origin[0]) > 256 * 8 - || Math.abs(ops.pmove.origin[1] - ps.pmove.origin[1]) > 256 * 8 - || Math.abs(ops.pmove.origin[2] - ps.pmove.origin[2]) > 256 * 8) - ops = ps; // don't interpolate - - lerp = Globals.cl.lerpfrac; - - // calculate the origin - if ((Globals.cl_predict.value != 0) && 0 == (Globals.cl.frame.playerstate.pmove.pm_flags & pmove_t.PMF_NO_PREDICTION)) { // use - // predicted - // values - int delta; - - backlerp = 1.0f - lerp; - for (i = 0; i < 3; i++) { - Globals.cl.refdef.vieworg[i] = Globals.cl.predicted_origin[i] + ops.viewoffset[i] + Globals.cl.lerpfrac - * (ps.viewoffset[i] - ops.viewoffset[i]) - backlerp * Globals.cl.prediction_error[i]; - } - - // smooth out stair climbing - delta = (int) (Globals.cls.realtime - Globals.cl.predicted_step_time); - if (delta < 100) - Globals.cl.refdef.vieworg[2] -= Globals.cl.predicted_step * (100 - delta) * 0.01; - } else { // just use interpolated values - for (i = 0; i < 3; i++) - Globals.cl.refdef.vieworg[i] = ops.pmove.origin[i] * 0.125f + ops.viewoffset[i] + lerp - * (ps.pmove.origin[i] * 0.125f + ps.viewoffset[i] - (ops.pmove.origin[i] * 0.125f + ops.viewoffset[i])); - } - - // if not running a demo or on a locked frame, add the local angle - // movement - if (Globals.cl.frame.playerstate.pmove.pm_type < Defines.PM_DEAD) { // use - // predicted - // values - for (i = 0; i < 3; i++) - Globals.cl.refdef.viewangles[i] = Globals.cl.predicted_angles[i]; - } else { // just use interpolated values - for (i = 0; i < 3; i++) - Globals.cl.refdef.viewangles[i] = Math3D.LerpAngle(ops.viewangles[i], ps.viewangles[i], lerp); - } - - for (i = 0; i < 3; i++) - Globals.cl.refdef.viewangles[i] += Math3D.LerpAngle(ops.kick_angles[i], ps.kick_angles[i], lerp); - - Math3D.AngleVectors(Globals.cl.refdef.viewangles, Globals.cl.v_forward, Globals.cl.v_right, Globals.cl.v_up); - - // interpolate field of view - Globals.cl.refdef.fov_x = ops.fov + lerp * (ps.fov - ops.fov); - - // don't interpolate blend color - for (i = 0; i < 4; i++) - Globals.cl.refdef.blend[i] = ps.blend[i]; - - // add the weapon - AddViewWeapon(ps, ops); - } - - /* - * =============== CL_AddEntities - * - * Emits all entities, particles, and lights to the refresh =============== - */ - static void AddEntities() { - if (Globals.cls.state != Defines.ca_active) - return; - - if (Globals.cl.time > Globals.cl.frame.servertime) { - if (Globals.cl_showclamp.value != 0) - Com.Printf("high clamp " + (Globals.cl.time - Globals.cl.frame.servertime) + "\n"); - Globals.cl.time = Globals.cl.frame.servertime; - Globals.cl.lerpfrac = 1.0f; - } else if (Globals.cl.time < Globals.cl.frame.servertime - 100) { - if (Globals.cl_showclamp.value != 0) - Com.Printf("low clamp " + (Globals.cl.frame.servertime - 100 - Globals.cl.time) + "\n"); - Globals.cl.time = Globals.cl.frame.servertime - 100; - Globals.cl.lerpfrac = 0; - } else - Globals.cl.lerpfrac = 1.0f - (Globals.cl.frame.servertime - Globals.cl.time) * 0.01f; - - if (Globals.cl_timedemo.value != 0) - Globals.cl.lerpfrac = 1.0f; - - /* - * is ok.. CL_AddPacketEntities (cl.frame); CL_AddTEnts (); - * CL_AddParticles (); CL_AddDLights (); CL_AddLightStyles (); - */ - - CalcViewValues(); - // PMM - moved this here so the heat beam has the right values for the - // vieworg, and can lock the beam to the gun - AddPacketEntities(Globals.cl.frame); - - CL_tent.AddTEnts(); - CL_fx.AddParticles(); - CL_fx.AddDLights(); - CL_fx.AddLightStyles(); - } - - /* - * =============== CL_GetEntitySoundOrigin - * - * Called to get the sound spatialization origin =============== - */ - public static void GetEntitySoundOrigin(int ent, float[] org) { - centity_t old; - - if (ent < 0 || ent >= Defines.MAX_EDICTS) - Com.Error(Defines.ERR_DROP, "CL_GetEntitySoundOrigin: bad ent"); - old = Globals.cl_entities[ent]; - Math3D.VectorCopy(old.lerp_origin, org); - - // FIXME: bmodel issues... - } + private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); + + static int bitcounts[] = new int[32]; /// just for protocol profiling + + static int bfg_lightramp[] = { 300, 400, 600, 300, 150, 75 }; + + /* + * ================= CL_ParseEntityBits + * + * Returns the entity number and the header bits ================= + */ + public static int ParseEntityBits(int bits[]) { + int b, total; + int i; + int number; + + total = MSG.ReadByte(Globals.net_message); + if ((total & Defines.U_MOREBITS1) != 0) { + + b = MSG.ReadByte(Globals.net_message); + total |= b << 8; + } + if ((total & Defines.U_MOREBITS2) != 0) { + + b = MSG.ReadByte(Globals.net_message); + total |= b << 16; + } + if ((total & Defines.U_MOREBITS3) != 0) { + + b = MSG.ReadByte(Globals.net_message); + total |= b << 24; + } + + // count the bits for net profiling + for (i = 0; i < 32; i++) + if ((total & (1 << i)) != 0) + bitcounts[i]++; + + if ((total & Defines.U_NUMBER16) != 0) + number = MSG.ReadShort(Globals.net_message); + else + number = MSG.ReadByte(Globals.net_message); + + bits[0] = total; + + return number; + } + + /* + * ================== CL_ParseDelta + * + * Can go from either a baseline or a previous packet_entity + * ================== + */ + public static void ParseDelta(entity_state_t from, entity_state_t to, int number, int bits) { + // set everything to the state we are delta'ing from + to.set(from); + + Math3D.VectorCopy(from.origin, to.old_origin); + to.number = number; + + if ((bits & Defines.U_MODEL) != 0) + to.modelindex = MSG.ReadByte(Globals.net_message); + if ((bits & Defines.U_MODEL2) != 0) + to.modelindex2 = MSG.ReadByte(Globals.net_message); + if ((bits & Defines.U_MODEL3) != 0) + to.modelindex3 = MSG.ReadByte(Globals.net_message); + if ((bits & Defines.U_MODEL4) != 0) + to.modelindex4 = MSG.ReadByte(Globals.net_message); + + if ((bits & Defines.U_FRAME8) != 0) + to.frame = MSG.ReadByte(Globals.net_message); + if ((bits & Defines.U_FRAME16) != 0) + to.frame = MSG.ReadShort(Globals.net_message); + + if ((bits & Defines.U_SKIN8) != 0 && (bits & Defines.U_SKIN16) != 0) //used + // for + // laser + // colors + to.skinnum = MSG.ReadLong(Globals.net_message); + else if ((bits & Defines.U_SKIN8) != 0) + to.skinnum = MSG.ReadByte(Globals.net_message); + else if ((bits & Defines.U_SKIN16) != 0) + to.skinnum = MSG.ReadShort(Globals.net_message); + + if ((bits & (Defines.U_EFFECTS8 | Defines.U_EFFECTS16)) == (Defines.U_EFFECTS8 | Defines.U_EFFECTS16)) + to.effects = MSG.ReadLong(Globals.net_message); + else if ((bits & Defines.U_EFFECTS8) != 0) + to.effects = MSG.ReadByte(Globals.net_message); + else if ((bits & Defines.U_EFFECTS16) != 0) + to.effects = MSG.ReadShort(Globals.net_message); + + if ((bits & (Defines.U_RENDERFX8 | Defines.U_RENDERFX16)) == (Defines.U_RENDERFX8 | Defines.U_RENDERFX16)) + to.renderfx = MSG.ReadLong(Globals.net_message); + else if ((bits & Defines.U_RENDERFX8) != 0) + to.renderfx = MSG.ReadByte(Globals.net_message); + else if ((bits & Defines.U_RENDERFX16) != 0) + to.renderfx = MSG.ReadShort(Globals.net_message); + + if ((bits & Defines.U_ORIGIN1) != 0) + to.origin[0] = MSG.ReadCoord(Globals.net_message); + if ((bits & Defines.U_ORIGIN2) != 0) + to.origin[1] = MSG.ReadCoord(Globals.net_message); + if ((bits & Defines.U_ORIGIN3) != 0) + to.origin[2] = MSG.ReadCoord(Globals.net_message); + + if ((bits & Defines.U_ANGLE1) != 0) + to.angles[0] = MSG.ReadAngle(Globals.net_message); + if ((bits & Defines.U_ANGLE2) != 0) + to.angles[1] = MSG.ReadAngle(Globals.net_message); + if ((bits & Defines.U_ANGLE3) != 0) + to.angles[2] = MSG.ReadAngle(Globals.net_message); + + if ((bits & Defines.U_OLDORIGIN) != 0) + MSG.ReadPos(Globals.net_message, to.old_origin); + + if ((bits & Defines.U_SOUND) != 0) + to.sound = MSG.ReadByte(Globals.net_message); + + if ((bits & Defines.U_EVENT) != 0) + to.event = MSG.ReadByte(Globals.net_message); + else + to.event = 0; + + if ((bits & Defines.U_SOLID) != 0) + to.solid = MSG.ReadShort(Globals.net_message); + } + + /* + * ================== CL_DeltaEntity + * + * Parses deltas from the given base and adds the resulting entity to the + * current frame ================== + */ + public static void DeltaEntity(frame_t frame, int newnum, entity_state_t old, int bits) { + centity_t ent; + entity_state_t state; + + ent = Globals.cl_entities[newnum]; + + state = Globals.cl_parse_entities[Globals.cl.parse_entities & (Defines.MAX_PARSE_ENTITIES - 1)]; + Globals.cl.parse_entities++; + frame.num_entities++; + + ParseDelta(old, state, newnum, bits); + + // some data changes will force no lerping + if (state.modelindex != ent.current.modelindex || state.modelindex2 != ent.current.modelindex2 + || state.modelindex3 != ent.current.modelindex3 || state.modelindex4 != ent.current.modelindex4 + || Math.abs(state.origin[0] - ent.current.origin[0]) > 512 || Math.abs(state.origin[1] - ent.current.origin[1]) > 512 + || Math.abs(state.origin[2] - ent.current.origin[2]) > 512 || state.event == Defines.EV_PLAYER_TELEPORT + || state.event == Defines.EV_OTHER_TELEPORT) { + ent.serverframe = -99; + } + + if (ent.serverframe != Globals.cl.frame.serverframe - 1) { // wasn't in + // last + // update, so + // initialize + // some + // things + ent.trailcount = 1024; // for diminishing rocket / grenade trails + // duplicate the current state so lerping doesn't hurt anything + ent.prev.set(state); + if (state.event == Defines.EV_OTHER_TELEPORT) { + Math3D.VectorCopy(state.origin, ent.prev.origin); + Math3D.VectorCopy(state.origin, ent.lerp_origin); + } else { + Math3D.VectorCopy(state.old_origin, ent.prev.origin); + Math3D.VectorCopy(state.old_origin, ent.lerp_origin); + } + } else { // shuffle the last state to previous + // Copy ! + ent.prev.set(ent.current); + } + + ent.serverframe = Globals.cl.frame.serverframe; + // Copy ! + ent.current.set(state); + } + + // call by reference + private static final int[] iw = {0}; + /* + * ================== CL_ParsePacketEntities + * + * An svc_packetentities has just been parsed, deal with the rest of the + * data stream. ================== + */ + public static void ParsePacketEntities(frame_t oldframe, frame_t newframe) { + int newnum; + int bits = 0; + + entity_state_t oldstate = null; + int oldnum; + + newframe.parse_entities = Globals.cl.parse_entities; + newframe.num_entities = 0; + + // delta from the entities present in oldframe + int oldindex = 0; + if (oldframe == null) + oldnum = 99999; + else { + // oldindex == 0. hoz + // if (oldindex >= oldframe.num_entities) + // oldnum = 99999; + // else { + oldstate = Globals.cl_parse_entities[(oldframe.parse_entities + oldindex) & (Defines.MAX_PARSE_ENTITIES - 1)]; + oldnum = oldstate.number; + // } + } + + while (true) { + //int iw[] = { bits }; + iw[0] = bits; + newnum = ParseEntityBits(iw); + bits = iw[0]; + + if (newnum >= Defines.MAX_EDICTS) + Com.Error(Defines.ERR_DROP, "CL_ParsePacketEntities: bad number:" + newnum); + + if (Globals.net_message.readcount > Globals.net_message.cursize) + Com.Error(Defines.ERR_DROP, "CL_ParsePacketEntities: end of message"); + + if (0 == newnum) + break; + + while (oldnum < newnum) { // one or more entities from the old + // packet are unchanged + if (Globals.cl_shownet.value == 3) + Com.Printf(" unchanged: " + oldnum + "\n"); + DeltaEntity(newframe, oldnum, oldstate, 0); + + oldindex++; + + if (oldindex >= oldframe.num_entities) + oldnum = 99999; + else { + oldstate = Globals.cl_parse_entities[(oldframe.parse_entities + oldindex) & (Defines.MAX_PARSE_ENTITIES - 1)]; + oldnum = oldstate.number; + } + } + + if ((bits & Defines.U_REMOVE) != 0) { // the entity present in + // oldframe is not in the + // current frame + if (Globals.cl_shownet.value == 3) + Com.Printf(" remove: " + newnum + "\n"); + if (oldnum != newnum) + Com.Printf("U_REMOVE: oldnum != newnum\n"); + + oldindex++; + + if (oldindex >= oldframe.num_entities) + oldnum = 99999; + else { + oldstate = Globals.cl_parse_entities[(oldframe.parse_entities + oldindex) & (Defines.MAX_PARSE_ENTITIES - 1)]; + oldnum = oldstate.number; + } + continue; + } + + if (oldnum == newnum) { // delta from previous state + if (Globals.cl_shownet.value == 3) + Com.Printf(" delta: " + newnum + "\n"); + DeltaEntity(newframe, newnum, oldstate, bits); + + oldindex++; + + if (oldindex >= oldframe.num_entities) + oldnum = 99999; + else { + oldstate = Globals.cl_parse_entities[(oldframe.parse_entities + oldindex) & (Defines.MAX_PARSE_ENTITIES - 1)]; + oldnum = oldstate.number; + } + continue; + } + + if (oldnum > newnum) { // delta from baseline + if (Globals.cl_shownet.value == 3) + Com.Printf(" baseline: " + newnum + "\n"); + DeltaEntity(newframe, newnum, Globals.cl_entities[newnum].baseline, bits); + continue; + } + + } + + // any remaining entities in the old frame are copied over + while (oldnum != 99999) { // one or more entities from the old packet + // are unchanged + if (Globals.cl_shownet.value == 3) + Com.Printf(" unchanged: " + oldnum + "\n"); + DeltaEntity(newframe, oldnum, oldstate, 0); + + oldindex++; + + if (oldindex >= oldframe.num_entities) + oldnum = 99999; + else { + oldstate = Globals.cl_parse_entities[(oldframe.parse_entities + oldindex) & (Defines.MAX_PARSE_ENTITIES - 1)]; + oldnum = oldstate.number; + } + } + } + + /* + * =================== CL_ParsePlayerstate =================== + */ + public static void ParsePlayerstate(frame_t oldframe, frame_t newframe) { + int flags; + player_state_t state; + int i; + int statbits; + + state = newframe.playerstate; + + // clear to old value before delta parsing + if (oldframe != null) + state.set(oldframe.playerstate); + else + //memset (state, 0, sizeof(*state)); + state.clear(); + + flags = MSG.ReadShort(Globals.net_message); + + // + // parse the pmove_state_t + // + if ((flags & Defines.PS_M_TYPE) != 0) + state.pmove.pm_type = MSG.ReadByte(Globals.net_message); + + if ((flags & Defines.PS_M_ORIGIN) != 0) { + state.pmove.origin[0] = MSG.ReadShort(Globals.net_message); + state.pmove.origin[1] = MSG.ReadShort(Globals.net_message); + state.pmove.origin[2] = MSG.ReadShort(Globals.net_message); + } + + if ((flags & Defines.PS_M_VELOCITY) != 0) { + state.pmove.velocity[0] = MSG.ReadShort(Globals.net_message); + state.pmove.velocity[1] = MSG.ReadShort(Globals.net_message); + state.pmove.velocity[2] = MSG.ReadShort(Globals.net_message); + } + + if ((flags & Defines.PS_M_TIME) != 0) { + state.pmove.pm_time = (byte) MSG.ReadByte(Globals.net_message); + } + + if ((flags & Defines.PS_M_FLAGS) != 0) + state.pmove.pm_flags = (byte) MSG.ReadByte(Globals.net_message); + + if ((flags & Defines.PS_M_GRAVITY) != 0) + state.pmove.gravity = MSG.ReadShort(Globals.net_message); + + if ((flags & Defines.PS_M_DELTA_ANGLES) != 0) { + state.pmove.delta_angles[0] = MSG.ReadShort(Globals.net_message); + state.pmove.delta_angles[1] = MSG.ReadShort(Globals.net_message); + state.pmove.delta_angles[2] = MSG.ReadShort(Globals.net_message); + } + + if (Globals.cl.attractloop) + state.pmove.pm_type = Defines.PM_FREEZE; // demo playback + + // + // parse the rest of the player_state_t + // + if ((flags & Defines.PS_VIEWOFFSET) != 0) { + state.viewoffset[0] = MSG.ReadChar(Globals.net_message) * 0.25f; + state.viewoffset[1] = MSG.ReadChar(Globals.net_message) * 0.25f; + state.viewoffset[2] = MSG.ReadChar(Globals.net_message) * 0.25f; + } + + if ((flags & Defines.PS_VIEWANGLES) != 0) { + state.viewangles[0] = MSG.ReadAngle16(Globals.net_message); + state.viewangles[1] = MSG.ReadAngle16(Globals.net_message); + state.viewangles[2] = MSG.ReadAngle16(Globals.net_message); + } + + if ((flags & Defines.PS_KICKANGLES) != 0) { + + state.kick_angles[0] = MSG.ReadChar(Globals.net_message) * 0.25f; + state.kick_angles[1] = MSG.ReadChar(Globals.net_message) * 0.25f; + state.kick_angles[2] = MSG.ReadChar(Globals.net_message) * 0.25f; + + } + + if ((flags & Defines.PS_WEAPONINDEX) != 0) { + state.gunindex = MSG.ReadByte(Globals.net_message); + } + + if ((flags & Defines.PS_WEAPONFRAME) != 0) { + state.gunframe = MSG.ReadByte(Globals.net_message); + state.gunoffset[0] = MSG.ReadChar(Globals.net_message) * 0.25f; + state.gunoffset[1] = MSG.ReadChar(Globals.net_message) * 0.25f; + state.gunoffset[2] = MSG.ReadChar(Globals.net_message) * 0.25f; + state.gunangles[0] = MSG.ReadChar(Globals.net_message) * 0.25f; + state.gunangles[1] = MSG.ReadChar(Globals.net_message) * 0.25f; + state.gunangles[2] = MSG.ReadChar(Globals.net_message) * 0.25f; + } + + if ((flags & Defines.PS_BLEND) != 0) { + state.blend[0] = MSG.ReadByte(Globals.net_message) / 255.0f; + state.blend[1] = MSG.ReadByte(Globals.net_message) / 255.0f; + state.blend[2] = MSG.ReadByte(Globals.net_message) / 255.0f; + state.blend[3] = MSG.ReadByte(Globals.net_message) / 255.0f; + } + + if ((flags & Defines.PS_FOV) != 0) + state.fov = MSG.ReadByte(Globals.net_message); + + if ((flags & Defines.PS_RDFLAGS) != 0) + state.rdflags = MSG.ReadByte(Globals.net_message); + + // parse stats + statbits = MSG.ReadLong(Globals.net_message); + for (i = 0; i < Defines.MAX_STATS; i++) + if ((statbits & (1 << i)) != 0) + state.stats[i] = MSG.ReadShort(Globals.net_message); + } + + /* + * ================== CL_FireEntityEvents + * + * ================== + */ + public static void FireEntityEvents(frame_t frame) { + entity_state_t s1; + int pnum, num; + + for (pnum = 0; pnum < frame.num_entities; pnum++) { + num = (frame.parse_entities + pnum) & (Defines.MAX_PARSE_ENTITIES - 1); + s1 = Globals.cl_parse_entities[num]; + if (s1.event != 0) + CL_fx.EntityEvent(s1); + + // EF_TELEPORTER acts like an event, but is not cleared each frame + if ((s1.effects & Defines.EF_TELEPORTER) != 0) + CL_fx.TeleporterParticles(s1); + } + } + + /* + * ================ CL_ParseFrame ================ + */ + public static void ParseFrame() { + int cmd; + int len; + frame_t old; + + //memset( cl.frame, 0, sizeof(cl.frame)); + Globals.cl.frame.reset(); + + Globals.cl.frame.serverframe = MSG.ReadLong(Globals.net_message); + Globals.cl.frame.deltaframe = MSG.ReadLong(Globals.net_message); + Globals.cl.frame.servertime = Globals.cl.frame.serverframe * 100; + + // BIG HACK to let old demos continue to work + if (Globals.cls.serverProtocol != 26) + Globals.cl.surpressCount = MSG.ReadByte(Globals.net_message); + + if (Globals.cl_shownet.value == 3) + Com.Printf(" frame:" + Globals.cl.frame.serverframe + " delta:" + Globals.cl.frame.deltaframe + "\n"); + + // If the frame is delta compressed from data that we + // no longer have available, we must suck up the rest of + // the frame, but not use it, then ask for a non-compressed + // message + if (Globals.cl.frame.deltaframe <= 0) { + Globals.cl.frame.valid = true; // uncompressed frame + old = null; + Globals.cls.demowaiting = false; // we can start recording now + } else { + old = Globals.cl.frames[Globals.cl.frame.deltaframe & Defines.UPDATE_MASK]; + if (!old.valid) { // should never happen + Com.Printf("Delta from invalid frame (not supposed to happen!).\n"); + } + if (old.serverframe != Globals.cl.frame.deltaframe) { // The frame + // that the + // server did + // the delta + // from + // is too old, so we can't reconstruct it properly. + Com.Printf("Delta frame too old.\n"); + } else if (Globals.cl.parse_entities - old.parse_entities > Defines.MAX_PARSE_ENTITIES - 128) { + Com.Printf("Delta parse_entities too old.\n"); + } else + Globals.cl.frame.valid = true; // valid delta parse + } + + // clamp time + if (Globals.cl.time > Globals.cl.frame.servertime) + Globals.cl.time = Globals.cl.frame.servertime; + else if (Globals.cl.time < Globals.cl.frame.servertime - 100) + Globals.cl.time = Globals.cl.frame.servertime - 100; + + // read areabits + len = MSG.ReadByte(Globals.net_message); + MSG.ReadData(Globals.net_message, Globals.cl.frame.areabits, len); + + // read playerinfo + cmd = MSG.ReadByte(Globals.net_message); + CL_parse.SHOWNET(CL_parse.svc_strings[cmd]); + if (cmd != Defines.svc_playerinfo) + Com.Error(Defines.ERR_DROP, "CL_ParseFrame: not playerinfo"); + ParsePlayerstate(old, Globals.cl.frame); + + // read packet entities + cmd = MSG.ReadByte(Globals.net_message); + CL_parse.SHOWNET(CL_parse.svc_strings[cmd]); + if (cmd != Defines.svc_packetentities) + Com.Error(Defines.ERR_DROP, "CL_ParseFrame: not packetentities"); + + ParsePacketEntities(old, Globals.cl.frame); + + // save the frame off in the backup array for later delta comparisons + Globals.cl.frames[Globals.cl.frame.serverframe & Defines.UPDATE_MASK].set(Globals.cl.frame); + + if (Globals.cl.frame.valid) { + // getting a valid frame message ends the connection process + if (Globals.cls.state != Defines.ca_active) { + Globals.cls.state = Defines.ca_active; + Globals.cl.force_refdef = true; + + Globals.cl.predicted_origin[0] = Globals.cl.frame.playerstate.pmove.origin[0] * 0.125f; + Globals.cl.predicted_origin[1] = Globals.cl.frame.playerstate.pmove.origin[1] * 0.125f; + Globals.cl.predicted_origin[2] = Globals.cl.frame.playerstate.pmove.origin[2] * 0.125f; + + Math3D.VectorCopy(Globals.cl.frame.playerstate.viewangles, Globals.cl.predicted_angles); + if (Globals.cls.disable_servercount != Globals.cl.servercount && Globals.cl.refresh_prepped) + SCR.EndLoadingPlaque(); // get rid of loading plaque + } + Globals.cl.sound_prepped = true; // can start mixing ambient sounds + + // fire entity events + FireEntityEvents(Globals.cl.frame); + CL_pred.CheckPredictionError(); + } + } + + /* + * ========================================================================== + * + * INTERPOLATE BETWEEN FRAMES TO GET RENDERING PARMS + * + * ========================================================================== + */ + + // stack variable + private static final entity_t ent = new entity_t(); + /* + * =============== + * CL_AddPacketEntities + * =============== + */ + static void AddPacketEntities(frame_t frame) { + entity_state_t s1; + float autorotate; + int i; + int pnum; + centity_t cent; + int autoanim; + clientinfo_t ci; + int effects, renderfx; + + // bonus items rotate at a fixed rate + autorotate = Math3D.anglemod(Globals.cl.time / 10); + + // brush models can auto animate their frames + autoanim = 2 * Globals.cl.time / 1000; + + //memset( ent, 0, sizeof(ent)); + ent.clear(); + + for (pnum = 0; pnum < frame.num_entities; pnum++) { + s1 = Globals.cl_parse_entities[(frame.parse_entities + pnum) & (Defines.MAX_PARSE_ENTITIES - 1)]; + + cent = Globals.cl_entities[s1.number]; + + effects = s1.effects; + renderfx = s1.renderfx; + + // set frame + if ((effects & Defines.EF_ANIM01) != 0) + ent.frame = autoanim & 1; + else if ((effects & Defines.EF_ANIM23) != 0) + ent.frame = 2 + (autoanim & 1); + else if ((effects & Defines.EF_ANIM_ALL) != 0) + ent.frame = autoanim; + else if ((effects & Defines.EF_ANIM_ALLFAST) != 0) + ent.frame = Globals.cl.time / 100; + else + ent.frame = s1.frame; + + // quad and pent can do different things on client + if ((effects & Defines.EF_PENT) != 0) { + effects &= ~Defines.EF_PENT; + effects |= Defines.EF_COLOR_SHELL; + renderfx |= Defines.RF_SHELL_RED; + } + + if ((effects & Defines.EF_QUAD) != 0) { + effects &= ~Defines.EF_QUAD; + effects |= Defines.EF_COLOR_SHELL; + renderfx |= Defines.RF_SHELL_BLUE; + } + // ====== + // PMM + if ((effects & Defines.EF_DOUBLE) != 0) { + effects &= ~Defines.EF_DOUBLE; + effects |= Defines.EF_COLOR_SHELL; + renderfx |= Defines.RF_SHELL_DOUBLE; + } + + if ((effects & Defines.EF_HALF_DAMAGE) != 0) { + effects &= ~Defines.EF_HALF_DAMAGE; + effects |= Defines.EF_COLOR_SHELL; + renderfx |= Defines.RF_SHELL_HALF_DAM; + } + // pmm + // ====== + ent.oldframe = cent.prev.frame; + ent.backlerp = 1.0f - Globals.cl.lerpfrac; + + if ((renderfx & (Defines.RF_FRAMELERP | Defines.RF_BEAM)) != 0) { + // step origin discretely, because the frames + // do the animation properly + Math3D.VectorCopy(cent.current.origin, ent.origin); + Math3D.VectorCopy(cent.current.old_origin, ent.oldorigin); + } else { // interpolate origin + for (i = 0; i < 3; i++) { + ent.origin[i] = ent.oldorigin[i] = cent.prev.origin[i] + Globals.cl.lerpfrac + * (cent.current.origin[i] - cent.prev.origin[i]); + } + } + + // create a new entity + + // tweak the color of beams + if ((renderfx & Defines.RF_BEAM) != 0) { // the four beam colors are + // encoded in 32 bits of + // skinnum (hack) + ent.alpha = 0.30f; + ent.skinnum = (s1.skinnum >> ((Globals.rnd.nextInt(4)) * 8)) & 0xff; + Math.random(); + ent.model = null; + } else { + // set skin + if (s1.modelindex == 255) { // use custom player skin + ent.skinnum = 0; + ci = Globals.cl.clientinfo[s1.skinnum & 0xff]; + ent.skin = ci.skin; + ent.model = ci.model; + if (null == ent.skin || null == ent.model) { + ent.skin = Globals.cl.baseclientinfo.skin; + ent.model = Globals.cl.baseclientinfo.model; + } + + // ============ + // PGM + if ((renderfx & Defines.RF_USE_DISGUISE) != 0) { + if (ent.skin.name.startsWith("players/male")) { + ent.skin = Globals.re.RegisterSkin("players/male/disguise.pcx"); + ent.model = Globals.re.RegisterModel("players/male/tris.md2"); + } else if (ent.skin.name.startsWith("players/female")) { + ent.skin = Globals.re.RegisterSkin("players/female/disguise.pcx"); + ent.model = Globals.re.RegisterModel("players/female/tris.md2"); + } else if (ent.skin.name.startsWith("players/cyborg")) { + ent.skin = Globals.re.RegisterSkin("players/cyborg/disguise.pcx"); + ent.model = Globals.re.RegisterModel("players/cyborg/tris.md2"); + } + } + // PGM + // ============ + } else { + ent.skinnum = s1.skinnum; + ent.skin = null; + ent.model = Globals.cl.model_draw[s1.modelindex]; + } + } + + // only used for black hole model right now, FIXME: do better + if (renderfx == Defines.RF_TRANSLUCENT) + ent.alpha = 0.70f; + + // render effects (fullbright, translucent, etc) + if ((effects & Defines.EF_COLOR_SHELL) != 0) + ent.flags = 0; // renderfx go on color shell entity + else + ent.flags = renderfx; + + // calculate angles + if ((effects & Defines.EF_ROTATE) != 0) { // some bonus items + // auto-rotate + ent.angles[0] = 0; + ent.angles[1] = autorotate; + ent.angles[2] = 0; + } + // RAFAEL + else if ((effects & Defines.EF_SPINNINGLIGHTS) != 0) { + ent.angles[0] = 0; + ent.angles[1] = Math3D.anglemod(Globals.cl.time / 2) + s1.angles[1]; + ent.angles[2] = 180; + { + float[] forward = { 0, 0, 0 }; + float[] start = { 0, 0, 0 }; + + Math3D.AngleVectors(ent.angles, forward, null, null); + Math3D.VectorMA(ent.origin, 64, forward, start); + V.AddLight(start, 100, 1, 0, 0); + } + } else { // interpolate angles + float a1, a2; + + for (i = 0; i < 3; i++) { + a1 = cent.current.angles[i]; + a2 = cent.prev.angles[i]; + ent.angles[i] = Math3D.LerpAngle(a2, a1, Globals.cl.lerpfrac); + } + } + + if (s1.number == Globals.cl.playernum + 1) { + ent.flags |= Defines.RF_VIEWERMODEL; // only draw from mirrors + // FIXME: still pass to refresh + + if ((effects & Defines.EF_FLAG1) != 0) + V.AddLight(ent.origin, 225, 1.0f, 0.1f, 0.1f); + else if ((effects & Defines.EF_FLAG2) != 0) + V.AddLight(ent.origin, 225, 0.1f, 0.1f, 1.0f); + else if ((effects & Defines.EF_TAGTRAIL) != 0) //PGM + V.AddLight(ent.origin, 225, 1.0f, 1.0f, 0.0f); //PGM + else if ((effects & Defines.EF_TRACKERTRAIL) != 0) //PGM + V.AddLight(ent.origin, 225, -1.0f, -1.0f, -1.0f); //PGM + + continue; + } + + // if set to invisible, skip + if (s1.modelindex == 0) + continue; + + if ((effects & Defines.EF_BFG) != 0) { + ent.flags |= Defines.RF_TRANSLUCENT; + ent.alpha = 0.30f; + } + + // RAFAEL + if ((effects & Defines.EF_PLASMA) != 0) { + ent.flags |= Defines.RF_TRANSLUCENT; + ent.alpha = 0.6f; + } + + if ((effects & Defines.EF_SPHERETRANS) != 0) { + ent.flags |= Defines.RF_TRANSLUCENT; + // PMM - *sigh* yet more EF overloading + if ((effects & Defines.EF_TRACKERTRAIL) != 0) + ent.alpha = 0.6f; + else + ent.alpha = 0.3f; + } + // pmm + + // add to refresh list + V.AddEntity(ent); + + // color shells generate a seperate entity for the main model + if ((effects & Defines.EF_COLOR_SHELL) != 0) { + /* + * PMM - at this point, all of the shells have been handled if + * we're in the rogue pack, set up the custom mixing, otherwise + * just keep going if(Developer_searchpath(2) == 2) { all of the + * solo colors are fine. we need to catch any of the + * combinations that look bad (double & half) and turn them into + * the appropriate color, and make double/quad something special + * + */ + if ((renderfx & Defines.RF_SHELL_HALF_DAM) != 0) { + if (fileSystem.developer_searchpath(2) == 2) { + // ditch the half damage shell if any of red, blue, or + // double are on + if ((renderfx & (Defines.RF_SHELL_RED | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE)) != 0) + renderfx &= ~Defines.RF_SHELL_HALF_DAM; + } + } + + if ((renderfx & Defines.RF_SHELL_DOUBLE) != 0) { + if (fileSystem.developer_searchpath(2) == 2) { + // lose the yellow shell if we have a red, blue, or + // green shell + if ((renderfx & (Defines.RF_SHELL_RED | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_GREEN)) != 0) + renderfx &= ~Defines.RF_SHELL_DOUBLE; + // if we have a red shell, turn it to purple by adding + // blue + if ((renderfx & Defines.RF_SHELL_RED) != 0) + renderfx |= Defines.RF_SHELL_BLUE; + // if we have a blue shell (and not a red shell), turn + // it to cyan by adding green + else if ((renderfx & Defines.RF_SHELL_BLUE) != 0) + // go to green if it's on already, otherwise do cyan + // (flash green) + if ((renderfx & Defines.RF_SHELL_GREEN) != 0) + renderfx &= ~Defines.RF_SHELL_BLUE; + else + renderfx |= Defines.RF_SHELL_GREEN; + } + } + // } + // pmm + ent.flags = renderfx | Defines.RF_TRANSLUCENT; + ent.alpha = 0.30f; + V.AddEntity(ent); + } + + ent.skin = null; // never use a custom skin on others + ent.skinnum = 0; + ent.flags = 0; + ent.alpha = 0; + + // duplicate for linked models + if (s1.modelindex2 != 0) { + if (s1.modelindex2 == 255) { // custom weapon + ci = Globals.cl.clientinfo[s1.skinnum & 0xff]; + i = (s1.skinnum >> 8); // 0 is default weapon model + if (0 == Globals.cl_vwep.value || i > Defines.MAX_CLIENTWEAPONMODELS - 1) + i = 0; + ent.model = ci.weaponmodel[i]; + if (null == ent.model) { + if (i != 0) + ent.model = ci.weaponmodel[0]; + if (null == ent.model) + ent.model = Globals.cl.baseclientinfo.weaponmodel[0]; + } + } else + ent.model = Globals.cl.model_draw[s1.modelindex2]; + + // PMM - check for the defender sphere shell .. make it + // translucent + // replaces the previous version which used the high bit on + // modelindex2 to determine transparency + if (Globals.cl.configstrings[Defines.CS_MODELS + (s1.modelindex2)].equalsIgnoreCase("models/items/shell/tris.md2")) { + ent.alpha = 0.32f; + ent.flags = Defines.RF_TRANSLUCENT; + } + // pmm + + V.AddEntity(ent); + + //PGM - make sure these get reset. + ent.flags = 0; + ent.alpha = 0; + //PGM + } + if (s1.modelindex3 != 0) { + ent.model = Globals.cl.model_draw[s1.modelindex3]; + V.AddEntity(ent); + } + if (s1.modelindex4 != 0) { + ent.model = Globals.cl.model_draw[s1.modelindex4]; + V.AddEntity(ent); + } + + if ((effects & Defines.EF_POWERSCREEN) != 0) { + ent.model = CL_tent.cl_mod_powerscreen; + ent.oldframe = 0; + ent.frame = 0; + ent.flags |= (Defines.RF_TRANSLUCENT | Defines.RF_SHELL_GREEN); + ent.alpha = 0.30f; + V.AddEntity(ent); + } + + // add automatic particle trails + if ((effects & ~Defines.EF_ROTATE) != 0) { + if ((effects & Defines.EF_ROCKET) != 0) { + CL_fx.RocketTrail(cent.lerp_origin, ent.origin, cent); + V.AddLight(ent.origin, 200, 1, 1, 0); + } + // PGM - Do not reorder EF_BLASTER and EF_HYPERBLASTER. + // EF_BLASTER | EF_TRACKER is a special case for EF_BLASTER2... + // Cheese! + else if ((effects & Defines.EF_BLASTER) != 0) { + // CL_BlasterTrail (cent.lerp_origin, ent.origin); + // PGM + if ((effects & Defines.EF_TRACKER) != 0) // lame... + // problematic? + { + CL_newfx.BlasterTrail2(cent.lerp_origin, ent.origin); + V.AddLight(ent.origin, 200, 0, 1, 0); + } else { + CL_fx.BlasterTrail(cent.lerp_origin, ent.origin); + V.AddLight(ent.origin, 200, 1, 1, 0); + } + // PGM + } else if ((effects & Defines.EF_HYPERBLASTER) != 0) { + if ((effects & Defines.EF_TRACKER) != 0) // PGM overloaded + // for blaster2. + V.AddLight(ent.origin, 200, 0, 1, 0); // PGM + else + // PGM + V.AddLight(ent.origin, 200, 1, 1, 0); + } else if ((effects & Defines.EF_GIB) != 0) { + CL_fx.DiminishingTrail(cent.lerp_origin, ent.origin, cent, effects); + } else if ((effects & Defines.EF_GRENADE) != 0) { + CL_fx.DiminishingTrail(cent.lerp_origin, ent.origin, cent, effects); + } else if ((effects & Defines.EF_FLIES) != 0) { + CL_fx.FlyEffect(cent, ent.origin); + } else if ((effects & Defines.EF_BFG) != 0) { + + if ((effects & Defines.EF_ANIM_ALLFAST) != 0) { + CL_fx.BfgParticles(ent); + i = 200; + } else { + i = bfg_lightramp[s1.frame]; + } + V.AddLight(ent.origin, i, 0, 1, 0); + } + // RAFAEL + else if ((effects & Defines.EF_TRAP) != 0) { + ent.origin[2] += 32; + CL_fx.TrapParticles(ent); + i = (Globals.rnd.nextInt(100)) + 100; + V.AddLight(ent.origin, i, 1, 0.8f, 0.1f); + } else if ((effects & Defines.EF_FLAG1) != 0) { + CL_fx.FlagTrail(cent.lerp_origin, ent.origin, 242); + V.AddLight(ent.origin, 225, 1, 0.1f, 0.1f); + } else if ((effects & Defines.EF_FLAG2) != 0) { + CL_fx.FlagTrail(cent.lerp_origin, ent.origin, 115); + V.AddLight(ent.origin, 225, 0.1f, 0.1f, 1); + } + // ====== + // ROGUE + else if ((effects & Defines.EF_TAGTRAIL) != 0) { + CL_newfx.TagTrail(cent.lerp_origin, ent.origin, 220); + V.AddLight(ent.origin, 225, 1.0f, 1.0f, 0.0f); + } else if ((effects & Defines.EF_TRACKERTRAIL) != 0) { + if ((effects & Defines.EF_TRACKER) != 0) { + float intensity; + + intensity = (float) (50 + (500 * (Math.sin(Globals.cl.time / 500.0) + 1.0))); + // FIXME - check out this effect in rendition + if (Globals.vidref_val == Defines.VIDREF_GL) + V.AddLight(ent.origin, intensity, -1.0f, -1.0f, -1.0f); + else + V.AddLight(ent.origin, -1.0f * intensity, 1.0f, 1.0f, 1.0f); + } else { + CL_newfx.Tracker_Shell(cent.lerp_origin); + V.AddLight(ent.origin, 155, -1.0f, -1.0f, -1.0f); + } + } else if ((effects & Defines.EF_TRACKER) != 0) { + CL_newfx.TrackerTrail(cent.lerp_origin, ent.origin, 0); + // FIXME - check out this effect in rendition + if (Globals.vidref_val == Defines.VIDREF_GL) + V.AddLight(ent.origin, 200, -1, -1, -1); + else + V.AddLight(ent.origin, -200, 1, 1, 1); + } + // ROGUE + // ====== + // RAFAEL + else if ((effects & Defines.EF_GREENGIB) != 0) { + CL_fx.DiminishingTrail(cent.lerp_origin, ent.origin, cent, effects); + } + // RAFAEL + else if ((effects & Defines.EF_IONRIPPER) != 0) { + CL_fx.IonripperTrail(cent.lerp_origin, ent.origin); + V.AddLight(ent.origin, 100, 1, 0.5f, 0.5f); + } + // RAFAEL + else if ((effects & Defines.EF_BLUEHYPERBLASTER) != 0) { + V.AddLight(ent.origin, 200, 0, 0, 1); + } + // RAFAEL + else if ((effects & Defines.EF_PLASMA) != 0) { + if ((effects & Defines.EF_ANIM_ALLFAST) != 0) { + CL_fx.BlasterTrail(cent.lerp_origin, ent.origin); + } + V.AddLight(ent.origin, 130, 1, 0.5f, 0.5f); + } + } + + Math3D.VectorCopy(ent.origin, cent.lerp_origin); + } + } + + // stack variable + private static final entity_t gun = new entity_t(); + /* + * ============== CL_AddViewWeapon ============== + */ + static void AddViewWeapon(player_state_t ps, player_state_t ops) { + int i; + + // allow the gun to be completely removed + if (0 == Globals.cl_gun.value) + return; + + // Nope. -flibit + // don't draw gun if in wide angle view + // if (ps.fov > 90) + // return; + + //memset( gun, 0, sizeof(gun)); + gun.clear(); + + if (Globals.gun_model != null) + gun.model = Globals.gun_model; // development tool + else + gun.model = Globals.cl.model_draw[ps.gunindex]; + + if (gun.model == null) + return; + + // set up gun position + for (i = 0; i < 3; i++) { + gun.origin[i] = Globals.cl.refdef.vieworg[i] + ops.gunoffset[i] + Globals.cl.lerpfrac + * (ps.gunoffset[i] - ops.gunoffset[i]); + gun.angles[i] = Globals.cl.refdef.viewangles[i] + Math3D.LerpAngle(ops.gunangles[i], ps.gunangles[i], Globals.cl.lerpfrac); + } + + if (Globals.gun_frame != 0) { + gun.frame = Globals.gun_frame; // development tool + gun.oldframe = Globals.gun_frame; // development tool + } else { + gun.frame = ps.gunframe; + if (gun.frame == 0) + gun.oldframe = 0; // just changed weapons, don't lerp from old + else + gun.oldframe = ops.gunframe; + } + + gun.flags = Defines.RF_MINLIGHT | Defines.RF_DEPTHHACK | Defines.RF_WEAPONMODEL; + gun.backlerp = 1.0f - Globals.cl.lerpfrac; + Math3D.VectorCopy(gun.origin, gun.oldorigin); // don't lerp at all + V.AddEntity(gun); + } + + /* + * =============== CL_CalcViewValues + * + * Sets cl.refdef view values =============== + */ + static void CalcViewValues() { + int i; + float lerp, backlerp; + frame_t oldframe; + player_state_t ps, ops; + + // find the previous frame to interpolate from + ps = Globals.cl.frame.playerstate; + + i = (Globals.cl.frame.serverframe - 1) & Defines.UPDATE_MASK; + oldframe = Globals.cl.frames[i]; + + if (oldframe.serverframe != Globals.cl.frame.serverframe - 1 || !oldframe.valid) + oldframe = Globals.cl.frame; // previous frame was dropped or + // involid + ops = oldframe.playerstate; + + // see if the player entity was teleported this frame + if (Math.abs(ops.pmove.origin[0] - ps.pmove.origin[0]) > 256 * 8 + || Math.abs(ops.pmove.origin[1] - ps.pmove.origin[1]) > 256 * 8 + || Math.abs(ops.pmove.origin[2] - ps.pmove.origin[2]) > 256 * 8) + ops = ps; // don't interpolate + + lerp = Globals.cl.lerpfrac; + + // calculate the origin + if ((Globals.cl_predict.value != 0) && 0 == (Globals.cl.frame.playerstate.pmove.pm_flags & pmove_t.PMF_NO_PREDICTION)) { // use + // predicted + // values + int delta; + + backlerp = 1.0f - lerp; + for (i = 0; i < 3; i++) { + Globals.cl.refdef.vieworg[i] = Globals.cl.predicted_origin[i] + ops.viewoffset[i] + Globals.cl.lerpfrac + * (ps.viewoffset[i] - ops.viewoffset[i]) - backlerp * Globals.cl.prediction_error[i]; + } + + // smooth out stair climbing + delta = (int) (Globals.cls.realtime - Globals.cl.predicted_step_time); + if (delta < 100) + Globals.cl.refdef.vieworg[2] -= Globals.cl.predicted_step * (100 - delta) * 0.01; + } else { // just use interpolated values + for (i = 0; i < 3; i++) + Globals.cl.refdef.vieworg[i] = ops.pmove.origin[i] * 0.125f + ops.viewoffset[i] + lerp + * (ps.pmove.origin[i] * 0.125f + ps.viewoffset[i] - (ops.pmove.origin[i] * 0.125f + ops.viewoffset[i])); + } + + // if not running a demo or on a locked frame, add the local angle + // movement + if (Globals.cl.frame.playerstate.pmove.pm_type < Defines.PM_DEAD) { // use + // predicted + // values + for (i = 0; i < 3; i++) + Globals.cl.refdef.viewangles[i] = Globals.cl.predicted_angles[i]; + } else { // just use interpolated values + for (i = 0; i < 3; i++) + Globals.cl.refdef.viewangles[i] = Math3D.LerpAngle(ops.viewangles[i], ps.viewangles[i], lerp); + } + + for (i = 0; i < 3; i++) + Globals.cl.refdef.viewangles[i] += Math3D.LerpAngle(ops.kick_angles[i], ps.kick_angles[i], lerp); + + Math3D.AngleVectors(Globals.cl.refdef.viewangles, Globals.cl.v_forward, Globals.cl.v_right, Globals.cl.v_up); + + // interpolate field of view + Globals.cl.refdef.fov_x = ops.fov + lerp * (ps.fov - ops.fov); + + // don't interpolate blend color + for (i = 0; i < 4; i++) + Globals.cl.refdef.blend[i] = ps.blend[i]; + + // add the weapon + AddViewWeapon(ps, ops); + } + + /* + * =============== CL_AddEntities + * + * Emits all entities, particles, and lights to the refresh =============== + */ + static void AddEntities() { + if (Globals.cls.state != Defines.ca_active) + return; + + if (Globals.cl.time > Globals.cl.frame.servertime) { + if (Globals.cl_showclamp.value != 0) + Com.Printf("high clamp " + (Globals.cl.time - Globals.cl.frame.servertime) + "\n"); + Globals.cl.time = Globals.cl.frame.servertime; + Globals.cl.lerpfrac = 1.0f; + } else if (Globals.cl.time < Globals.cl.frame.servertime - 100) { + if (Globals.cl_showclamp.value != 0) + Com.Printf("low clamp " + (Globals.cl.frame.servertime - 100 - Globals.cl.time) + "\n"); + Globals.cl.time = Globals.cl.frame.servertime - 100; + Globals.cl.lerpfrac = 0; + } else + Globals.cl.lerpfrac = 1.0f - (Globals.cl.frame.servertime - Globals.cl.time) * 0.01f; + + if (Globals.cl_timedemo.value != 0) + Globals.cl.lerpfrac = 1.0f; + + /* + * is ok.. CL_AddPacketEntities (cl.frame); CL_AddTEnts (); + * CL_AddParticles (); CL_AddDLights (); CL_AddLightStyles (); + */ + + CalcViewValues(); + // PMM - moved this here so the heat beam has the right values for the + // vieworg, and can lock the beam to the gun + AddPacketEntities(Globals.cl.frame); + + CL_tent.AddTEnts(); + CL_fx.AddParticles(); + CL_fx.AddDLights(); + CL_fx.AddLightStyles(); + } + + /* + * =============== CL_GetEntitySoundOrigin + * + * Called to get the sound spatialization origin =============== + */ + public static void GetEntitySoundOrigin(int ent, float[] org) { + centity_t old; + + if (ent < 0 || ent >= Defines.MAX_EDICTS) + Com.Error(Defines.ERR_DROP, "CL_GetEntitySoundOrigin: bad ent"); + old = Globals.cl_entities[ent]; + Math3D.VectorCopy(old.lerp_origin, org); + + // FIXME: bmodel issues... + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/client/CL_fx.java b/src/main/java/lwjake2/client/CL_fx.java index c3d6f7d..842c76a 100644 --- a/src/main/java/lwjake2/client/CL_fx.java +++ b/src/main/java/lwjake2/client/CL_fx.java @@ -33,2134 +33,2134 @@ import lwjake2.util.Math3D; */ public class CL_fx { - static class cdlight_t { - int key; // so entities can reuse same entry - - float[] color = { 0, 0, 0 }; - - float[] origin = { 0, 0, 0 }; - - float radius; - - float die; // stop lighting after this time - - float minlight; // don't add when contributing less - - void clear() { - radius = minlight = color[0] = color[1] = color[2] = 0; - } - } - - static cparticle_t[] particles = new cparticle_t[Defines.MAX_PARTICLES]; - static { - for (int i = 0; i < particles.length; i++) - particles[i] = new cparticle_t(); - } - - static int cl_numparticles = Defines.MAX_PARTICLES; - - static final float INSTANT_PARTICLE = -10000.0f; - - static float[][] avelocities = new float[Defines.NUMVERTEXNORMALS][3]; - - static clightstyle_t[] cl_lightstyle = new clightstyle_t[Defines.MAX_LIGHTSTYLES]; - - static int lastofs; - - /* - * ============================================================== - * - * LIGHT STYLE MANAGEMENT - * - * ============================================================== - */ - - static class clightstyle_t { - int length; - - float[] value = new float[3]; - - float[] map = new float[Defines.MAX_QPATH]; - - void clear() { - value[0] = value[1] = value[2] = length = 0; - for (int i = 0; i < map.length; i++) - map[i] = 0.0f; - } - } - - static { - for (int i = 0; i < cl_lightstyle.length; i++) { - cl_lightstyle[i] = new clightstyle_t(); - } - } - - /* - * ============================================================== - * - * DLIGHT MANAGEMENT - * - * ============================================================== - */ - - static cdlight_t[] cl_dlights = new cdlight_t[Defines.MAX_DLIGHTS]; - static { - for (int i = 0; i < cl_dlights.length; i++) - cl_dlights[i] = new cdlight_t(); - } - - /* - * ================ CL_ClearDlights ================ - */ - static void ClearDlights() { - // memset (cl_dlights, 0, sizeof(cl_dlights)); - for (int i = 0; i < cl_dlights.length; i++) { - cl_dlights[i].clear(); - } - } - - /* - * ================ CL_ClearLightStyles ================ - */ - static void ClearLightStyles() { - //memset (cl_lightstyle, 0, sizeof(cl_lightstyle)); - for (int i = 0; i < cl_lightstyle.length; i++) - cl_lightstyle[i].clear(); - lastofs = -1; - } - - /* - * ================ CL_RunLightStyles ================ - */ - static void RunLightStyles() { - clightstyle_t ls; - - int ofs = Globals.cl.time / 100; - if (ofs == lastofs) - return; - lastofs = ofs; - - for (int i = 0; i < cl_lightstyle.length; i++) { - ls = cl_lightstyle[i]; - if (ls.length == 0) { - ls.value[0] = ls.value[1] = ls.value[2] = 1.0f; - continue; - } - if (ls.length == 1) - ls.value[0] = ls.value[1] = ls.value[2] = ls.map[0]; - else - ls.value[0] = ls.value[1] = ls.value[2] = ls.map[ofs % ls.length]; - } - } - - static void SetLightstyle(int i) { - String s; - int j, k; - - s = Globals.cl.configstrings[i + Defines.CS_LIGHTS]; - - j = s.length(); - if (j >= Defines.MAX_QPATH) - Com.Error(Defines.ERR_DROP, "svc_lightstyle length=" + j); - - cl_lightstyle[i].length = j; - - for (k = 0; k < j; k++) - cl_lightstyle[i].map[k] = (float) (s.charAt(k) - 'a') / (float) ('m' - 'a'); - } - - /* - * ================ CL_AddLightStyles ================ - */ - static void AddLightStyles() { - clightstyle_t ls; - - for (int i = 0; i < cl_lightstyle.length; i++) { - ls = cl_lightstyle[i]; - V.AddLightStyle(i, ls.value[0], ls.value[1], ls.value[2]); - } - } - - /* - * =============== CL_AllocDlight - * - * =============== - */ - static cdlight_t AllocDlight(int key) { - int i; - cdlight_t dl; - - // first look for an exact key match - if (key != 0) { - for (i = 0; i < Defines.MAX_DLIGHTS; i++) { - dl = cl_dlights[i]; - if (dl.key == key) { - //memset (dl, 0, sizeof(*dl)); - dl.clear(); - dl.key = key; - return dl; - } - } - } - - // then look for anything else - for (i = 0; i < Defines.MAX_DLIGHTS; i++) { - dl = cl_dlights[i]; - if (dl.die < Globals.cl.time) { - //memset (dl, 0, sizeof(*dl)); - dl.clear(); - dl.key = key; - return dl; - } - } - - //dl = &cl_dlights[0]; - //memset (dl, 0, sizeof(*dl)); - dl = cl_dlights[0]; - dl.clear(); - dl.key = key; - return dl; - } - - - /* - * =============== - * CL_RunDLights - * =============== - */ - static void RunDLights() { - cdlight_t dl; - - for (int i = 0; i < Defines.MAX_DLIGHTS; i++) { - dl = cl_dlights[i]; - if (dl.radius == 0.0f) - continue; - - if (dl.die < Globals.cl.time) { - dl.radius = 0.0f; - return; - } - } - } - - // stack variable - private static final float[] fv = {0, 0, 0}; - private static final float[] rv = {0, 0, 0}; - /* - * ============== - * CL_ParseMuzzleFlash - * ============== - */ - static void ParseMuzzleFlash() { - float volume; - String soundname; - - int i = MSG.ReadShort(Globals.net_message); - if (i < 1 || i >= Defines.MAX_EDICTS) - Com.Error(Defines.ERR_DROP, "CL_ParseMuzzleFlash: bad entity"); - - int weapon = MSG.ReadByte(Globals.net_message); - int silenced = weapon & Defines.MZ_SILENCED; - weapon &= ~Defines.MZ_SILENCED; - - centity_t pl = Globals.cl_entities[i]; - - cdlight_t dl = AllocDlight(i); - Math3D.VectorCopy(pl.current.origin, dl.origin); - Math3D.AngleVectors(pl.current.angles, fv, rv, null); - Math3D.VectorMA(dl.origin, 18, fv, dl.origin); - Math3D.VectorMA(dl.origin, 16, rv, dl.origin); - if (silenced != 0) - dl.radius = 100 + (Globals.rnd.nextInt() & 31); - else - dl.radius = 200 + (Globals.rnd.nextInt() & 31); - dl.minlight = 32; - dl.die = Globals.cl.time; // + 0.1; - - if (silenced != 0) - volume = 0.2f; - else - volume = 1; - - switch (weapon) { - case Defines.MZ_BLASTER: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/blastf1a.wav"), volume, Defines.ATTN_NORM, 0); - break; - case Defines.MZ_BLUEHYPERBLASTER: - dl.color[0] = 0; - dl.color[1] = 0; - dl.color[2] = 1; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/hyprbf1a.wav"), volume, Defines.ATTN_NORM, 0); - break; - case Defines.MZ_HYPERBLASTER: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/hyprbf1a.wav"), volume, Defines.ATTN_NORM, 0); - break; - case Defines.MZ_MACHINEGUN: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - //Com_sprintf(soundname, sizeof(soundname), - // "weapons/machgf%ib.wav", (rand() % 5) + 1); - soundname = "weapons/machgf" + ((Globals.rnd.nextInt(5)) + 1) + "b.wav"; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound(soundname), volume, Defines.ATTN_NORM, 0); - break; - case Defines.MZ_SHOTGUN: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/shotgf1b.wav"), volume, Defines.ATTN_NORM, 0); - S.StartSound(null, i, Defines.CHAN_AUTO, S.RegisterSound("weapons/shotgr1b.wav"), volume, Defines.ATTN_NORM, 0.1f); - break; - case Defines.MZ_SSHOTGUN: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/sshotf1b.wav"), volume, Defines.ATTN_NORM, 0); - break; - case Defines.MZ_CHAINGUN1: - dl.radius = 200 + (Globals.rnd.nextInt() & 31); - dl.color[0] = 1; - dl.color[1] = 0.25f; - dl.color[2] = 0; - //Com_sprintf(soundname, sizeof(soundname), - // "weapons/machgf%ib.wav", (rand() % 5) + 1); - soundname = "weapons/machgf" + ((Globals.rnd.nextInt(5)) + 1) + "b.wav"; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound(soundname), volume, Defines.ATTN_NORM, 0); - break; - case Defines.MZ_CHAINGUN2: - dl.radius = 225 + (Globals.rnd.nextInt() & 31); - dl.color[0] = 1; - dl.color[1] = 0.5f; - dl.color[2] = 0; - dl.die = Globals.cl.time + 0.1f; // long delay - //Com_sprintf(soundname, sizeof(soundname), - // "weapons/machgf%ib.wav", (rand() % 5) + 1); - soundname = "weapons/machgf" + ((Globals.rnd.nextInt(5)) + 1) + "b.wav"; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound(soundname), volume, Defines.ATTN_NORM, 0); - //Com_sprintf(soundname, sizeof(soundname), - // "weapons/machgf%ib.wav", (rand() % 5) + 1); - soundname = "weapons/machgf" + ((Globals.rnd.nextInt(5)) + 1) + "b.wav"; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound(soundname), volume, Defines.ATTN_NORM, 0.05f); - break; - case Defines.MZ_CHAINGUN3: - dl.radius = 250 + (Globals.rnd.nextInt() & 31); - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - dl.die = Globals.cl.time + 0.1f; // long delay - //Com_sprintf(soundname, sizeof(soundname), - // "weapons/machgf%ib.wav", (rand() % 5) + 1); - soundname = "weapons/machgf" + ((Globals.rnd.nextInt(5)) + 1) + "b.wav"; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound(soundname), volume, Defines.ATTN_NORM, 0); - //Com_sprintf(soundname, sizeof(soundname), - // "weapons/machgf%ib.wav", (rand() % 5) + 1); - soundname = "weapons/machgf" + ((Globals.rnd.nextInt(5)) + 1) + "b.wav"; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound(soundname), volume, Defines.ATTN_NORM, 0.033f); - //Com_sprintf(soundname, sizeof(soundname), - // "weapons/machgf%ib.wav", (rand() % 5) + 1); - soundname = "weapons/machgf" + ((Globals.rnd.nextInt(5)) + 1) + "b.wav"; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound(soundname), volume, Defines.ATTN_NORM, 0.066f); - break; - case Defines.MZ_RAILGUN: - dl.color[0] = 0.5f; - dl.color[1] = 0.5f; - dl.color[2] = 1.0f; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/railgf1a.wav"), volume, Defines.ATTN_NORM, 0); - break; - case Defines.MZ_ROCKET: - dl.color[0] = 1; - dl.color[1] = 0.5f; - dl.color[2] = 0.2f; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/rocklf1a.wav"), volume, Defines.ATTN_NORM, 0); - S.StartSound(null, i, Defines.CHAN_AUTO, S.RegisterSound("weapons/rocklr1b.wav"), volume, Defines.ATTN_NORM, 0.1f); - break; - case Defines.MZ_GRENADE: - dl.color[0] = 1; - dl.color[1] = 0.5f; - dl.color[2] = 0; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/grenlf1a.wav"), volume, Defines.ATTN_NORM, 0); - S.StartSound(null, i, Defines.CHAN_AUTO, S.RegisterSound("weapons/grenlr1b.wav"), volume, Defines.ATTN_NORM, 0.1f); - break; - case Defines.MZ_BFG: - dl.color[0] = 0; - dl.color[1] = 1; - dl.color[2] = 0; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/bfg__f1y.wav"), volume, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ_LOGIN: - dl.color[0] = 0; - dl.color[1] = 1; - dl.color[2] = 0; - dl.die = Globals.cl.time + 1.0f; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/grenlf1a.wav"), 1, Defines.ATTN_NORM, 0); - LogoutEffect(pl.current.origin, weapon); - break; - case Defines.MZ_LOGOUT: - dl.color[0] = 1; - dl.color[1] = 0; - dl.color[2] = 0; - dl.die = Globals.cl.time + 1.0f; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/grenlf1a.wav"), 1, Defines.ATTN_NORM, 0); - LogoutEffect(pl.current.origin, weapon); - break; - case Defines.MZ_RESPAWN: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - dl.die = Globals.cl.time + 1.0f; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/grenlf1a.wav"), 1, Defines.ATTN_NORM, 0); - LogoutEffect(pl.current.origin, weapon); - break; - // RAFAEL - case Defines.MZ_PHALANX: - dl.color[0] = 1; - dl.color[1] = 0.5f; - dl.color[2] = 0.5f; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/plasshot.wav"), volume, Defines.ATTN_NORM, 0); - break; - // RAFAEL - case Defines.MZ_IONRIPPER: - dl.color[0] = 1; - dl.color[1] = 0.5f; - dl.color[2] = 0.5f; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/rippfire.wav"), volume, Defines.ATTN_NORM, 0); - break; - - // ====================== - // PGM - case Defines.MZ_ETF_RIFLE: - dl.color[0] = 0.9f; - dl.color[1] = 0.7f; - dl.color[2] = 0; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/nail1.wav"), volume, Defines.ATTN_NORM, 0); - break; - case Defines.MZ_SHOTGUN2: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/shotg2.wav"), volume, Defines.ATTN_NORM, 0); - break; - case Defines.MZ_HEATBEAM: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - dl.die = Globals.cl.time + 100; - // S.StartSound (null, i, CHAN_WEAPON, - // S.RegisterSound("weapons/bfg__l1a.wav"), volume, ATTN_NORM, 0); - break; - case Defines.MZ_BLASTER2: - dl.color[0] = 0; - dl.color[1] = 1; - dl.color[2] = 0; - // FIXME - different sound for blaster2 ?? - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/blastf1a.wav"), volume, Defines.ATTN_NORM, 0); - break; - case Defines.MZ_TRACKER: - // negative flashes handled the same in gl/soft until CL_AddDLights - dl.color[0] = -1; - dl.color[1] = -1; - dl.color[2] = -1; - S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/disint2.wav"), volume, Defines.ATTN_NORM, 0); - break; - case Defines.MZ_NUKE1: - dl.color[0] = 1; - dl.color[1] = 0; - dl.color[2] = 0; - dl.die = Globals.cl.time + 100; - break; - case Defines.MZ_NUKE2: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - dl.die = Globals.cl.time + 100; - break; - case Defines.MZ_NUKE4: - dl.color[0] = 0; - dl.color[1] = 0; - dl.color[2] = 1; - dl.die = Globals.cl.time + 100; - break; - case Defines.MZ_NUKE8: - dl.color[0] = 0; - dl.color[1] = 1; - dl.color[2] = 1; - dl.die = Globals.cl.time + 100; - break; - // PGM - // ====================== - } - } - - // stack variable - private static final float[] origin = {0, 0, 0}; - private static final float[] forward = {0, 0, 0}; - private static final float[] right = {0, 0, 0}; - /* - * ============== CL_ParseMuzzleFlash2 ============== - */ - static void ParseMuzzleFlash2() { - String soundname; - - int ent = MSG.ReadShort(Globals.net_message); - if (ent < 1 || ent >= Defines.MAX_EDICTS) - Com.Error(Defines.ERR_DROP, "CL_ParseMuzzleFlash2: bad entity"); - - int flash_number = MSG.ReadByte(Globals.net_message); - - // locate the origin - Math3D.AngleVectors(Globals.cl_entities[ent].current.angles, forward, right, null); - origin[0] = Globals.cl_entities[ent].current.origin[0] + forward[0] * M_Flash.monster_flash_offset[flash_number][0] + right[0] - * M_Flash.monster_flash_offset[flash_number][1]; - origin[1] = Globals.cl_entities[ent].current.origin[1] + forward[1] * M_Flash.monster_flash_offset[flash_number][0] + right[1] - * M_Flash.monster_flash_offset[flash_number][1]; - origin[2] = Globals.cl_entities[ent].current.origin[2] + forward[2] * M_Flash.monster_flash_offset[flash_number][0] + right[2] - * M_Flash.monster_flash_offset[flash_number][1] + M_Flash.monster_flash_offset[flash_number][2]; - - cdlight_t dl = AllocDlight(ent); - Math3D.VectorCopy(origin, dl.origin); - dl.radius = 200 + (Globals.rnd.nextInt() & 31); - dl.minlight = 32; - dl.die = Globals.cl.time; // + 0.1; - - switch (flash_number) { - case Defines.MZ2_INFANTRY_MACHINEGUN_1: - case Defines.MZ2_INFANTRY_MACHINEGUN_2: - case Defines.MZ2_INFANTRY_MACHINEGUN_3: - case Defines.MZ2_INFANTRY_MACHINEGUN_4: - case Defines.MZ2_INFANTRY_MACHINEGUN_5: - case Defines.MZ2_INFANTRY_MACHINEGUN_6: - case Defines.MZ2_INFANTRY_MACHINEGUN_7: - case Defines.MZ2_INFANTRY_MACHINEGUN_8: - case Defines.MZ2_INFANTRY_MACHINEGUN_9: - case Defines.MZ2_INFANTRY_MACHINEGUN_10: - case Defines.MZ2_INFANTRY_MACHINEGUN_11: - case Defines.MZ2_INFANTRY_MACHINEGUN_12: - case Defines.MZ2_INFANTRY_MACHINEGUN_13: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - ParticleEffect(origin, Globals.vec3_origin, 0, 40); - CL_tent.SmokeAndFlash(origin); - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("infantry/infatck1.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_SOLDIER_MACHINEGUN_1: - case Defines.MZ2_SOLDIER_MACHINEGUN_2: - case Defines.MZ2_SOLDIER_MACHINEGUN_3: - case Defines.MZ2_SOLDIER_MACHINEGUN_4: - case Defines.MZ2_SOLDIER_MACHINEGUN_5: - case Defines.MZ2_SOLDIER_MACHINEGUN_6: - case Defines.MZ2_SOLDIER_MACHINEGUN_7: - case Defines.MZ2_SOLDIER_MACHINEGUN_8: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - ParticleEffect(origin, Globals.vec3_origin, 0, 40); - CL_tent.SmokeAndFlash(origin); - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("soldier/solatck3.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_GUNNER_MACHINEGUN_1: - case Defines.MZ2_GUNNER_MACHINEGUN_2: - case Defines.MZ2_GUNNER_MACHINEGUN_3: - case Defines.MZ2_GUNNER_MACHINEGUN_4: - case Defines.MZ2_GUNNER_MACHINEGUN_5: - case Defines.MZ2_GUNNER_MACHINEGUN_6: - case Defines.MZ2_GUNNER_MACHINEGUN_7: - case Defines.MZ2_GUNNER_MACHINEGUN_8: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - ParticleEffect(origin, Globals.vec3_origin, 0, 40); - CL_tent.SmokeAndFlash(origin); - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("gunner/gunatck2.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_ACTOR_MACHINEGUN_1: - case Defines.MZ2_SUPERTANK_MACHINEGUN_1: - case Defines.MZ2_SUPERTANK_MACHINEGUN_2: - case Defines.MZ2_SUPERTANK_MACHINEGUN_3: - case Defines.MZ2_SUPERTANK_MACHINEGUN_4: - case Defines.MZ2_SUPERTANK_MACHINEGUN_5: - case Defines.MZ2_SUPERTANK_MACHINEGUN_6: - case Defines.MZ2_TURRET_MACHINEGUN: // PGM - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - - ParticleEffect(origin, Globals.vec3_origin, 0, 40); - CL_tent.SmokeAndFlash(origin); - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("infantry/infatck1.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_BOSS2_MACHINEGUN_L1: - case Defines.MZ2_BOSS2_MACHINEGUN_L2: - case Defines.MZ2_BOSS2_MACHINEGUN_L3: - case Defines.MZ2_BOSS2_MACHINEGUN_L4: - case Defines.MZ2_BOSS2_MACHINEGUN_L5: - case Defines.MZ2_CARRIER_MACHINEGUN_L1: // PMM - case Defines.MZ2_CARRIER_MACHINEGUN_L2: // PMM - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - - ParticleEffect(origin, Globals.vec3_origin, 0, 40); - CL_tent.SmokeAndFlash(origin); - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("infantry/infatck1.wav"), 1, Defines.ATTN_NONE, 0); - break; - - case Defines.MZ2_SOLDIER_BLASTER_1: - case Defines.MZ2_SOLDIER_BLASTER_2: - case Defines.MZ2_SOLDIER_BLASTER_3: - case Defines.MZ2_SOLDIER_BLASTER_4: - case Defines.MZ2_SOLDIER_BLASTER_5: - case Defines.MZ2_SOLDIER_BLASTER_6: - case Defines.MZ2_SOLDIER_BLASTER_7: - case Defines.MZ2_SOLDIER_BLASTER_8: - case Defines.MZ2_TURRET_BLASTER: // PGM - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("soldier/solatck2.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_FLYER_BLASTER_1: - case Defines.MZ2_FLYER_BLASTER_2: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("flyer/flyatck3.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_MEDIC_BLASTER_1: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("medic/medatck1.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_HOVER_BLASTER_1: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("hover/hovatck1.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_FLOAT_BLASTER_1: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("floater/fltatck1.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_SOLDIER_SHOTGUN_1: - case Defines.MZ2_SOLDIER_SHOTGUN_2: - case Defines.MZ2_SOLDIER_SHOTGUN_3: - case Defines.MZ2_SOLDIER_SHOTGUN_4: - case Defines.MZ2_SOLDIER_SHOTGUN_5: - case Defines.MZ2_SOLDIER_SHOTGUN_6: - case Defines.MZ2_SOLDIER_SHOTGUN_7: - case Defines.MZ2_SOLDIER_SHOTGUN_8: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - CL_tent.SmokeAndFlash(origin); - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("soldier/solatck1.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_TANK_BLASTER_1: - case Defines.MZ2_TANK_BLASTER_2: - case Defines.MZ2_TANK_BLASTER_3: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("tank/tnkatck3.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_TANK_MACHINEGUN_1: - case Defines.MZ2_TANK_MACHINEGUN_2: - case Defines.MZ2_TANK_MACHINEGUN_3: - case Defines.MZ2_TANK_MACHINEGUN_4: - case Defines.MZ2_TANK_MACHINEGUN_5: - case Defines.MZ2_TANK_MACHINEGUN_6: - case Defines.MZ2_TANK_MACHINEGUN_7: - case Defines.MZ2_TANK_MACHINEGUN_8: - case Defines.MZ2_TANK_MACHINEGUN_9: - case Defines.MZ2_TANK_MACHINEGUN_10: - case Defines.MZ2_TANK_MACHINEGUN_11: - case Defines.MZ2_TANK_MACHINEGUN_12: - case Defines.MZ2_TANK_MACHINEGUN_13: - case Defines.MZ2_TANK_MACHINEGUN_14: - case Defines.MZ2_TANK_MACHINEGUN_15: - case Defines.MZ2_TANK_MACHINEGUN_16: - case Defines.MZ2_TANK_MACHINEGUN_17: - case Defines.MZ2_TANK_MACHINEGUN_18: - case Defines.MZ2_TANK_MACHINEGUN_19: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - ParticleEffect(origin, Globals.vec3_origin, 0, 40); - CL_tent.SmokeAndFlash(origin); - //Com_sprintf(soundname, sizeof(soundname), "tank/tnkatk2%c.wav", - // 'a' + rand() % 5); - soundname = "tank/tnkatk2" + (char) ('a' + Globals.rnd.nextInt(5)) + ".wav"; - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound(soundname), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_CHICK_ROCKET_1: - case Defines.MZ2_TURRET_ROCKET: // PGM - dl.color[0] = 1; - dl.color[1] = 0.5f; - dl.color[2] = 0.2f; - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("chick/chkatck2.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_TANK_ROCKET_1: - case Defines.MZ2_TANK_ROCKET_2: - case Defines.MZ2_TANK_ROCKET_3: - dl.color[0] = 1; - dl.color[1] = 0.5f; - dl.color[2] = 0.2f; - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("tank/tnkatck1.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_SUPERTANK_ROCKET_1: - case Defines.MZ2_SUPERTANK_ROCKET_2: - case Defines.MZ2_SUPERTANK_ROCKET_3: - case Defines.MZ2_BOSS2_ROCKET_1: - case Defines.MZ2_BOSS2_ROCKET_2: - case Defines.MZ2_BOSS2_ROCKET_3: - case Defines.MZ2_BOSS2_ROCKET_4: - case Defines.MZ2_CARRIER_ROCKET_1: - // case MZ2_CARRIER_ROCKET_2: - // case MZ2_CARRIER_ROCKET_3: - // case MZ2_CARRIER_ROCKET_4: - dl.color[0] = 1; - dl.color[1] = 0.5f; - dl.color[2] = 0.2f; - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("tank/rocket.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_GUNNER_GRENADE_1: - case Defines.MZ2_GUNNER_GRENADE_2: - case Defines.MZ2_GUNNER_GRENADE_3: - case Defines.MZ2_GUNNER_GRENADE_4: - dl.color[0] = 1; - dl.color[1] = 0.5f; - dl.color[2] = 0; - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("gunner/gunatck3.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_GLADIATOR_RAILGUN_1: - // PMM - case Defines.MZ2_CARRIER_RAILGUN: - case Defines.MZ2_WIDOW_RAIL: - // pmm - dl.color[0] = 0.5f; - dl.color[1] = 0.5f; - dl.color[2] = 1.0f; - break; - - // --- Xian's shit starts --- - case Defines.MZ2_MAKRON_BFG: - dl.color[0] = 0.5f; - dl.color[1] = 1; - dl.color[2] = 0.5f; - //S.StartSound (null, ent, CHAN_WEAPON, - // S.RegisterSound("makron/bfg_fire.wav"), 1, ATTN_NORM, 0); - break; - - case Defines.MZ2_MAKRON_BLASTER_1: - case Defines.MZ2_MAKRON_BLASTER_2: - case Defines.MZ2_MAKRON_BLASTER_3: - case Defines.MZ2_MAKRON_BLASTER_4: - case Defines.MZ2_MAKRON_BLASTER_5: - case Defines.MZ2_MAKRON_BLASTER_6: - case Defines.MZ2_MAKRON_BLASTER_7: - case Defines.MZ2_MAKRON_BLASTER_8: - case Defines.MZ2_MAKRON_BLASTER_9: - case Defines.MZ2_MAKRON_BLASTER_10: - case Defines.MZ2_MAKRON_BLASTER_11: - case Defines.MZ2_MAKRON_BLASTER_12: - case Defines.MZ2_MAKRON_BLASTER_13: - case Defines.MZ2_MAKRON_BLASTER_14: - case Defines.MZ2_MAKRON_BLASTER_15: - case Defines.MZ2_MAKRON_BLASTER_16: - case Defines.MZ2_MAKRON_BLASTER_17: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("makron/blaster.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_JORG_MACHINEGUN_L1: - case Defines.MZ2_JORG_MACHINEGUN_L2: - case Defines.MZ2_JORG_MACHINEGUN_L3: - case Defines.MZ2_JORG_MACHINEGUN_L4: - case Defines.MZ2_JORG_MACHINEGUN_L5: - case Defines.MZ2_JORG_MACHINEGUN_L6: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - ParticleEffect(origin, Globals.vec3_origin, 0, 40); - CL_tent.SmokeAndFlash(origin); - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("boss3/xfire.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_JORG_MACHINEGUN_R1: - case Defines.MZ2_JORG_MACHINEGUN_R2: - case Defines.MZ2_JORG_MACHINEGUN_R3: - case Defines.MZ2_JORG_MACHINEGUN_R4: - case Defines.MZ2_JORG_MACHINEGUN_R5: - case Defines.MZ2_JORG_MACHINEGUN_R6: - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - ParticleEffect(origin, Globals.vec3_origin, 0, 40); - CL_tent.SmokeAndFlash(origin); - break; - - case Defines.MZ2_JORG_BFG_1: - dl.color[0] = 0.5f; - dl.color[1] = 1; - dl.color[2] = 0.5f; - break; - - case Defines.MZ2_BOSS2_MACHINEGUN_R1: - case Defines.MZ2_BOSS2_MACHINEGUN_R2: - case Defines.MZ2_BOSS2_MACHINEGUN_R3: - case Defines.MZ2_BOSS2_MACHINEGUN_R4: - case Defines.MZ2_BOSS2_MACHINEGUN_R5: - case Defines.MZ2_CARRIER_MACHINEGUN_R1: // PMM - case Defines.MZ2_CARRIER_MACHINEGUN_R2: // PMM - - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - - ParticleEffect(origin, Globals.vec3_origin, 0, 40); - CL_tent.SmokeAndFlash(origin); - break; - - // ====== - // ROGUE - case Defines.MZ2_STALKER_BLASTER: - case Defines.MZ2_DAEDALUS_BLASTER: - case Defines.MZ2_MEDIC_BLASTER_2: - case Defines.MZ2_WIDOW_BLASTER: - case Defines.MZ2_WIDOW_BLASTER_SWEEP1: - case Defines.MZ2_WIDOW_BLASTER_SWEEP2: - case Defines.MZ2_WIDOW_BLASTER_SWEEP3: - case Defines.MZ2_WIDOW_BLASTER_SWEEP4: - case Defines.MZ2_WIDOW_BLASTER_SWEEP5: - case Defines.MZ2_WIDOW_BLASTER_SWEEP6: - case Defines.MZ2_WIDOW_BLASTER_SWEEP7: - case Defines.MZ2_WIDOW_BLASTER_SWEEP8: - case Defines.MZ2_WIDOW_BLASTER_SWEEP9: - case Defines.MZ2_WIDOW_BLASTER_100: - case Defines.MZ2_WIDOW_BLASTER_90: - case Defines.MZ2_WIDOW_BLASTER_80: - case Defines.MZ2_WIDOW_BLASTER_70: - case Defines.MZ2_WIDOW_BLASTER_60: - case Defines.MZ2_WIDOW_BLASTER_50: - case Defines.MZ2_WIDOW_BLASTER_40: - case Defines.MZ2_WIDOW_BLASTER_30: - case Defines.MZ2_WIDOW_BLASTER_20: - case Defines.MZ2_WIDOW_BLASTER_10: - case Defines.MZ2_WIDOW_BLASTER_0: - case Defines.MZ2_WIDOW_BLASTER_10L: - case Defines.MZ2_WIDOW_BLASTER_20L: - case Defines.MZ2_WIDOW_BLASTER_30L: - case Defines.MZ2_WIDOW_BLASTER_40L: - case Defines.MZ2_WIDOW_BLASTER_50L: - case Defines.MZ2_WIDOW_BLASTER_60L: - case Defines.MZ2_WIDOW_BLASTER_70L: - case Defines.MZ2_WIDOW_RUN_1: - case Defines.MZ2_WIDOW_RUN_2: - case Defines.MZ2_WIDOW_RUN_3: - case Defines.MZ2_WIDOW_RUN_4: - case Defines.MZ2_WIDOW_RUN_5: - case Defines.MZ2_WIDOW_RUN_6: - case Defines.MZ2_WIDOW_RUN_7: - case Defines.MZ2_WIDOW_RUN_8: - dl.color[0] = 0; - dl.color[1] = 1; - dl.color[2] = 0; - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("tank/tnkatck3.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_WIDOW_DISRUPTOR: - dl.color[0] = -1; - dl.color[1] = -1; - dl.color[2] = -1; - S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("weapons/disint2.wav"), 1, Defines.ATTN_NORM, 0); - break; - - case Defines.MZ2_WIDOW_PLASMABEAM: - case Defines.MZ2_WIDOW2_BEAMER_1: - case Defines.MZ2_WIDOW2_BEAMER_2: - case Defines.MZ2_WIDOW2_BEAMER_3: - case Defines.MZ2_WIDOW2_BEAMER_4: - case Defines.MZ2_WIDOW2_BEAMER_5: - case Defines.MZ2_WIDOW2_BEAM_SWEEP_1: - case Defines.MZ2_WIDOW2_BEAM_SWEEP_2: - case Defines.MZ2_WIDOW2_BEAM_SWEEP_3: - case Defines.MZ2_WIDOW2_BEAM_SWEEP_4: - case Defines.MZ2_WIDOW2_BEAM_SWEEP_5: - case Defines.MZ2_WIDOW2_BEAM_SWEEP_6: - case Defines.MZ2_WIDOW2_BEAM_SWEEP_7: - case Defines.MZ2_WIDOW2_BEAM_SWEEP_8: - case Defines.MZ2_WIDOW2_BEAM_SWEEP_9: - case Defines.MZ2_WIDOW2_BEAM_SWEEP_10: - case Defines.MZ2_WIDOW2_BEAM_SWEEP_11: - dl.radius = 300 + (Globals.rnd.nextInt() & 100); - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 0; - dl.die = Globals.cl.time + 200; - break; - // ROGUE - // ====== - - // --- Xian's shit ends --- - - } - } - - /* - * =============== CL_AddDLights - * - * =============== - */ - static void AddDLights() { - cdlight_t dl; - - // ===== - // PGM - if (Globals.vidref_val == Defines.VIDREF_GL) { - for (int i = 0; i < Defines.MAX_DLIGHTS; i++) { - dl = cl_dlights[i]; - if (dl.radius == 0.0f) - continue; - V.AddLight(dl.origin, dl.radius, dl.color[0], dl.color[1], dl.color[2]); - } - } else { - for (int i = 0; i < Defines.MAX_DLIGHTS; i++) { - dl = cl_dlights[i]; - if (dl.radius == 0.0f) - continue; - - // negative light in software. only black allowed - if ((dl.color[0] < 0) || (dl.color[1] < 0) || (dl.color[2] < 0)) { - dl.radius = -(dl.radius); - dl.color[0] = 1; - dl.color[1] = 1; - dl.color[2] = 1; - } - V.AddLight(dl.origin, dl.radius, dl.color[0], dl.color[1], dl.color[2]); - } - } - // PGM - // ===== - } - - /* - * =============== CL_ClearParticles =============== - */ - static void ClearParticles() { - free_particles = particles[0]; - active_particles = null; - - for (int i = 0; i < particles.length - 1; i++) - particles[i].next = particles[i + 1]; - particles[particles.length - 1].next = null; - } - - /* - * =============== CL_ParticleEffect - * - * Wall impact puffs =============== - */ - static void ParticleEffect(float[] org, float[] dir, int color, int count) { - int j; - cparticle_t p; - float d; - - for (int i = 0; i < count; i++) { - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - p.color = color + (Lib.rand() & 7); - - d = Lib.rand() & 31; - for (j = 0; j < 3; j++) { - p.org[j] = org[j] + ((Lib.rand() & 7) - 4) + d * dir[j]; - p.vel[j] = Lib.crand() * 20; - } - - p.accel[0] = p.accel[1] = 0; - p.accel[2] = -PARTICLE_GRAVITY; - p.alpha = 1.0f; - - p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f); - } - } - - /* - * =============== CL_ParticleEffect2 =============== - */ - static void ParticleEffect2(float[] org, float[] dir, int color, int count) { - int j; - cparticle_t p; - float d; - - for (int i = 0; i < count; i++) { - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - p.color = color; - - d = Lib.rand() & 7; - for (j = 0; j < 3; j++) { - p.org[j] = org[j] + ((Lib.rand() & 7) - 4) + d * dir[j]; - p.vel[j] = Lib.crand() * 20; - } - - p.accel[0] = p.accel[1] = 0; - p.accel[2] = -PARTICLE_GRAVITY; - p.alpha = 1.0f; - - p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f); - } - } - - // RAFAEL - /* - * =============== CL_ParticleEffect3 =============== - */ - static void ParticleEffect3(float[] org, float[] dir, int color, int count) { - int j; - cparticle_t p; - float d; - - for (int i = 0; i < count; i++) { - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - p.color = color; - - d = Lib.rand() & 7; - for (j = 0; j < 3; j++) { - p.org[j] = org[j] + ((Lib.rand() & 7) - 4) + d * dir[j]; - p.vel[j] = Lib.crand() * 20; - } - - p.accel[0] = p.accel[1] = 0; - p.accel[2] = PARTICLE_GRAVITY; - p.alpha = 1.0f; - - p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f); - } - } - - /* - * =============== CL_TeleporterParticles =============== - */ - static void TeleporterParticles(entity_state_t ent) { - int j; - cparticle_t p; - - for (int i = 0; i < 8; i++) { - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - p.color = 0xdb; - - for (j = 0; j < 2; j++) { - p.org[j] = ent.origin[j] - 16 + (Lib.rand() & 31); - p.vel[j] = Lib.crand() * 14; - } - - p.org[2] = ent.origin[2] - 8 + (Lib.rand() & 7); - p.vel[2] = 80 + (Lib.rand() & 7); - - p.accel[0] = p.accel[1] = 0; - p.accel[2] = -PARTICLE_GRAVITY; - p.alpha = 1.0f; - - p.alphavel = -0.5f; - } - } - - /* - * =============== CL_LogoutEffect - * - * =============== - */ - static void LogoutEffect(float[] org, int type) { - int j; - cparticle_t p; - - for (int i = 0; i < 500; i++) { - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - - if (type == Defines.MZ_LOGIN) - p.color = 0xd0 + (Lib.rand() & 7); // green - else if (type == Defines.MZ_LOGOUT) - p.color = 0x40 + (Lib.rand() & 7); // red - else - p.color = 0xe0 + (Lib.rand() & 7); // yellow - - p.org[0] = org[0] - 16 + Globals.rnd.nextFloat() * 32; - p.org[1] = org[1] - 16 + Globals.rnd.nextFloat() * 32; - p.org[2] = org[2] - 24 + Globals.rnd.nextFloat() * 56; - - for (j = 0; j < 3; j++) - p.vel[j] = Lib.crand() * 20; - - p.accel[0] = p.accel[1] = 0; - p.accel[2] = -PARTICLE_GRAVITY; - p.alpha = 1.0f; - - p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.3f); - } - } - - /* - * =============== CL_ItemRespawnParticles - * - * =============== - */ - static void ItemRespawnParticles(float[] org) { - int j; - cparticle_t p; - - for (int i = 0; i < 64; i++) { - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - - p.color = 0xd4 + (Lib.rand() & 3); // green - - p.org[0] = org[0] + Lib.crand() * 8; - p.org[1] = org[1] + Lib.crand() * 8; - p.org[2] = org[2] + Lib.crand() * 8; - - for (j = 0; j < 3; j++) - p.vel[j] = Lib.crand() * 8; - - p.accel[0] = p.accel[1] = 0; - p.accel[2] = -PARTICLE_GRAVITY * 0.2f; - p.alpha = 1.0f; - - p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.3f); - } - } - - /* - * =============== CL_ExplosionParticles =============== - */ - static void ExplosionParticles(float[] org) { - int j; - cparticle_t p; - - for (int i = 0; i < 256; i++) { - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - p.color = 0xe0 + (Lib.rand() & 7); - - for (j = 0; j < 3; j++) { - p.org[j] = org[j] + ((Lib.rand() % 32) - 16); - p.vel[j] = (Lib.rand() % 384) - 192; - } - - p.accel[0] = p.accel[1] = 0.0f; - p.accel[2] = -PARTICLE_GRAVITY; - p.alpha = 1.0f; - - p.alphavel = -0.8f / (0.5f + Globals.rnd.nextFloat() * 0.3f); - } - } - - static void BigTeleportParticles(float[] org) { - cparticle_t p; - float angle, dist; - - for (int i = 0; i < 4096; i++) { - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - - p.color = colortable[Lib.rand() & 3]; - - angle = (float) (Math.PI * 2 * (Lib.rand() & 1023) / 1023.0); - dist = Lib.rand() & 31; - p.org[0] = (float) (org[0] + Math.cos(angle) * dist); - p.vel[0] = (float) (Math.cos(angle) * (70 + (Lib.rand() & 63))); - p.accel[0] = (float) (-Math.cos(angle) * 100); - - p.org[1] = (float) (org[1] + Math.sin(angle) * dist); - p.vel[1] = (float) (Math.sin(angle) * (70 + (Lib.rand() & 63))); - p.accel[1] = (float) (-Math.sin(angle) * 100); - - p.org[2] = org[2] + 8 + (Lib.rand() % 90); - p.vel[2] = -100 + (Lib.rand() & 31); - p.accel[2] = PARTICLE_GRAVITY * 4; - p.alpha = 1.0f; - - p.alphavel = -0.3f / (0.5f + Globals.rnd.nextFloat() * 0.3f); - } - } - - /* - * =============== CL_BlasterParticles - * - * Wall impact puffs =============== - */ - static void BlasterParticles(float[] org, float[] dir) { - int j; - cparticle_t p; - float d; - - int count = 40; - for (int i = 0; i < count; i++) { - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - p.color = 0xe0 + (Lib.rand() & 7); - - d = Lib.rand() & 15; - for (j = 0; j < 3; j++) { - p.org[j] = org[j] + ((Lib.rand() & 7) - 4) + d * dir[j]; - p.vel[j] = dir[j] * 30 + Lib.crand() * 40; - } - - p.accel[0] = p.accel[1] = 0; - p.accel[2] = -PARTICLE_GRAVITY; - p.alpha = 1.0f; - - p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f); - } - } - - // stack variable - private static final float[] move = {0, 0, 0}; - private static final float[] vec = {0, 0, 0}; - /* - * =============== CL_BlasterTrail - * - * =============== - */ - static void BlasterTrail(float[] start, float[] end) { - float len; - int j; - cparticle_t p; - int dec; - - Math3D.VectorCopy(start, move); - Math3D.VectorSubtract(end, start, vec); - len = Math3D.VectorNormalize(vec); - - dec = 5; - Math3D.VectorScale(vec, 5, vec); - - // FIXME: this is a really silly way to have a loop - while (len > 0) { - len -= dec; - - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - Math3D.VectorClear(p.accel); - - p.time = Globals.cl.time; - - p.alpha = 1.0f; - p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f); - p.color = 0xe0; - for (j = 0; j < 3; j++) { - p.org[j] = move[j] + Lib.crand(); - p.vel[j] = Lib.crand() * 5; - p.accel[j] = 0; - } - - Math3D.VectorAdd(move, vec, move); - } - } - - // stack variable - // move, vec - /* - * =============== - * CL_FlagTrail - * =============== - */ - static void FlagTrail(float[] start, float[] end, float color) { - float len; - int j; - cparticle_t p; - int dec; - - Math3D.VectorCopy(start, move); - Math3D.VectorSubtract(end, start, vec); - len = Math3D.VectorNormalize(vec); - - dec = 5; - Math3D.VectorScale(vec, 5, vec); - - while (len > 0) { - len -= dec; - - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - Math3D.VectorClear(p.accel); - - p.time = Globals.cl.time; - - p.alpha = 1.0f; - p.alphavel = -1.0f / (0.8f + Globals.rnd.nextFloat() * 0.2f); - p.color = color; - for (j = 0; j < 3; j++) { - p.org[j] = move[j] + Lib.crand() * 16; - p.vel[j] = Lib.crand() * 5; - p.accel[j] = 0; - } - - Math3D.VectorAdd(move, vec, move); - } - } - - // stack variable - // move, vec - /* - * =============== CL_DiminishingTrail - * - * =============== - */ - static void DiminishingTrail(float[] start, float[] end, centity_t old, int flags) { - cparticle_t p; - float orgscale; - float velscale; - - Math3D.VectorCopy(start, move); - Math3D.VectorSubtract(end, start, vec); - float len = Math3D.VectorNormalize(vec); - - float dec = 0.5f; - Math3D.VectorScale(vec, dec, vec); - - if (old.trailcount > 900) { - orgscale = 4; - velscale = 15; - } else if (old.trailcount > 800) { - orgscale = 2; - velscale = 10; - } else { - orgscale = 1; - velscale = 5; - } - - while (len > 0) { - len -= dec; - - if (free_particles == null) - return; - - // drop less particles as it flies - if ((Lib.rand() & 1023) < old.trailcount) { - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - Math3D.VectorClear(p.accel); - - p.time = Globals.cl.time; - - if ((flags & Defines.EF_GIB) != 0) { - p.alpha = 1.0f; - p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.4f); - p.color = 0xe8 + (Lib.rand() & 7); - for (int j = 0; j < 3; j++) { - p.org[j] = move[j] + Lib.crand() * orgscale; - p.vel[j] = Lib.crand() * velscale; - p.accel[j] = 0; - } - p.vel[2] -= PARTICLE_GRAVITY; - } else if ((flags & Defines.EF_GREENGIB) != 0) { - p.alpha = 1.0f; - p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.4f); - p.color = 0xdb + (Lib.rand() & 7); - for (int j = 0; j < 3; j++) { - p.org[j] = move[j] + Lib.crand() * orgscale; - p.vel[j] = Lib.crand() * velscale; - p.accel[j] = 0; - } - p.vel[2] -= PARTICLE_GRAVITY; - } else { - p.alpha = 1.0f; - p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f); - p.color = 4 + (Lib.rand() & 7); - for (int j = 0; j < 3; j++) { - p.org[j] = move[j] + Lib.crand() * orgscale; - p.vel[j] = Lib.crand() * velscale; - } - p.accel[2] = 20; - } - } - - old.trailcount -= 5; - if (old.trailcount < 100) - old.trailcount = 100; - Math3D.VectorAdd(move, vec, move); - } - } - - // stack variable - // move, vec - /* - * =============== CL_RocketTrail - * - * =============== - */ - static void RocketTrail(float[] start, float[] end, centity_t old) { - float len; - int j; - cparticle_t p; - float dec; - - // smoke - DiminishingTrail(start, end, old, Defines.EF_ROCKET); - - // fire - Math3D.VectorCopy(start, move); - Math3D.VectorSubtract(end, start, vec); - len = Math3D.VectorNormalize(vec); - - dec = 1; - Math3D.VectorScale(vec, dec, vec); - - while (len > 0) { - len -= dec; - - if (free_particles == null) - return; - - if ((Lib.rand() & 7) == 0) { - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - Math3D.VectorClear(p.accel); - p.time = Globals.cl.time; - - p.alpha = 1.0f; - p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f); - p.color = 0xdc + (Lib.rand() & 3); - for (j = 0; j < 3; j++) { - p.org[j] = move[j] + Lib.crand() * 5; - p.vel[j] = Lib.crand() * 20; - } - p.accel[2] = -PARTICLE_GRAVITY; - } - Math3D.VectorAdd(move, vec, move); - } - } - - // stack variable - // move, vec - /* - * =============== CL_RailTrail - * - * =============== - */ - static void RailTrail(float[] start, float[] end) { - float len; - int j; - cparticle_t p; - float dec; - float[] right = new float[3]; - float[] up = new float[3]; - int i; - float d, c, s; - float[] dir = new float[3]; - byte clr = 0x74; - - Math3D.VectorCopy(start, move); - Math3D.VectorSubtract(end, start, vec); - len = Math3D.VectorNormalize(vec); - - Math3D.MakeNormalVectors(vec, right, up); - - for (i = 0; i < len; i++) { - if (free_particles == null) - return; - - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - Math3D.VectorClear(p.accel); - - d = i * 0.1f; - c = (float) Math.cos(d); - s = (float) Math.sin(d); - - Math3D.VectorScale(right, c, dir); - Math3D.VectorMA(dir, s, up, dir); - - p.alpha = 1.0f; - p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f); - p.color = clr + (Lib.rand() & 7); - for (j = 0; j < 3; j++) { - p.org[j] = move[j] + dir[j] * 3; - p.vel[j] = dir[j] * 6; - } - - Math3D.VectorAdd(move, vec, move); - } - - dec = 0.75f; - Math3D.VectorScale(vec, dec, vec); - Math3D.VectorCopy(start, move); - - while (len > 0) { - len -= dec; - - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - Math3D.VectorClear(p.accel); - - p.alpha = 1.0f; - p.alphavel = -1.0f / (0.6f + Globals.rnd.nextFloat() * 0.2f); - p.color = 0x0 + Lib.rand() & 15; - - for (j = 0; j < 3; j++) { - p.org[j] = move[j] + Lib.crand() * 3; - p.vel[j] = Lib.crand() * 3; - p.accel[j] = 0; - } - - Math3D.VectorAdd(move, vec, move); - } - } - - // stack variable - // move, vec - /* - * =============== CL_IonripperTrail =============== - */ - static void IonripperTrail(float[] start, float[] ent) { - float len; - int j; - cparticle_t p; - int dec; - int left = 0; - - Math3D.VectorCopy(start, move); - Math3D.VectorSubtract(ent, start, vec); - len = Math3D.VectorNormalize(vec); - - dec = 5; - Math3D.VectorScale(vec, 5, vec); - - while (len > 0) { - len -= dec; - - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - Math3D.VectorClear(p.accel); - - p.time = Globals.cl.time; - p.alpha = 0.5f; - p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f); - p.color = 0xe4 + (Lib.rand() & 3); - - for (j = 0; j < 3; j++) { - p.org[j] = move[j]; - p.accel[j] = 0; - } - if (left != 0) { - left = 0; - p.vel[0] = 10; - } else { - left = 1; - p.vel[0] = -10; - } - - p.vel[1] = 0; - p.vel[2] = 0; - - Math3D.VectorAdd(move, vec, move); - } - } - - // stack variable - // move, vec - /* - * =============== CL_BubbleTrail - * - * =============== - */ - static void BubbleTrail(float[] start, float[] end) { - float len; - int i, j; - cparticle_t p; - float dec; - - Math3D.VectorCopy(start, move); - Math3D.VectorSubtract(end, start, vec); - len = Math3D.VectorNormalize(vec); - - dec = 32; - Math3D.VectorScale(vec, dec, vec); - - for (i = 0; i < len; i += dec) { - if (free_particles == null) - return; - - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - Math3D.VectorClear(p.accel); - p.time = Globals.cl.time; - - p.alpha = 1.0f; - p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f); - p.color = 4 + (Lib.rand() & 7); - for (j = 0; j < 3; j++) { - p.org[j] = move[j] + Lib.crand() * 2; - p.vel[j] = Lib.crand() * 5; - } - p.vel[2] += 6; - - Math3D.VectorAdd(move, vec, move); - } - } - - // stack variable - // forward - /* - * =============== CL_FlyParticles =============== - */ - static void FlyParticles(float[] origin, int count) { - int i; - cparticle_t p; - float angle; - float sp, sy, cp, cy; - float dist = 64; - float ltime; - - if (count > Defines.NUMVERTEXNORMALS) - count = Defines.NUMVERTEXNORMALS; - - if (avelocities[0][0] == 0.0f) { - for (i = 0; i < Defines.NUMVERTEXNORMALS; i++) { - avelocities[i][0] = (Lib.rand() & 255) * 0.01f; - avelocities[i][1] = (Lib.rand() & 255) * 0.01f; - avelocities[i][2] = (Lib.rand() & 255) * 0.01f; - } - } - - ltime = Globals.cl.time / 1000.0f; - for (i = 0; i < count; i += 2) { - angle = ltime * avelocities[i][0]; - sy = (float) Math.sin(angle); - cy = (float) Math.cos(angle); - angle = ltime * avelocities[i][1]; - sp = (float) Math.sin(angle); - cp = (float) Math.cos(angle); - angle = ltime * avelocities[i][2]; - - forward[0] = cp * cy; - forward[1] = cp * sy; - forward[2] = -sp; - - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - - dist = (float) Math.sin(ltime + i) * 64; - p.org[0] = origin[0] + Globals.bytedirs[i][0] * dist + forward[0] * BEAMLENGTH; - p.org[1] = origin[1] + Globals.bytedirs[i][1] * dist + forward[1] * BEAMLENGTH; - p.org[2] = origin[2] + Globals.bytedirs[i][2] * dist + forward[2] * BEAMLENGTH; - - Math3D.VectorClear(p.vel); - Math3D.VectorClear(p.accel); - - p.color = 0; - //p.colorvel = 0; - - p.alpha = 1; - p.alphavel = -100; - } - } - - static void FlyEffect(centity_t ent, float[] origin) { - int n; - int count; - int starttime; - - if (ent.fly_stoptime < Globals.cl.time) { - starttime = Globals.cl.time; - ent.fly_stoptime = Globals.cl.time + 60000; - } else { - starttime = ent.fly_stoptime - 60000; - } - - n = Globals.cl.time - starttime; - if (n < 20000) - count = (int) ((n * 162) / 20000.0); - else { - n = ent.fly_stoptime - Globals.cl.time; - if (n < 20000) - count = (int) ((n * 162) / 20000.0); - else - count = 162; - } - - FlyParticles(origin, count); - } - - // stack variable - private static final float[] v = {0, 0, 0}; - // forward - /* - * =============== CL_BfgParticles =============== - */ - //#define BEAMLENGTH 16 - static void BfgParticles(entity_t ent) { - int i; - cparticle_t p; - float angle; - float sp, sy, cp, cy; - float dist = 64; - float ltime; - - if (avelocities[0][0] == 0.0f) { - for (i = 0; i < Defines.NUMVERTEXNORMALS; i++) { - avelocities[i][0] = (Lib.rand() & 255) * 0.01f; - avelocities[i][1] = (Lib.rand() & 255) * 0.01f; - avelocities[i][2] = (Lib.rand() & 255) * 0.01f; - } - } - - ltime = Globals.cl.time / 1000.0f; - for (i = 0; i < Defines.NUMVERTEXNORMALS; i++) { - angle = ltime * avelocities[i][0]; - sy = (float) Math.sin(angle); - cy = (float) Math.cos(angle); - angle = ltime * avelocities[i][1]; - sp = (float) Math.sin(angle); - cp = (float) Math.cos(angle); - angle = ltime * avelocities[i][2]; - - forward[0] = cp * cy; - forward[1] = cp * sy; - forward[2] = -sp; - - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - - dist = (float) (Math.sin(ltime + i) * 64); - p.org[0] = ent.origin[0] + Globals.bytedirs[i][0] * dist + forward[0] * BEAMLENGTH; - p.org[1] = ent.origin[1] + Globals.bytedirs[i][1] * dist + forward[1] * BEAMLENGTH; - p.org[2] = ent.origin[2] + Globals.bytedirs[i][2] * dist + forward[2] * BEAMLENGTH; - - Math3D.VectorClear(p.vel); - Math3D.VectorClear(p.accel); - - Math3D.VectorSubtract(p.org, ent.origin, v); - dist = Math3D.VectorLength(v) / 90.0f; - p.color = (float) Math.floor(0xd0 + dist * 7); - //p.colorvel = 0; - - p.alpha = 1.0f - dist; - p.alphavel = -100; - } - } - - // stack variable - // move, vec - private static final float[] start = {0, 0, 0}; - private static final float[] end = {0, 0, 0}; - /* - * =============== CL_TrapParticles =============== - */ - // RAFAEL - static void TrapParticles(entity_t ent) { - float len; - int j; - cparticle_t p; - int dec; - - ent.origin[2] -= 14; - Math3D.VectorCopy(ent.origin, start); - Math3D.VectorCopy(ent.origin, end); - end[2] += 64; - - Math3D.VectorCopy(start, move); - Math3D.VectorSubtract(end, start, vec); - len = Math3D.VectorNormalize(vec); - - dec = 5; - Math3D.VectorScale(vec, 5, vec); - - // FIXME: this is a really silly way to have a loop - while (len > 0) { - len -= dec; - - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - Math3D.VectorClear(p.accel); - - p.time = Globals.cl.time; - - p.alpha = 1.0f; - p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f); - p.color = 0xe0; - for (j = 0; j < 3; j++) { - p.org[j] = move[j] + Lib.crand(); - p.vel[j] = Lib.crand() * 15; - p.accel[j] = 0; - } - p.accel[2] = PARTICLE_GRAVITY; - - Math3D.VectorAdd(move, vec, move); - } - - int i, k; - //cparticle_t p; - float vel; - float[] dir = new float[3]; - float[] org = new float[3]; - - ent.origin[2] += 14; - Math3D.VectorCopy(ent.origin, org); - - for (i = -2; i <= 2; i += 4) - for (j = -2; j <= 2; j += 4) - for (k = -2; k <= 4; k += 4) { - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - p.color = 0xe0 + (Lib.rand() & 3); - - p.alpha = 1.0f; - p.alphavel = -1.0f / (0.3f + (Lib.rand() & 7) * 0.02f); - - p.org[0] = org[0] + i + ((Lib.rand() & 23) * Lib.crand()); - p.org[1] = org[1] + j + ((Lib.rand() & 23) * Lib.crand()); - p.org[2] = org[2] + k + ((Lib.rand() & 23) * Lib.crand()); - - dir[0] = j * 8; - dir[1] = i * 8; - dir[2] = k * 8; - - Math3D.VectorNormalize(dir); - vel = 50 + Lib.rand() & 63; - Math3D.VectorScale(dir, vel, p.vel); - - p.accel[0] = p.accel[1] = 0; - p.accel[2] = -PARTICLE_GRAVITY; - } - - } - - /* - * =============== CL_BFGExplosionParticles =============== - */ - // FIXME combined with CL_ExplosionParticles - static void BFGExplosionParticles(float[] org) { - int j; - cparticle_t p; - - for (int i = 0; i < 256; i++) { - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - p.color = 0xd0 + (Lib.rand() & 7); - - for (j = 0; j < 3; j++) { - p.org[j] = org[j] + ((Lib.rand() % 32) - 16); - p.vel[j] = (Lib.rand() % 384) - 192; - } - - p.accel[0] = p.accel[1] = 0; - p.accel[2] = -PARTICLE_GRAVITY; - p.alpha = 1.0f; - - p.alphavel = -0.8f / (0.5f + Globals.rnd.nextFloat() * 0.3f); - } - } - - // stack variable - private static final float[] dir = {0, 0, 0}; - /* - * =============== CL_TeleportParticles - * - * =============== - */ - static void TeleportParticles(float[] org) { - cparticle_t p; - float vel; - - for (int i = -16; i <= 16; i += 4) - for (int j = -16; j <= 16; j += 4) - for (int k = -16; k <= 32; k += 4) { - if (free_particles == null) - return; - p = free_particles; - free_particles = p.next; - p.next = active_particles; - active_particles = p; - - p.time = Globals.cl.time; - p.color = 7 + (Lib.rand() & 7); - - p.alpha = 1.0f; - p.alphavel = -1.0f / (0.3f + (Lib.rand() & 7) * 0.02f); - - p.org[0] = org[0] + i + (Lib.rand() & 3); - p.org[1] = org[1] + j + (Lib.rand() & 3); - p.org[2] = org[2] + k + (Lib.rand() & 3); - - dir[0] = j * 8; - dir[1] = i * 8; - dir[2] = k * 8; - - Math3D.VectorNormalize(dir); - vel = 50 + (Lib.rand() & 63); - Math3D.VectorScale(dir, vel, p.vel); - - p.accel[0] = p.accel[1] = 0; - p.accel[2] = -PARTICLE_GRAVITY; - } - } - - // stack variable - private static final float[] org = {0, 0, 0}; - /* - * =============== CL_AddParticles =============== - */ - static void AddParticles() { - cparticle_t p, next; - float alpha; - float time = 0.0f; - float time2; - int color; - cparticle_t active, tail; - - active = null; - tail = null; - - for (p = active_particles; p != null; p = next) { - next = p.next; - - // PMM - added INSTANT_PARTICLE handling for heat beam - if (p.alphavel != INSTANT_PARTICLE) { - time = (Globals.cl.time - p.time) * 0.001f; - alpha = p.alpha + time * p.alphavel; - if (alpha <= 0) { // faded out - p.next = free_particles; - free_particles = p; - continue; - } - } else { - alpha = p.alpha; - } - - p.next = null; - if (tail == null) - active = tail = p; - else { - tail.next = p; - tail = p; - } - - if (alpha > 1.0) - alpha = 1; - color = (int) p.color; - - time2 = time * time; - - org[0] = p.org[0] + p.vel[0] * time + p.accel[0] * time2; - org[1] = p.org[1] + p.vel[1] * time + p.accel[1] * time2; - org[2] = p.org[2] + p.vel[2] * time + p.accel[2] * time2; - - V.AddParticle(org, color, alpha); - // PMM - if (p.alphavel == INSTANT_PARTICLE) { - p.alphavel = 0.0f; - p.alpha = 0.0f; - } - } - - active_particles = active; - } - - /* - * ============== CL_EntityEvent - * - * An entity has just been parsed that has an event value - * - * the female events are there for backwards compatability ============== - */ - static void EntityEvent(entity_state_t ent) { - switch (ent.event) { - case Defines.EV_ITEM_RESPAWN: - S.StartSound(null, ent.number, Defines.CHAN_WEAPON, S.RegisterSound("items/respawn1.wav"), 1, Defines.ATTN_IDLE, 0); - ItemRespawnParticles(ent.origin); - break; - case Defines.EV_PLAYER_TELEPORT: - S.StartSound(null, ent.number, Defines.CHAN_WEAPON, S.RegisterSound("misc/tele1.wav"), 1, Defines.ATTN_IDLE, 0); - TeleportParticles(ent.origin); - break; - case Defines.EV_FOOTSTEP: - if (Globals.cl_footsteps.value != 0.0f) - S.StartSound(null, ent.number, Defines.CHAN_BODY, CL_tent.cl_sfx_footsteps[Lib.rand() & 3], 1, Defines.ATTN_NORM, 0); - break; - case Defines.EV_FALLSHORT: - S.StartSound(null, ent.number, Defines.CHAN_AUTO, S.RegisterSound("player/land1.wav"), 1, Defines.ATTN_NORM, 0); - break; - case Defines.EV_FALL: - S.StartSound(null, ent.number, Defines.CHAN_AUTO, S.RegisterSound("*fall2.wav"), 1, Defines.ATTN_NORM, 0); - break; - case Defines.EV_FALLFAR: - S.StartSound(null, ent.number, Defines.CHAN_AUTO, S.RegisterSound("*fall1.wav"), 1, Defines.ATTN_NORM, 0); - break; - } - } - - /* - * ============== CL_ClearEffects - * - * ============== - */ - static void ClearEffects() { - ClearParticles(); - ClearDlights(); - ClearLightStyles(); - } - - /* - * ============================================================== - * - * PARTICLE MANAGEMENT - * - * ============================================================== - */ - - static final int PARTICLE_GRAVITY = 40; - - static cparticle_t active_particles, free_particles; - - /* - * =============== CL_BigTeleportParticles =============== - */ - private static int[] colortable = { 2 * 8, 13 * 8, 21 * 8, 18 * 8 }; - - private static final int BEAMLENGTH = 16; + static class cdlight_t { + int key; // so entities can reuse same entry + + float[] color = { 0, 0, 0 }; + + float[] origin = { 0, 0, 0 }; + + float radius; + + float die; // stop lighting after this time + + float minlight; // don't add when contributing less + + void clear() { + radius = minlight = color[0] = color[1] = color[2] = 0; + } + } + + static cparticle_t[] particles = new cparticle_t[Defines.MAX_PARTICLES]; + static { + for (int i = 0; i < particles.length; i++) + particles[i] = new cparticle_t(); + } + + static int cl_numparticles = Defines.MAX_PARTICLES; + + static final float INSTANT_PARTICLE = -10000.0f; + + static float[][] avelocities = new float[Defines.NUMVERTEXNORMALS][3]; + + static clightstyle_t[] cl_lightstyle = new clightstyle_t[Defines.MAX_LIGHTSTYLES]; + + static int lastofs; + + /* + * ============================================================== + * + * LIGHT STYLE MANAGEMENT + * + * ============================================================== + */ + + static class clightstyle_t { + int length; + + float[] value = new float[3]; + + float[] map = new float[Defines.MAX_QPATH]; + + void clear() { + value[0] = value[1] = value[2] = length = 0; + for (int i = 0; i < map.length; i++) + map[i] = 0.0f; + } + } + + static { + for (int i = 0; i < cl_lightstyle.length; i++) { + cl_lightstyle[i] = new clightstyle_t(); + } + } + + /* + * ============================================================== + * + * DLIGHT MANAGEMENT + * + * ============================================================== + */ + + static cdlight_t[] cl_dlights = new cdlight_t[Defines.MAX_DLIGHTS]; + static { + for (int i = 0; i < cl_dlights.length; i++) + cl_dlights[i] = new cdlight_t(); + } + + /* + * ================ CL_ClearDlights ================ + */ + static void ClearDlights() { + // memset (cl_dlights, 0, sizeof(cl_dlights)); + for (int i = 0; i < cl_dlights.length; i++) { + cl_dlights[i].clear(); + } + } + + /* + * ================ CL_ClearLightStyles ================ + */ + static void ClearLightStyles() { + //memset (cl_lightstyle, 0, sizeof(cl_lightstyle)); + for (int i = 0; i < cl_lightstyle.length; i++) + cl_lightstyle[i].clear(); + lastofs = -1; + } + + /* + * ================ CL_RunLightStyles ================ + */ + static void RunLightStyles() { + clightstyle_t ls; + + int ofs = Globals.cl.time / 100; + if (ofs == lastofs) + return; + lastofs = ofs; + + for (int i = 0; i < cl_lightstyle.length; i++) { + ls = cl_lightstyle[i]; + if (ls.length == 0) { + ls.value[0] = ls.value[1] = ls.value[2] = 1.0f; + continue; + } + if (ls.length == 1) + ls.value[0] = ls.value[1] = ls.value[2] = ls.map[0]; + else + ls.value[0] = ls.value[1] = ls.value[2] = ls.map[ofs % ls.length]; + } + } + + static void SetLightstyle(int i) { + String s; + int j, k; + + s = Globals.cl.configstrings[i + Defines.CS_LIGHTS]; + + j = s.length(); + if (j >= Defines.MAX_QPATH) + Com.Error(Defines.ERR_DROP, "svc_lightstyle length=" + j); + + cl_lightstyle[i].length = j; + + for (k = 0; k < j; k++) + cl_lightstyle[i].map[k] = (float) (s.charAt(k) - 'a') / (float) ('m' - 'a'); + } + + /* + * ================ CL_AddLightStyles ================ + */ + static void AddLightStyles() { + clightstyle_t ls; + + for (int i = 0; i < cl_lightstyle.length; i++) { + ls = cl_lightstyle[i]; + V.AddLightStyle(i, ls.value[0], ls.value[1], ls.value[2]); + } + } + + /* + * =============== CL_AllocDlight + * + * =============== + */ + static cdlight_t AllocDlight(int key) { + int i; + cdlight_t dl; + + // first look for an exact key match + if (key != 0) { + for (i = 0; i < Defines.MAX_DLIGHTS; i++) { + dl = cl_dlights[i]; + if (dl.key == key) { + //memset (dl, 0, sizeof(*dl)); + dl.clear(); + dl.key = key; + return dl; + } + } + } + + // then look for anything else + for (i = 0; i < Defines.MAX_DLIGHTS; i++) { + dl = cl_dlights[i]; + if (dl.die < Globals.cl.time) { + //memset (dl, 0, sizeof(*dl)); + dl.clear(); + dl.key = key; + return dl; + } + } + + //dl = &cl_dlights[0]; + //memset (dl, 0, sizeof(*dl)); + dl = cl_dlights[0]; + dl.clear(); + dl.key = key; + return dl; + } + + + /* + * =============== + * CL_RunDLights + * =============== + */ + static void RunDLights() { + cdlight_t dl; + + for (int i = 0; i < Defines.MAX_DLIGHTS; i++) { + dl = cl_dlights[i]; + if (dl.radius == 0.0f) + continue; + + if (dl.die < Globals.cl.time) { + dl.radius = 0.0f; + return; + } + } + } + + // stack variable + private static final float[] fv = {0, 0, 0}; + private static final float[] rv = {0, 0, 0}; + /* + * ============== + * CL_ParseMuzzleFlash + * ============== + */ + static void ParseMuzzleFlash() { + float volume; + String soundname; + + int i = MSG.ReadShort(Globals.net_message); + if (i < 1 || i >= Defines.MAX_EDICTS) + Com.Error(Defines.ERR_DROP, "CL_ParseMuzzleFlash: bad entity"); + + int weapon = MSG.ReadByte(Globals.net_message); + int silenced = weapon & Defines.MZ_SILENCED; + weapon &= ~Defines.MZ_SILENCED; + + centity_t pl = Globals.cl_entities[i]; + + cdlight_t dl = AllocDlight(i); + Math3D.VectorCopy(pl.current.origin, dl.origin); + Math3D.AngleVectors(pl.current.angles, fv, rv, null); + Math3D.VectorMA(dl.origin, 18, fv, dl.origin); + Math3D.VectorMA(dl.origin, 16, rv, dl.origin); + if (silenced != 0) + dl.radius = 100 + (Globals.rnd.nextInt() & 31); + else + dl.radius = 200 + (Globals.rnd.nextInt() & 31); + dl.minlight = 32; + dl.die = Globals.cl.time; // + 0.1; + + if (silenced != 0) + volume = 0.2f; + else + volume = 1; + + switch (weapon) { + case Defines.MZ_BLASTER: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/blastf1a.wav"), volume, Defines.ATTN_NORM, 0); + break; + case Defines.MZ_BLUEHYPERBLASTER: + dl.color[0] = 0; + dl.color[1] = 0; + dl.color[2] = 1; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/hyprbf1a.wav"), volume, Defines.ATTN_NORM, 0); + break; + case Defines.MZ_HYPERBLASTER: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/hyprbf1a.wav"), volume, Defines.ATTN_NORM, 0); + break; + case Defines.MZ_MACHINEGUN: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + //Com_sprintf(soundname, sizeof(soundname), + // "weapons/machgf%ib.wav", (rand() % 5) + 1); + soundname = "weapons/machgf" + ((Globals.rnd.nextInt(5)) + 1) + "b.wav"; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound(soundname), volume, Defines.ATTN_NORM, 0); + break; + case Defines.MZ_SHOTGUN: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/shotgf1b.wav"), volume, Defines.ATTN_NORM, 0); + S.StartSound(null, i, Defines.CHAN_AUTO, S.RegisterSound("weapons/shotgr1b.wav"), volume, Defines.ATTN_NORM, 0.1f); + break; + case Defines.MZ_SSHOTGUN: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/sshotf1b.wav"), volume, Defines.ATTN_NORM, 0); + break; + case Defines.MZ_CHAINGUN1: + dl.radius = 200 + (Globals.rnd.nextInt() & 31); + dl.color[0] = 1; + dl.color[1] = 0.25f; + dl.color[2] = 0; + //Com_sprintf(soundname, sizeof(soundname), + // "weapons/machgf%ib.wav", (rand() % 5) + 1); + soundname = "weapons/machgf" + ((Globals.rnd.nextInt(5)) + 1) + "b.wav"; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound(soundname), volume, Defines.ATTN_NORM, 0); + break; + case Defines.MZ_CHAINGUN2: + dl.radius = 225 + (Globals.rnd.nextInt() & 31); + dl.color[0] = 1; + dl.color[1] = 0.5f; + dl.color[2] = 0; + dl.die = Globals.cl.time + 0.1f; // long delay + //Com_sprintf(soundname, sizeof(soundname), + // "weapons/machgf%ib.wav", (rand() % 5) + 1); + soundname = "weapons/machgf" + ((Globals.rnd.nextInt(5)) + 1) + "b.wav"; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound(soundname), volume, Defines.ATTN_NORM, 0); + //Com_sprintf(soundname, sizeof(soundname), + // "weapons/machgf%ib.wav", (rand() % 5) + 1); + soundname = "weapons/machgf" + ((Globals.rnd.nextInt(5)) + 1) + "b.wav"; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound(soundname), volume, Defines.ATTN_NORM, 0.05f); + break; + case Defines.MZ_CHAINGUN3: + dl.radius = 250 + (Globals.rnd.nextInt() & 31); + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + dl.die = Globals.cl.time + 0.1f; // long delay + //Com_sprintf(soundname, sizeof(soundname), + // "weapons/machgf%ib.wav", (rand() % 5) + 1); + soundname = "weapons/machgf" + ((Globals.rnd.nextInt(5)) + 1) + "b.wav"; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound(soundname), volume, Defines.ATTN_NORM, 0); + //Com_sprintf(soundname, sizeof(soundname), + // "weapons/machgf%ib.wav", (rand() % 5) + 1); + soundname = "weapons/machgf" + ((Globals.rnd.nextInt(5)) + 1) + "b.wav"; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound(soundname), volume, Defines.ATTN_NORM, 0.033f); + //Com_sprintf(soundname, sizeof(soundname), + // "weapons/machgf%ib.wav", (rand() % 5) + 1); + soundname = "weapons/machgf" + ((Globals.rnd.nextInt(5)) + 1) + "b.wav"; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound(soundname), volume, Defines.ATTN_NORM, 0.066f); + break; + case Defines.MZ_RAILGUN: + dl.color[0] = 0.5f; + dl.color[1] = 0.5f; + dl.color[2] = 1.0f; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/railgf1a.wav"), volume, Defines.ATTN_NORM, 0); + break; + case Defines.MZ_ROCKET: + dl.color[0] = 1; + dl.color[1] = 0.5f; + dl.color[2] = 0.2f; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/rocklf1a.wav"), volume, Defines.ATTN_NORM, 0); + S.StartSound(null, i, Defines.CHAN_AUTO, S.RegisterSound("weapons/rocklr1b.wav"), volume, Defines.ATTN_NORM, 0.1f); + break; + case Defines.MZ_GRENADE: + dl.color[0] = 1; + dl.color[1] = 0.5f; + dl.color[2] = 0; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/grenlf1a.wav"), volume, Defines.ATTN_NORM, 0); + S.StartSound(null, i, Defines.CHAN_AUTO, S.RegisterSound("weapons/grenlr1b.wav"), volume, Defines.ATTN_NORM, 0.1f); + break; + case Defines.MZ_BFG: + dl.color[0] = 0; + dl.color[1] = 1; + dl.color[2] = 0; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/bfg__f1y.wav"), volume, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ_LOGIN: + dl.color[0] = 0; + dl.color[1] = 1; + dl.color[2] = 0; + dl.die = Globals.cl.time + 1.0f; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/grenlf1a.wav"), 1, Defines.ATTN_NORM, 0); + LogoutEffect(pl.current.origin, weapon); + break; + case Defines.MZ_LOGOUT: + dl.color[0] = 1; + dl.color[1] = 0; + dl.color[2] = 0; + dl.die = Globals.cl.time + 1.0f; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/grenlf1a.wav"), 1, Defines.ATTN_NORM, 0); + LogoutEffect(pl.current.origin, weapon); + break; + case Defines.MZ_RESPAWN: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + dl.die = Globals.cl.time + 1.0f; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/grenlf1a.wav"), 1, Defines.ATTN_NORM, 0); + LogoutEffect(pl.current.origin, weapon); + break; + // RAFAEL + case Defines.MZ_PHALANX: + dl.color[0] = 1; + dl.color[1] = 0.5f; + dl.color[2] = 0.5f; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/plasshot.wav"), volume, Defines.ATTN_NORM, 0); + break; + // RAFAEL + case Defines.MZ_IONRIPPER: + dl.color[0] = 1; + dl.color[1] = 0.5f; + dl.color[2] = 0.5f; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/rippfire.wav"), volume, Defines.ATTN_NORM, 0); + break; + + // ====================== + // PGM + case Defines.MZ_ETF_RIFLE: + dl.color[0] = 0.9f; + dl.color[1] = 0.7f; + dl.color[2] = 0; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/nail1.wav"), volume, Defines.ATTN_NORM, 0); + break; + case Defines.MZ_SHOTGUN2: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/shotg2.wav"), volume, Defines.ATTN_NORM, 0); + break; + case Defines.MZ_HEATBEAM: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + dl.die = Globals.cl.time + 100; + // S.StartSound (null, i, CHAN_WEAPON, + // S.RegisterSound("weapons/bfg__l1a.wav"), volume, ATTN_NORM, 0); + break; + case Defines.MZ_BLASTER2: + dl.color[0] = 0; + dl.color[1] = 1; + dl.color[2] = 0; + // FIXME - different sound for blaster2 ?? + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/blastf1a.wav"), volume, Defines.ATTN_NORM, 0); + break; + case Defines.MZ_TRACKER: + // negative flashes handled the same in gl/soft until CL_AddDLights + dl.color[0] = -1; + dl.color[1] = -1; + dl.color[2] = -1; + S.StartSound(null, i, Defines.CHAN_WEAPON, S.RegisterSound("weapons/disint2.wav"), volume, Defines.ATTN_NORM, 0); + break; + case Defines.MZ_NUKE1: + dl.color[0] = 1; + dl.color[1] = 0; + dl.color[2] = 0; + dl.die = Globals.cl.time + 100; + break; + case Defines.MZ_NUKE2: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + dl.die = Globals.cl.time + 100; + break; + case Defines.MZ_NUKE4: + dl.color[0] = 0; + dl.color[1] = 0; + dl.color[2] = 1; + dl.die = Globals.cl.time + 100; + break; + case Defines.MZ_NUKE8: + dl.color[0] = 0; + dl.color[1] = 1; + dl.color[2] = 1; + dl.die = Globals.cl.time + 100; + break; + // PGM + // ====================== + } + } + + // stack variable + private static final float[] origin = {0, 0, 0}; + private static final float[] forward = {0, 0, 0}; + private static final float[] right = {0, 0, 0}; + /* + * ============== CL_ParseMuzzleFlash2 ============== + */ + static void ParseMuzzleFlash2() { + String soundname; + + int ent = MSG.ReadShort(Globals.net_message); + if (ent < 1 || ent >= Defines.MAX_EDICTS) + Com.Error(Defines.ERR_DROP, "CL_ParseMuzzleFlash2: bad entity"); + + int flash_number = MSG.ReadByte(Globals.net_message); + + // locate the origin + Math3D.AngleVectors(Globals.cl_entities[ent].current.angles, forward, right, null); + origin[0] = Globals.cl_entities[ent].current.origin[0] + forward[0] * M_Flash.monster_flash_offset[flash_number][0] + right[0] + * M_Flash.monster_flash_offset[flash_number][1]; + origin[1] = Globals.cl_entities[ent].current.origin[1] + forward[1] * M_Flash.monster_flash_offset[flash_number][0] + right[1] + * M_Flash.monster_flash_offset[flash_number][1]; + origin[2] = Globals.cl_entities[ent].current.origin[2] + forward[2] * M_Flash.monster_flash_offset[flash_number][0] + right[2] + * M_Flash.monster_flash_offset[flash_number][1] + M_Flash.monster_flash_offset[flash_number][2]; + + cdlight_t dl = AllocDlight(ent); + Math3D.VectorCopy(origin, dl.origin); + dl.radius = 200 + (Globals.rnd.nextInt() & 31); + dl.minlight = 32; + dl.die = Globals.cl.time; // + 0.1; + + switch (flash_number) { + case Defines.MZ2_INFANTRY_MACHINEGUN_1: + case Defines.MZ2_INFANTRY_MACHINEGUN_2: + case Defines.MZ2_INFANTRY_MACHINEGUN_3: + case Defines.MZ2_INFANTRY_MACHINEGUN_4: + case Defines.MZ2_INFANTRY_MACHINEGUN_5: + case Defines.MZ2_INFANTRY_MACHINEGUN_6: + case Defines.MZ2_INFANTRY_MACHINEGUN_7: + case Defines.MZ2_INFANTRY_MACHINEGUN_8: + case Defines.MZ2_INFANTRY_MACHINEGUN_9: + case Defines.MZ2_INFANTRY_MACHINEGUN_10: + case Defines.MZ2_INFANTRY_MACHINEGUN_11: + case Defines.MZ2_INFANTRY_MACHINEGUN_12: + case Defines.MZ2_INFANTRY_MACHINEGUN_13: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + ParticleEffect(origin, Globals.vec3_origin, 0, 40); + CL_tent.SmokeAndFlash(origin); + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("infantry/infatck1.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_SOLDIER_MACHINEGUN_1: + case Defines.MZ2_SOLDIER_MACHINEGUN_2: + case Defines.MZ2_SOLDIER_MACHINEGUN_3: + case Defines.MZ2_SOLDIER_MACHINEGUN_4: + case Defines.MZ2_SOLDIER_MACHINEGUN_5: + case Defines.MZ2_SOLDIER_MACHINEGUN_6: + case Defines.MZ2_SOLDIER_MACHINEGUN_7: + case Defines.MZ2_SOLDIER_MACHINEGUN_8: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + ParticleEffect(origin, Globals.vec3_origin, 0, 40); + CL_tent.SmokeAndFlash(origin); + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("soldier/solatck3.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_GUNNER_MACHINEGUN_1: + case Defines.MZ2_GUNNER_MACHINEGUN_2: + case Defines.MZ2_GUNNER_MACHINEGUN_3: + case Defines.MZ2_GUNNER_MACHINEGUN_4: + case Defines.MZ2_GUNNER_MACHINEGUN_5: + case Defines.MZ2_GUNNER_MACHINEGUN_6: + case Defines.MZ2_GUNNER_MACHINEGUN_7: + case Defines.MZ2_GUNNER_MACHINEGUN_8: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + ParticleEffect(origin, Globals.vec3_origin, 0, 40); + CL_tent.SmokeAndFlash(origin); + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("gunner/gunatck2.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_ACTOR_MACHINEGUN_1: + case Defines.MZ2_SUPERTANK_MACHINEGUN_1: + case Defines.MZ2_SUPERTANK_MACHINEGUN_2: + case Defines.MZ2_SUPERTANK_MACHINEGUN_3: + case Defines.MZ2_SUPERTANK_MACHINEGUN_4: + case Defines.MZ2_SUPERTANK_MACHINEGUN_5: + case Defines.MZ2_SUPERTANK_MACHINEGUN_6: + case Defines.MZ2_TURRET_MACHINEGUN: // PGM + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + + ParticleEffect(origin, Globals.vec3_origin, 0, 40); + CL_tent.SmokeAndFlash(origin); + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("infantry/infatck1.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_BOSS2_MACHINEGUN_L1: + case Defines.MZ2_BOSS2_MACHINEGUN_L2: + case Defines.MZ2_BOSS2_MACHINEGUN_L3: + case Defines.MZ2_BOSS2_MACHINEGUN_L4: + case Defines.MZ2_BOSS2_MACHINEGUN_L5: + case Defines.MZ2_CARRIER_MACHINEGUN_L1: // PMM + case Defines.MZ2_CARRIER_MACHINEGUN_L2: // PMM + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + + ParticleEffect(origin, Globals.vec3_origin, 0, 40); + CL_tent.SmokeAndFlash(origin); + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("infantry/infatck1.wav"), 1, Defines.ATTN_NONE, 0); + break; + + case Defines.MZ2_SOLDIER_BLASTER_1: + case Defines.MZ2_SOLDIER_BLASTER_2: + case Defines.MZ2_SOLDIER_BLASTER_3: + case Defines.MZ2_SOLDIER_BLASTER_4: + case Defines.MZ2_SOLDIER_BLASTER_5: + case Defines.MZ2_SOLDIER_BLASTER_6: + case Defines.MZ2_SOLDIER_BLASTER_7: + case Defines.MZ2_SOLDIER_BLASTER_8: + case Defines.MZ2_TURRET_BLASTER: // PGM + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("soldier/solatck2.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_FLYER_BLASTER_1: + case Defines.MZ2_FLYER_BLASTER_2: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("flyer/flyatck3.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_MEDIC_BLASTER_1: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("medic/medatck1.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_HOVER_BLASTER_1: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("hover/hovatck1.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_FLOAT_BLASTER_1: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("floater/fltatck1.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_SOLDIER_SHOTGUN_1: + case Defines.MZ2_SOLDIER_SHOTGUN_2: + case Defines.MZ2_SOLDIER_SHOTGUN_3: + case Defines.MZ2_SOLDIER_SHOTGUN_4: + case Defines.MZ2_SOLDIER_SHOTGUN_5: + case Defines.MZ2_SOLDIER_SHOTGUN_6: + case Defines.MZ2_SOLDIER_SHOTGUN_7: + case Defines.MZ2_SOLDIER_SHOTGUN_8: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + CL_tent.SmokeAndFlash(origin); + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("soldier/solatck1.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_TANK_BLASTER_1: + case Defines.MZ2_TANK_BLASTER_2: + case Defines.MZ2_TANK_BLASTER_3: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("tank/tnkatck3.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_TANK_MACHINEGUN_1: + case Defines.MZ2_TANK_MACHINEGUN_2: + case Defines.MZ2_TANK_MACHINEGUN_3: + case Defines.MZ2_TANK_MACHINEGUN_4: + case Defines.MZ2_TANK_MACHINEGUN_5: + case Defines.MZ2_TANK_MACHINEGUN_6: + case Defines.MZ2_TANK_MACHINEGUN_7: + case Defines.MZ2_TANK_MACHINEGUN_8: + case Defines.MZ2_TANK_MACHINEGUN_9: + case Defines.MZ2_TANK_MACHINEGUN_10: + case Defines.MZ2_TANK_MACHINEGUN_11: + case Defines.MZ2_TANK_MACHINEGUN_12: + case Defines.MZ2_TANK_MACHINEGUN_13: + case Defines.MZ2_TANK_MACHINEGUN_14: + case Defines.MZ2_TANK_MACHINEGUN_15: + case Defines.MZ2_TANK_MACHINEGUN_16: + case Defines.MZ2_TANK_MACHINEGUN_17: + case Defines.MZ2_TANK_MACHINEGUN_18: + case Defines.MZ2_TANK_MACHINEGUN_19: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + ParticleEffect(origin, Globals.vec3_origin, 0, 40); + CL_tent.SmokeAndFlash(origin); + //Com_sprintf(soundname, sizeof(soundname), "tank/tnkatk2%c.wav", + // 'a' + rand() % 5); + soundname = "tank/tnkatk2" + (char) ('a' + Globals.rnd.nextInt(5)) + ".wav"; + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound(soundname), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_CHICK_ROCKET_1: + case Defines.MZ2_TURRET_ROCKET: // PGM + dl.color[0] = 1; + dl.color[1] = 0.5f; + dl.color[2] = 0.2f; + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("chick/chkatck2.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_TANK_ROCKET_1: + case Defines.MZ2_TANK_ROCKET_2: + case Defines.MZ2_TANK_ROCKET_3: + dl.color[0] = 1; + dl.color[1] = 0.5f; + dl.color[2] = 0.2f; + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("tank/tnkatck1.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_SUPERTANK_ROCKET_1: + case Defines.MZ2_SUPERTANK_ROCKET_2: + case Defines.MZ2_SUPERTANK_ROCKET_3: + case Defines.MZ2_BOSS2_ROCKET_1: + case Defines.MZ2_BOSS2_ROCKET_2: + case Defines.MZ2_BOSS2_ROCKET_3: + case Defines.MZ2_BOSS2_ROCKET_4: + case Defines.MZ2_CARRIER_ROCKET_1: + // case MZ2_CARRIER_ROCKET_2: + // case MZ2_CARRIER_ROCKET_3: + // case MZ2_CARRIER_ROCKET_4: + dl.color[0] = 1; + dl.color[1] = 0.5f; + dl.color[2] = 0.2f; + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("tank/rocket.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_GUNNER_GRENADE_1: + case Defines.MZ2_GUNNER_GRENADE_2: + case Defines.MZ2_GUNNER_GRENADE_3: + case Defines.MZ2_GUNNER_GRENADE_4: + dl.color[0] = 1; + dl.color[1] = 0.5f; + dl.color[2] = 0; + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("gunner/gunatck3.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_GLADIATOR_RAILGUN_1: + // PMM + case Defines.MZ2_CARRIER_RAILGUN: + case Defines.MZ2_WIDOW_RAIL: + // pmm + dl.color[0] = 0.5f; + dl.color[1] = 0.5f; + dl.color[2] = 1.0f; + break; + + // --- Xian's shit starts --- + case Defines.MZ2_MAKRON_BFG: + dl.color[0] = 0.5f; + dl.color[1] = 1; + dl.color[2] = 0.5f; + //S.StartSound (null, ent, CHAN_WEAPON, + // S.RegisterSound("makron/bfg_fire.wav"), 1, ATTN_NORM, 0); + break; + + case Defines.MZ2_MAKRON_BLASTER_1: + case Defines.MZ2_MAKRON_BLASTER_2: + case Defines.MZ2_MAKRON_BLASTER_3: + case Defines.MZ2_MAKRON_BLASTER_4: + case Defines.MZ2_MAKRON_BLASTER_5: + case Defines.MZ2_MAKRON_BLASTER_6: + case Defines.MZ2_MAKRON_BLASTER_7: + case Defines.MZ2_MAKRON_BLASTER_8: + case Defines.MZ2_MAKRON_BLASTER_9: + case Defines.MZ2_MAKRON_BLASTER_10: + case Defines.MZ2_MAKRON_BLASTER_11: + case Defines.MZ2_MAKRON_BLASTER_12: + case Defines.MZ2_MAKRON_BLASTER_13: + case Defines.MZ2_MAKRON_BLASTER_14: + case Defines.MZ2_MAKRON_BLASTER_15: + case Defines.MZ2_MAKRON_BLASTER_16: + case Defines.MZ2_MAKRON_BLASTER_17: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("makron/blaster.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_JORG_MACHINEGUN_L1: + case Defines.MZ2_JORG_MACHINEGUN_L2: + case Defines.MZ2_JORG_MACHINEGUN_L3: + case Defines.MZ2_JORG_MACHINEGUN_L4: + case Defines.MZ2_JORG_MACHINEGUN_L5: + case Defines.MZ2_JORG_MACHINEGUN_L6: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + ParticleEffect(origin, Globals.vec3_origin, 0, 40); + CL_tent.SmokeAndFlash(origin); + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("boss3/xfire.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_JORG_MACHINEGUN_R1: + case Defines.MZ2_JORG_MACHINEGUN_R2: + case Defines.MZ2_JORG_MACHINEGUN_R3: + case Defines.MZ2_JORG_MACHINEGUN_R4: + case Defines.MZ2_JORG_MACHINEGUN_R5: + case Defines.MZ2_JORG_MACHINEGUN_R6: + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + ParticleEffect(origin, Globals.vec3_origin, 0, 40); + CL_tent.SmokeAndFlash(origin); + break; + + case Defines.MZ2_JORG_BFG_1: + dl.color[0] = 0.5f; + dl.color[1] = 1; + dl.color[2] = 0.5f; + break; + + case Defines.MZ2_BOSS2_MACHINEGUN_R1: + case Defines.MZ2_BOSS2_MACHINEGUN_R2: + case Defines.MZ2_BOSS2_MACHINEGUN_R3: + case Defines.MZ2_BOSS2_MACHINEGUN_R4: + case Defines.MZ2_BOSS2_MACHINEGUN_R5: + case Defines.MZ2_CARRIER_MACHINEGUN_R1: // PMM + case Defines.MZ2_CARRIER_MACHINEGUN_R2: // PMM + + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + + ParticleEffect(origin, Globals.vec3_origin, 0, 40); + CL_tent.SmokeAndFlash(origin); + break; + + // ====== + // ROGUE + case Defines.MZ2_STALKER_BLASTER: + case Defines.MZ2_DAEDALUS_BLASTER: + case Defines.MZ2_MEDIC_BLASTER_2: + case Defines.MZ2_WIDOW_BLASTER: + case Defines.MZ2_WIDOW_BLASTER_SWEEP1: + case Defines.MZ2_WIDOW_BLASTER_SWEEP2: + case Defines.MZ2_WIDOW_BLASTER_SWEEP3: + case Defines.MZ2_WIDOW_BLASTER_SWEEP4: + case Defines.MZ2_WIDOW_BLASTER_SWEEP5: + case Defines.MZ2_WIDOW_BLASTER_SWEEP6: + case Defines.MZ2_WIDOW_BLASTER_SWEEP7: + case Defines.MZ2_WIDOW_BLASTER_SWEEP8: + case Defines.MZ2_WIDOW_BLASTER_SWEEP9: + case Defines.MZ2_WIDOW_BLASTER_100: + case Defines.MZ2_WIDOW_BLASTER_90: + case Defines.MZ2_WIDOW_BLASTER_80: + case Defines.MZ2_WIDOW_BLASTER_70: + case Defines.MZ2_WIDOW_BLASTER_60: + case Defines.MZ2_WIDOW_BLASTER_50: + case Defines.MZ2_WIDOW_BLASTER_40: + case Defines.MZ2_WIDOW_BLASTER_30: + case Defines.MZ2_WIDOW_BLASTER_20: + case Defines.MZ2_WIDOW_BLASTER_10: + case Defines.MZ2_WIDOW_BLASTER_0: + case Defines.MZ2_WIDOW_BLASTER_10L: + case Defines.MZ2_WIDOW_BLASTER_20L: + case Defines.MZ2_WIDOW_BLASTER_30L: + case Defines.MZ2_WIDOW_BLASTER_40L: + case Defines.MZ2_WIDOW_BLASTER_50L: + case Defines.MZ2_WIDOW_BLASTER_60L: + case Defines.MZ2_WIDOW_BLASTER_70L: + case Defines.MZ2_WIDOW_RUN_1: + case Defines.MZ2_WIDOW_RUN_2: + case Defines.MZ2_WIDOW_RUN_3: + case Defines.MZ2_WIDOW_RUN_4: + case Defines.MZ2_WIDOW_RUN_5: + case Defines.MZ2_WIDOW_RUN_6: + case Defines.MZ2_WIDOW_RUN_7: + case Defines.MZ2_WIDOW_RUN_8: + dl.color[0] = 0; + dl.color[1] = 1; + dl.color[2] = 0; + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("tank/tnkatck3.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_WIDOW_DISRUPTOR: + dl.color[0] = -1; + dl.color[1] = -1; + dl.color[2] = -1; + S.StartSound(null, ent, Defines.CHAN_WEAPON, S.RegisterSound("weapons/disint2.wav"), 1, Defines.ATTN_NORM, 0); + break; + + case Defines.MZ2_WIDOW_PLASMABEAM: + case Defines.MZ2_WIDOW2_BEAMER_1: + case Defines.MZ2_WIDOW2_BEAMER_2: + case Defines.MZ2_WIDOW2_BEAMER_3: + case Defines.MZ2_WIDOW2_BEAMER_4: + case Defines.MZ2_WIDOW2_BEAMER_5: + case Defines.MZ2_WIDOW2_BEAM_SWEEP_1: + case Defines.MZ2_WIDOW2_BEAM_SWEEP_2: + case Defines.MZ2_WIDOW2_BEAM_SWEEP_3: + case Defines.MZ2_WIDOW2_BEAM_SWEEP_4: + case Defines.MZ2_WIDOW2_BEAM_SWEEP_5: + case Defines.MZ2_WIDOW2_BEAM_SWEEP_6: + case Defines.MZ2_WIDOW2_BEAM_SWEEP_7: + case Defines.MZ2_WIDOW2_BEAM_SWEEP_8: + case Defines.MZ2_WIDOW2_BEAM_SWEEP_9: + case Defines.MZ2_WIDOW2_BEAM_SWEEP_10: + case Defines.MZ2_WIDOW2_BEAM_SWEEP_11: + dl.radius = 300 + (Globals.rnd.nextInt() & 100); + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 0; + dl.die = Globals.cl.time + 200; + break; + // ROGUE + // ====== + + // --- Xian's shit ends --- + + } + } + + /* + * =============== CL_AddDLights + * + * =============== + */ + static void AddDLights() { + cdlight_t dl; + + // ===== + // PGM + if (Globals.vidref_val == Defines.VIDREF_GL) { + for (int i = 0; i < Defines.MAX_DLIGHTS; i++) { + dl = cl_dlights[i]; + if (dl.radius == 0.0f) + continue; + V.AddLight(dl.origin, dl.radius, dl.color[0], dl.color[1], dl.color[2]); + } + } else { + for (int i = 0; i < Defines.MAX_DLIGHTS; i++) { + dl = cl_dlights[i]; + if (dl.radius == 0.0f) + continue; + + // negative light in software. only black allowed + if ((dl.color[0] < 0) || (dl.color[1] < 0) || (dl.color[2] < 0)) { + dl.radius = -(dl.radius); + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 1; + } + V.AddLight(dl.origin, dl.radius, dl.color[0], dl.color[1], dl.color[2]); + } + } + // PGM + // ===== + } + + /* + * =============== CL_ClearParticles =============== + */ + static void ClearParticles() { + free_particles = particles[0]; + active_particles = null; + + for (int i = 0; i < particles.length - 1; i++) + particles[i].next = particles[i + 1]; + particles[particles.length - 1].next = null; + } + + /* + * =============== CL_ParticleEffect + * + * Wall impact puffs =============== + */ + static void ParticleEffect(float[] org, float[] dir, int color, int count) { + int j; + cparticle_t p; + float d; + + for (int i = 0; i < count; i++) { + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + p.color = color + (Lib.rand() & 7); + + d = Lib.rand() & 31; + for (j = 0; j < 3; j++) { + p.org[j] = org[j] + ((Lib.rand() & 7) - 4) + d * dir[j]; + p.vel[j] = Lib.crand() * 20; + } + + p.accel[0] = p.accel[1] = 0; + p.accel[2] = -PARTICLE_GRAVITY; + p.alpha = 1.0f; + + p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f); + } + } + + /* + * =============== CL_ParticleEffect2 =============== + */ + static void ParticleEffect2(float[] org, float[] dir, int color, int count) { + int j; + cparticle_t p; + float d; + + for (int i = 0; i < count; i++) { + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + p.color = color; + + d = Lib.rand() & 7; + for (j = 0; j < 3; j++) { + p.org[j] = org[j] + ((Lib.rand() & 7) - 4) + d * dir[j]; + p.vel[j] = Lib.crand() * 20; + } + + p.accel[0] = p.accel[1] = 0; + p.accel[2] = -PARTICLE_GRAVITY; + p.alpha = 1.0f; + + p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f); + } + } + + // RAFAEL + /* + * =============== CL_ParticleEffect3 =============== + */ + static void ParticleEffect3(float[] org, float[] dir, int color, int count) { + int j; + cparticle_t p; + float d; + + for (int i = 0; i < count; i++) { + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + p.color = color; + + d = Lib.rand() & 7; + for (j = 0; j < 3; j++) { + p.org[j] = org[j] + ((Lib.rand() & 7) - 4) + d * dir[j]; + p.vel[j] = Lib.crand() * 20; + } + + p.accel[0] = p.accel[1] = 0; + p.accel[2] = PARTICLE_GRAVITY; + p.alpha = 1.0f; + + p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f); + } + } + + /* + * =============== CL_TeleporterParticles =============== + */ + static void TeleporterParticles(entity_state_t ent) { + int j; + cparticle_t p; + + for (int i = 0; i < 8; i++) { + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + p.color = 0xdb; + + for (j = 0; j < 2; j++) { + p.org[j] = ent.origin[j] - 16 + (Lib.rand() & 31); + p.vel[j] = Lib.crand() * 14; + } + + p.org[2] = ent.origin[2] - 8 + (Lib.rand() & 7); + p.vel[2] = 80 + (Lib.rand() & 7); + + p.accel[0] = p.accel[1] = 0; + p.accel[2] = -PARTICLE_GRAVITY; + p.alpha = 1.0f; + + p.alphavel = -0.5f; + } + } + + /* + * =============== CL_LogoutEffect + * + * =============== + */ + static void LogoutEffect(float[] org, int type) { + int j; + cparticle_t p; + + for (int i = 0; i < 500; i++) { + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + + if (type == Defines.MZ_LOGIN) + p.color = 0xd0 + (Lib.rand() & 7); // green + else if (type == Defines.MZ_LOGOUT) + p.color = 0x40 + (Lib.rand() & 7); // red + else + p.color = 0xe0 + (Lib.rand() & 7); // yellow + + p.org[0] = org[0] - 16 + Globals.rnd.nextFloat() * 32; + p.org[1] = org[1] - 16 + Globals.rnd.nextFloat() * 32; + p.org[2] = org[2] - 24 + Globals.rnd.nextFloat() * 56; + + for (j = 0; j < 3; j++) + p.vel[j] = Lib.crand() * 20; + + p.accel[0] = p.accel[1] = 0; + p.accel[2] = -PARTICLE_GRAVITY; + p.alpha = 1.0f; + + p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.3f); + } + } + + /* + * =============== CL_ItemRespawnParticles + * + * =============== + */ + static void ItemRespawnParticles(float[] org) { + int j; + cparticle_t p; + + for (int i = 0; i < 64; i++) { + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + + p.color = 0xd4 + (Lib.rand() & 3); // green + + p.org[0] = org[0] + Lib.crand() * 8; + p.org[1] = org[1] + Lib.crand() * 8; + p.org[2] = org[2] + Lib.crand() * 8; + + for (j = 0; j < 3; j++) + p.vel[j] = Lib.crand() * 8; + + p.accel[0] = p.accel[1] = 0; + p.accel[2] = -PARTICLE_GRAVITY * 0.2f; + p.alpha = 1.0f; + + p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.3f); + } + } + + /* + * =============== CL_ExplosionParticles =============== + */ + static void ExplosionParticles(float[] org) { + int j; + cparticle_t p; + + for (int i = 0; i < 256; i++) { + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + p.color = 0xe0 + (Lib.rand() & 7); + + for (j = 0; j < 3; j++) { + p.org[j] = org[j] + ((Lib.rand() % 32) - 16); + p.vel[j] = (Lib.rand() % 384) - 192; + } + + p.accel[0] = p.accel[1] = 0.0f; + p.accel[2] = -PARTICLE_GRAVITY; + p.alpha = 1.0f; + + p.alphavel = -0.8f / (0.5f + Globals.rnd.nextFloat() * 0.3f); + } + } + + static void BigTeleportParticles(float[] org) { + cparticle_t p; + float angle, dist; + + for (int i = 0; i < 4096; i++) { + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + + p.color = colortable[Lib.rand() & 3]; + + angle = (float) (Math.PI * 2 * (Lib.rand() & 1023) / 1023.0); + dist = Lib.rand() & 31; + p.org[0] = (float) (org[0] + Math.cos(angle) * dist); + p.vel[0] = (float) (Math.cos(angle) * (70 + (Lib.rand() & 63))); + p.accel[0] = (float) (-Math.cos(angle) * 100); + + p.org[1] = (float) (org[1] + Math.sin(angle) * dist); + p.vel[1] = (float) (Math.sin(angle) * (70 + (Lib.rand() & 63))); + p.accel[1] = (float) (-Math.sin(angle) * 100); + + p.org[2] = org[2] + 8 + (Lib.rand() % 90); + p.vel[2] = -100 + (Lib.rand() & 31); + p.accel[2] = PARTICLE_GRAVITY * 4; + p.alpha = 1.0f; + + p.alphavel = -0.3f / (0.5f + Globals.rnd.nextFloat() * 0.3f); + } + } + + /* + * =============== CL_BlasterParticles + * + * Wall impact puffs =============== + */ + static void BlasterParticles(float[] org, float[] dir) { + int j; + cparticle_t p; + float d; + + int count = 40; + for (int i = 0; i < count; i++) { + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + p.color = 0xe0 + (Lib.rand() & 7); + + d = Lib.rand() & 15; + for (j = 0; j < 3; j++) { + p.org[j] = org[j] + ((Lib.rand() & 7) - 4) + d * dir[j]; + p.vel[j] = dir[j] * 30 + Lib.crand() * 40; + } + + p.accel[0] = p.accel[1] = 0; + p.accel[2] = -PARTICLE_GRAVITY; + p.alpha = 1.0f; + + p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f); + } + } + + // stack variable + private static final float[] move = {0, 0, 0}; + private static final float[] vec = {0, 0, 0}; + /* + * =============== CL_BlasterTrail + * + * =============== + */ + static void BlasterTrail(float[] start, float[] end) { + float len; + int j; + cparticle_t p; + int dec; + + Math3D.VectorCopy(start, move); + Math3D.VectorSubtract(end, start, vec); + len = Math3D.VectorNormalize(vec); + + dec = 5; + Math3D.VectorScale(vec, 5, vec); + + // FIXME: this is a really silly way to have a loop + while (len > 0) { + len -= dec; + + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + Math3D.VectorClear(p.accel); + + p.time = Globals.cl.time; + + p.alpha = 1.0f; + p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f); + p.color = 0xe0; + for (j = 0; j < 3; j++) { + p.org[j] = move[j] + Lib.crand(); + p.vel[j] = Lib.crand() * 5; + p.accel[j] = 0; + } + + Math3D.VectorAdd(move, vec, move); + } + } + + // stack variable + // move, vec + /* + * =============== + * CL_FlagTrail + * =============== + */ + static void FlagTrail(float[] start, float[] end, float color) { + float len; + int j; + cparticle_t p; + int dec; + + Math3D.VectorCopy(start, move); + Math3D.VectorSubtract(end, start, vec); + len = Math3D.VectorNormalize(vec); + + dec = 5; + Math3D.VectorScale(vec, 5, vec); + + while (len > 0) { + len -= dec; + + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + Math3D.VectorClear(p.accel); + + p.time = Globals.cl.time; + + p.alpha = 1.0f; + p.alphavel = -1.0f / (0.8f + Globals.rnd.nextFloat() * 0.2f); + p.color = color; + for (j = 0; j < 3; j++) { + p.org[j] = move[j] + Lib.crand() * 16; + p.vel[j] = Lib.crand() * 5; + p.accel[j] = 0; + } + + Math3D.VectorAdd(move, vec, move); + } + } + + // stack variable + // move, vec + /* + * =============== CL_DiminishingTrail + * + * =============== + */ + static void DiminishingTrail(float[] start, float[] end, centity_t old, int flags) { + cparticle_t p; + float orgscale; + float velscale; + + Math3D.VectorCopy(start, move); + Math3D.VectorSubtract(end, start, vec); + float len = Math3D.VectorNormalize(vec); + + float dec = 0.5f; + Math3D.VectorScale(vec, dec, vec); + + if (old.trailcount > 900) { + orgscale = 4; + velscale = 15; + } else if (old.trailcount > 800) { + orgscale = 2; + velscale = 10; + } else { + orgscale = 1; + velscale = 5; + } + + while (len > 0) { + len -= dec; + + if (free_particles == null) + return; + + // drop less particles as it flies + if ((Lib.rand() & 1023) < old.trailcount) { + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + Math3D.VectorClear(p.accel); + + p.time = Globals.cl.time; + + if ((flags & Defines.EF_GIB) != 0) { + p.alpha = 1.0f; + p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.4f); + p.color = 0xe8 + (Lib.rand() & 7); + for (int j = 0; j < 3; j++) { + p.org[j] = move[j] + Lib.crand() * orgscale; + p.vel[j] = Lib.crand() * velscale; + p.accel[j] = 0; + } + p.vel[2] -= PARTICLE_GRAVITY; + } else if ((flags & Defines.EF_GREENGIB) != 0) { + p.alpha = 1.0f; + p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.4f); + p.color = 0xdb + (Lib.rand() & 7); + for (int j = 0; j < 3; j++) { + p.org[j] = move[j] + Lib.crand() * orgscale; + p.vel[j] = Lib.crand() * velscale; + p.accel[j] = 0; + } + p.vel[2] -= PARTICLE_GRAVITY; + } else { + p.alpha = 1.0f; + p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f); + p.color = 4 + (Lib.rand() & 7); + for (int j = 0; j < 3; j++) { + p.org[j] = move[j] + Lib.crand() * orgscale; + p.vel[j] = Lib.crand() * velscale; + } + p.accel[2] = 20; + } + } + + old.trailcount -= 5; + if (old.trailcount < 100) + old.trailcount = 100; + Math3D.VectorAdd(move, vec, move); + } + } + + // stack variable + // move, vec + /* + * =============== CL_RocketTrail + * + * =============== + */ + static void RocketTrail(float[] start, float[] end, centity_t old) { + float len; + int j; + cparticle_t p; + float dec; + + // smoke + DiminishingTrail(start, end, old, Defines.EF_ROCKET); + + // fire + Math3D.VectorCopy(start, move); + Math3D.VectorSubtract(end, start, vec); + len = Math3D.VectorNormalize(vec); + + dec = 1; + Math3D.VectorScale(vec, dec, vec); + + while (len > 0) { + len -= dec; + + if (free_particles == null) + return; + + if ((Lib.rand() & 7) == 0) { + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + Math3D.VectorClear(p.accel); + p.time = Globals.cl.time; + + p.alpha = 1.0f; + p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f); + p.color = 0xdc + (Lib.rand() & 3); + for (j = 0; j < 3; j++) { + p.org[j] = move[j] + Lib.crand() * 5; + p.vel[j] = Lib.crand() * 20; + } + p.accel[2] = -PARTICLE_GRAVITY; + } + Math3D.VectorAdd(move, vec, move); + } + } + + // stack variable + // move, vec + /* + * =============== CL_RailTrail + * + * =============== + */ + static void RailTrail(float[] start, float[] end) { + float len; + int j; + cparticle_t p; + float dec; + float[] right = new float[3]; + float[] up = new float[3]; + int i; + float d, c, s; + float[] dir = new float[3]; + byte clr = 0x74; + + Math3D.VectorCopy(start, move); + Math3D.VectorSubtract(end, start, vec); + len = Math3D.VectorNormalize(vec); + + Math3D.MakeNormalVectors(vec, right, up); + + for (i = 0; i < len; i++) { + if (free_particles == null) + return; + + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + Math3D.VectorClear(p.accel); + + d = i * 0.1f; + c = (float) Math.cos(d); + s = (float) Math.sin(d); + + Math3D.VectorScale(right, c, dir); + Math3D.VectorMA(dir, s, up, dir); + + p.alpha = 1.0f; + p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f); + p.color = clr + (Lib.rand() & 7); + for (j = 0; j < 3; j++) { + p.org[j] = move[j] + dir[j] * 3; + p.vel[j] = dir[j] * 6; + } + + Math3D.VectorAdd(move, vec, move); + } + + dec = 0.75f; + Math3D.VectorScale(vec, dec, vec); + Math3D.VectorCopy(start, move); + + while (len > 0) { + len -= dec; + + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + Math3D.VectorClear(p.accel); + + p.alpha = 1.0f; + p.alphavel = -1.0f / (0.6f + Globals.rnd.nextFloat() * 0.2f); + p.color = 0x0 + Lib.rand() & 15; + + for (j = 0; j < 3; j++) { + p.org[j] = move[j] + Lib.crand() * 3; + p.vel[j] = Lib.crand() * 3; + p.accel[j] = 0; + } + + Math3D.VectorAdd(move, vec, move); + } + } + + // stack variable + // move, vec + /* + * =============== CL_IonripperTrail =============== + */ + static void IonripperTrail(float[] start, float[] ent) { + float len; + int j; + cparticle_t p; + int dec; + int left = 0; + + Math3D.VectorCopy(start, move); + Math3D.VectorSubtract(ent, start, vec); + len = Math3D.VectorNormalize(vec); + + dec = 5; + Math3D.VectorScale(vec, 5, vec); + + while (len > 0) { + len -= dec; + + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + Math3D.VectorClear(p.accel); + + p.time = Globals.cl.time; + p.alpha = 0.5f; + p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f); + p.color = 0xe4 + (Lib.rand() & 3); + + for (j = 0; j < 3; j++) { + p.org[j] = move[j]; + p.accel[j] = 0; + } + if (left != 0) { + left = 0; + p.vel[0] = 10; + } else { + left = 1; + p.vel[0] = -10; + } + + p.vel[1] = 0; + p.vel[2] = 0; + + Math3D.VectorAdd(move, vec, move); + } + } + + // stack variable + // move, vec + /* + * =============== CL_BubbleTrail + * + * =============== + */ + static void BubbleTrail(float[] start, float[] end) { + float len; + int i, j; + cparticle_t p; + float dec; + + Math3D.VectorCopy(start, move); + Math3D.VectorSubtract(end, start, vec); + len = Math3D.VectorNormalize(vec); + + dec = 32; + Math3D.VectorScale(vec, dec, vec); + + for (i = 0; i < len; i += dec) { + if (free_particles == null) + return; + + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + Math3D.VectorClear(p.accel); + p.time = Globals.cl.time; + + p.alpha = 1.0f; + p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f); + p.color = 4 + (Lib.rand() & 7); + for (j = 0; j < 3; j++) { + p.org[j] = move[j] + Lib.crand() * 2; + p.vel[j] = Lib.crand() * 5; + } + p.vel[2] += 6; + + Math3D.VectorAdd(move, vec, move); + } + } + + // stack variable + // forward + /* + * =============== CL_FlyParticles =============== + */ + static void FlyParticles(float[] origin, int count) { + int i; + cparticle_t p; + float angle; + float sp, sy, cp, cy; + float dist = 64; + float ltime; + + if (count > Defines.NUMVERTEXNORMALS) + count = Defines.NUMVERTEXNORMALS; + + if (avelocities[0][0] == 0.0f) { + for (i = 0; i < Defines.NUMVERTEXNORMALS; i++) { + avelocities[i][0] = (Lib.rand() & 255) * 0.01f; + avelocities[i][1] = (Lib.rand() & 255) * 0.01f; + avelocities[i][2] = (Lib.rand() & 255) * 0.01f; + } + } + + ltime = Globals.cl.time / 1000.0f; + for (i = 0; i < count; i += 2) { + angle = ltime * avelocities[i][0]; + sy = (float) Math.sin(angle); + cy = (float) Math.cos(angle); + angle = ltime * avelocities[i][1]; + sp = (float) Math.sin(angle); + cp = (float) Math.cos(angle); + angle = ltime * avelocities[i][2]; + + forward[0] = cp * cy; + forward[1] = cp * sy; + forward[2] = -sp; + + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + + dist = (float) Math.sin(ltime + i) * 64; + p.org[0] = origin[0] + Globals.bytedirs[i][0] * dist + forward[0] * BEAMLENGTH; + p.org[1] = origin[1] + Globals.bytedirs[i][1] * dist + forward[1] * BEAMLENGTH; + p.org[2] = origin[2] + Globals.bytedirs[i][2] * dist + forward[2] * BEAMLENGTH; + + Math3D.VectorClear(p.vel); + Math3D.VectorClear(p.accel); + + p.color = 0; + //p.colorvel = 0; + + p.alpha = 1; + p.alphavel = -100; + } + } + + static void FlyEffect(centity_t ent, float[] origin) { + int n; + int count; + int starttime; + + if (ent.fly_stoptime < Globals.cl.time) { + starttime = Globals.cl.time; + ent.fly_stoptime = Globals.cl.time + 60000; + } else { + starttime = ent.fly_stoptime - 60000; + } + + n = Globals.cl.time - starttime; + if (n < 20000) + count = (int) ((n * 162) / 20000.0); + else { + n = ent.fly_stoptime - Globals.cl.time; + if (n < 20000) + count = (int) ((n * 162) / 20000.0); + else + count = 162; + } + + FlyParticles(origin, count); + } + + // stack variable + private static final float[] v = {0, 0, 0}; + // forward + /* + * =============== CL_BfgParticles =============== + */ + //#define BEAMLENGTH 16 + static void BfgParticles(entity_t ent) { + int i; + cparticle_t p; + float angle; + float sp, sy, cp, cy; + float dist = 64; + float ltime; + + if (avelocities[0][0] == 0.0f) { + for (i = 0; i < Defines.NUMVERTEXNORMALS; i++) { + avelocities[i][0] = (Lib.rand() & 255) * 0.01f; + avelocities[i][1] = (Lib.rand() & 255) * 0.01f; + avelocities[i][2] = (Lib.rand() & 255) * 0.01f; + } + } + + ltime = Globals.cl.time / 1000.0f; + for (i = 0; i < Defines.NUMVERTEXNORMALS; i++) { + angle = ltime * avelocities[i][0]; + sy = (float) Math.sin(angle); + cy = (float) Math.cos(angle); + angle = ltime * avelocities[i][1]; + sp = (float) Math.sin(angle); + cp = (float) Math.cos(angle); + angle = ltime * avelocities[i][2]; + + forward[0] = cp * cy; + forward[1] = cp * sy; + forward[2] = -sp; + + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + + dist = (float) (Math.sin(ltime + i) * 64); + p.org[0] = ent.origin[0] + Globals.bytedirs[i][0] * dist + forward[0] * BEAMLENGTH; + p.org[1] = ent.origin[1] + Globals.bytedirs[i][1] * dist + forward[1] * BEAMLENGTH; + p.org[2] = ent.origin[2] + Globals.bytedirs[i][2] * dist + forward[2] * BEAMLENGTH; + + Math3D.VectorClear(p.vel); + Math3D.VectorClear(p.accel); + + Math3D.VectorSubtract(p.org, ent.origin, v); + dist = Math3D.VectorLength(v) / 90.0f; + p.color = (float) Math.floor(0xd0 + dist * 7); + //p.colorvel = 0; + + p.alpha = 1.0f - dist; + p.alphavel = -100; + } + } + + // stack variable + // move, vec + private static final float[] start = {0, 0, 0}; + private static final float[] end = {0, 0, 0}; + /* + * =============== CL_TrapParticles =============== + */ + // RAFAEL + static void TrapParticles(entity_t ent) { + float len; + int j; + cparticle_t p; + int dec; + + ent.origin[2] -= 14; + Math3D.VectorCopy(ent.origin, start); + Math3D.VectorCopy(ent.origin, end); + end[2] += 64; + + Math3D.VectorCopy(start, move); + Math3D.VectorSubtract(end, start, vec); + len = Math3D.VectorNormalize(vec); + + dec = 5; + Math3D.VectorScale(vec, 5, vec); + + // FIXME: this is a really silly way to have a loop + while (len > 0) { + len -= dec; + + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + Math3D.VectorClear(p.accel); + + p.time = Globals.cl.time; + + p.alpha = 1.0f; + p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f); + p.color = 0xe0; + for (j = 0; j < 3; j++) { + p.org[j] = move[j] + Lib.crand(); + p.vel[j] = Lib.crand() * 15; + p.accel[j] = 0; + } + p.accel[2] = PARTICLE_GRAVITY; + + Math3D.VectorAdd(move, vec, move); + } + + int i, k; + //cparticle_t p; + float vel; + float[] dir = new float[3]; + float[] org = new float[3]; + + ent.origin[2] += 14; + Math3D.VectorCopy(ent.origin, org); + + for (i = -2; i <= 2; i += 4) + for (j = -2; j <= 2; j += 4) + for (k = -2; k <= 4; k += 4) { + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + p.color = 0xe0 + (Lib.rand() & 3); + + p.alpha = 1.0f; + p.alphavel = -1.0f / (0.3f + (Lib.rand() & 7) * 0.02f); + + p.org[0] = org[0] + i + ((Lib.rand() & 23) * Lib.crand()); + p.org[1] = org[1] + j + ((Lib.rand() & 23) * Lib.crand()); + p.org[2] = org[2] + k + ((Lib.rand() & 23) * Lib.crand()); + + dir[0] = j * 8; + dir[1] = i * 8; + dir[2] = k * 8; + + Math3D.VectorNormalize(dir); + vel = 50 + Lib.rand() & 63; + Math3D.VectorScale(dir, vel, p.vel); + + p.accel[0] = p.accel[1] = 0; + p.accel[2] = -PARTICLE_GRAVITY; + } + + } + + /* + * =============== CL_BFGExplosionParticles =============== + */ + // FIXME combined with CL_ExplosionParticles + static void BFGExplosionParticles(float[] org) { + int j; + cparticle_t p; + + for (int i = 0; i < 256; i++) { + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + p.color = 0xd0 + (Lib.rand() & 7); + + for (j = 0; j < 3; j++) { + p.org[j] = org[j] + ((Lib.rand() % 32) - 16); + p.vel[j] = (Lib.rand() % 384) - 192; + } + + p.accel[0] = p.accel[1] = 0; + p.accel[2] = -PARTICLE_GRAVITY; + p.alpha = 1.0f; + + p.alphavel = -0.8f / (0.5f + Globals.rnd.nextFloat() * 0.3f); + } + } + + // stack variable + private static final float[] dir = {0, 0, 0}; + /* + * =============== CL_TeleportParticles + * + * =============== + */ + static void TeleportParticles(float[] org) { + cparticle_t p; + float vel; + + for (int i = -16; i <= 16; i += 4) + for (int j = -16; j <= 16; j += 4) + for (int k = -16; k <= 32; k += 4) { + if (free_particles == null) + return; + p = free_particles; + free_particles = p.next; + p.next = active_particles; + active_particles = p; + + p.time = Globals.cl.time; + p.color = 7 + (Lib.rand() & 7); + + p.alpha = 1.0f; + p.alphavel = -1.0f / (0.3f + (Lib.rand() & 7) * 0.02f); + + p.org[0] = org[0] + i + (Lib.rand() & 3); + p.org[1] = org[1] + j + (Lib.rand() & 3); + p.org[2] = org[2] + k + (Lib.rand() & 3); + + dir[0] = j * 8; + dir[1] = i * 8; + dir[2] = k * 8; + + Math3D.VectorNormalize(dir); + vel = 50 + (Lib.rand() & 63); + Math3D.VectorScale(dir, vel, p.vel); + + p.accel[0] = p.accel[1] = 0; + p.accel[2] = -PARTICLE_GRAVITY; + } + } + + // stack variable + private static final float[] org = {0, 0, 0}; + /* + * =============== CL_AddParticles =============== + */ + static void AddParticles() { + cparticle_t p, next; + float alpha; + float time = 0.0f; + float time2; + int color; + cparticle_t active, tail; + + active = null; + tail = null; + + for (p = active_particles; p != null; p = next) { + next = p.next; + + // PMM - added INSTANT_PARTICLE handling for heat beam + if (p.alphavel != INSTANT_PARTICLE) { + time = (Globals.cl.time - p.time) * 0.001f; + alpha = p.alpha + time * p.alphavel; + if (alpha <= 0) { // faded out + p.next = free_particles; + free_particles = p; + continue; + } + } else { + alpha = p.alpha; + } + + p.next = null; + if (tail == null) + active = tail = p; + else { + tail.next = p; + tail = p; + } + + if (alpha > 1.0) + alpha = 1; + color = (int) p.color; + + time2 = time * time; + + org[0] = p.org[0] + p.vel[0] * time + p.accel[0] * time2; + org[1] = p.org[1] + p.vel[1] * time + p.accel[1] * time2; + org[2] = p.org[2] + p.vel[2] * time + p.accel[2] * time2; + + V.AddParticle(org, color, alpha); + // PMM + if (p.alphavel == INSTANT_PARTICLE) { + p.alphavel = 0.0f; + p.alpha = 0.0f; + } + } + + active_particles = active; + } + + /* + * ============== CL_EntityEvent + * + * An entity has just been parsed that has an event value + * + * the female events are there for backwards compatability ============== + */ + static void EntityEvent(entity_state_t ent) { + switch (ent.event) { + case Defines.EV_ITEM_RESPAWN: + S.StartSound(null, ent.number, Defines.CHAN_WEAPON, S.RegisterSound("items/respawn1.wav"), 1, Defines.ATTN_IDLE, 0); + ItemRespawnParticles(ent.origin); + break; + case Defines.EV_PLAYER_TELEPORT: + S.StartSound(null, ent.number, Defines.CHAN_WEAPON, S.RegisterSound("misc/tele1.wav"), 1, Defines.ATTN_IDLE, 0); + TeleportParticles(ent.origin); + break; + case Defines.EV_FOOTSTEP: + if (Globals.cl_footsteps.value != 0.0f) + S.StartSound(null, ent.number, Defines.CHAN_BODY, CL_tent.cl_sfx_footsteps[Lib.rand() & 3], 1, Defines.ATTN_NORM, 0); + break; + case Defines.EV_FALLSHORT: + S.StartSound(null, ent.number, Defines.CHAN_AUTO, S.RegisterSound("player/land1.wav"), 1, Defines.ATTN_NORM, 0); + break; + case Defines.EV_FALL: + S.StartSound(null, ent.number, Defines.CHAN_AUTO, S.RegisterSound("*fall2.wav"), 1, Defines.ATTN_NORM, 0); + break; + case Defines.EV_FALLFAR: + S.StartSound(null, ent.number, Defines.CHAN_AUTO, S.RegisterSound("*fall1.wav"), 1, Defines.ATTN_NORM, 0); + break; + } + } + + /* + * ============== CL_ClearEffects + * + * ============== + */ + static void ClearEffects() { + ClearParticles(); + ClearDlights(); + ClearLightStyles(); + } + + /* + * ============================================================== + * + * PARTICLE MANAGEMENT + * + * ============================================================== + */ + + static final int PARTICLE_GRAVITY = 40; + + static cparticle_t active_particles, free_particles; + + /* + * =============== CL_BigTeleportParticles =============== + */ + private static int[] colortable = { 2 * 8, 13 * 8, 21 * 8, 18 * 8 }; + + private static final int BEAMLENGTH = 16; } \ No newline at end of file diff --git a/src/main/java/lwjake2/client/CL_input.java b/src/main/java/lwjake2/client/CL_input.java index 7636bc2..a46a9a8 100644 --- a/src/main/java/lwjake2/client/CL_input.java +++ b/src/main/java/lwjake2/client/CL_input.java @@ -38,585 +38,585 @@ import lwjake2.util.Math3D; */ public class CL_input { - static long frame_msec; + static long frame_msec; - static long old_sys_frame_time; + static long old_sys_frame_time; - static cvar_t cl_nodelta; + static cvar_t cl_nodelta; - /* - * =============================================================================== - * - * KEY BUTTONS - * - * Continuous button event tracking is complicated by the fact that two - * different input sources (say, mouse button 1 and the control key) can - * both press the same button, but the button should only be released when - * both of the pressing key have been released. - * - * When a key event issues a button command (+forward, +attack, etc), it - * appends its key number as a parameter to the command so it can be matched - * up with the release. - * - * state bit 0 is the current state of the key state bit 1 is edge triggered - * on the up to down transition state bit 2 is edge triggered on the down to - * up transition - * - * - * Key_Event (int key, qboolean down, unsigned time); - * - * +mlook src time - * - * =============================================================================== - */ - - static kbutton_t in_klook = new kbutton_t(); - - static kbutton_t in_left = new kbutton_t(); - - static kbutton_t in_right = new kbutton_t(); - - static kbutton_t in_forward = new kbutton_t(); - - static kbutton_t in_back = new kbutton_t(); - - static kbutton_t in_lookup = new kbutton_t(); - - static kbutton_t in_lookdown = new kbutton_t(); - - static kbutton_t in_moveleft = new kbutton_t(); - - static kbutton_t in_moveright = new kbutton_t(); - - public static kbutton_t in_strafe = new kbutton_t(); - - static kbutton_t in_speed = new kbutton_t(); - - static kbutton_t in_use = new kbutton_t(); - - static kbutton_t in_attack = new kbutton_t(); - - static kbutton_t in_up = new kbutton_t(); - - static kbutton_t in_down = new kbutton_t(); - - static int in_impulse; - - static void KeyDown(kbutton_t b) { - int k; - String c; - - c = Cmd.Argv(1); - if (c.length() > 0) - k = Lib.atoi(c); - else - k = -1; // typed manually at the console for continuous down - - if (k == b.down[0] || k == b.down[1]) - return; // repeating key - - if (b.down[0] == 0) - b.down[0] = k; - else if (b.down[1] == 0) - b.down[1] = k; - else { - Com.Printf("Three keys down for a button!\n"); - return; - } - - if ((b.state & 1) != 0) - return; // still down - - // save timestamp - c = Cmd.Argv(2); - b.downtime = Lib.atoi(c); - if (b.downtime == 0) - b.downtime = Globals.sys_frame_time - 100; - - b.state |= 3; // down + impulse down - } - - static void KeyUp(kbutton_t b) { - int k; - String c; - int uptime; - - c = Cmd.Argv(1); - if (c.length() > 0) - k = Lib.atoi(c); - else { - // typed manually at the console, assume for unsticking, so clear - // all - b.down[0] = b.down[1] = 0; - b.state = 4; // impulse up - return; - } - - if (b.down[0] == k) - b.down[0] = 0; - else if (b.down[1] == k) - b.down[1] = 0; - else - return; // key up without coresponding down (menu pass through) - if (b.down[0] != 0 || b.down[1] != 0) - return; // some other key is still holding it down + /* + * =============================================================================== + * + * KEY BUTTONS + * + * Continuous button event tracking is complicated by the fact that two + * different input sources (say, mouse button 1 and the control key) can + * both press the same button, but the button should only be released when + * both of the pressing key have been released. + * + * When a key event issues a button command (+forward, +attack, etc), it + * appends its key number as a parameter to the command so it can be matched + * up with the release. + * + * state bit 0 is the current state of the key state bit 1 is edge triggered + * on the up to down transition state bit 2 is edge triggered on the down to + * up transition + * + * + * Key_Event (int key, qboolean down, unsigned time); + * + * +mlook src time + * + * =============================================================================== + */ + + static kbutton_t in_klook = new kbutton_t(); + + static kbutton_t in_left = new kbutton_t(); + + static kbutton_t in_right = new kbutton_t(); + + static kbutton_t in_forward = new kbutton_t(); + + static kbutton_t in_back = new kbutton_t(); + + static kbutton_t in_lookup = new kbutton_t(); + + static kbutton_t in_lookdown = new kbutton_t(); + + static kbutton_t in_moveleft = new kbutton_t(); + + static kbutton_t in_moveright = new kbutton_t(); + + public static kbutton_t in_strafe = new kbutton_t(); + + static kbutton_t in_speed = new kbutton_t(); + + static kbutton_t in_use = new kbutton_t(); + + static kbutton_t in_attack = new kbutton_t(); + + static kbutton_t in_up = new kbutton_t(); + + static kbutton_t in_down = new kbutton_t(); + + static int in_impulse; + + static void KeyDown(kbutton_t b) { + int k; + String c; + + c = Cmd.Argv(1); + if (c.length() > 0) + k = Lib.atoi(c); + else + k = -1; // typed manually at the console for continuous down + + if (k == b.down[0] || k == b.down[1]) + return; // repeating key + + if (b.down[0] == 0) + b.down[0] = k; + else if (b.down[1] == 0) + b.down[1] = k; + else { + Com.Printf("Three keys down for a button!\n"); + return; + } + + if ((b.state & 1) != 0) + return; // still down + + // save timestamp + c = Cmd.Argv(2); + b.downtime = Lib.atoi(c); + if (b.downtime == 0) + b.downtime = Globals.sys_frame_time - 100; + + b.state |= 3; // down + impulse down + } + + static void KeyUp(kbutton_t b) { + int k; + String c; + int uptime; + + c = Cmd.Argv(1); + if (c.length() > 0) + k = Lib.atoi(c); + else { + // typed manually at the console, assume for unsticking, so clear + // all + b.down[0] = b.down[1] = 0; + b.state = 4; // impulse up + return; + } + + if (b.down[0] == k) + b.down[0] = 0; + else if (b.down[1] == k) + b.down[1] = 0; + else + return; // key up without coresponding down (menu pass through) + if (b.down[0] != 0 || b.down[1] != 0) + return; // some other key is still holding it down - if ((b.state & 1) == 0) - return; // still up (this should not happen) + if ((b.state & 1) == 0) + return; // still up (this should not happen) - // save timestamp - c = Cmd.Argv(2); - uptime = Lib.atoi(c); - if (uptime != 0) - b.msec += uptime - b.downtime; - else - b.msec += 10; + // save timestamp + c = Cmd.Argv(2); + uptime = Lib.atoi(c); + if (uptime != 0) + b.msec += uptime - b.downtime; + else + b.msec += 10; - b.state &= ~1; // now up - b.state |= 4; // impulse up - } + b.state &= ~1; // now up + b.state |= 4; // impulse up + } - static void IN_KLookDown() { - KeyDown(in_klook); - } + static void IN_KLookDown() { + KeyDown(in_klook); + } - static void IN_KLookUp() { - KeyUp(in_klook); - } + static void IN_KLookUp() { + KeyUp(in_klook); + } - static void IN_UpDown() { - KeyDown(in_up); - } - - static void IN_UpUp() { - KeyUp(in_up); - } - - static void IN_DownDown() { - KeyDown(in_down); - } - - static void IN_DownUp() { - KeyUp(in_down); - } - - static void IN_LeftDown() { - KeyDown(in_left); - } - - static void IN_LeftUp() { - KeyUp(in_left); - } - - static void IN_RightDown() { - KeyDown(in_right); - } - - static void IN_RightUp() { - KeyUp(in_right); - } - - static void IN_ForwardDown() { - KeyDown(in_forward); - } - - static void IN_ForwardUp() { - KeyUp(in_forward); - } - - static void IN_BackDown() { - KeyDown(in_back); - } - - static void IN_BackUp() { - KeyUp(in_back); - } - - static void IN_LookupDown() { - KeyDown(in_lookup); - } - - static void IN_LookupUp() { - KeyUp(in_lookup); - } - - static void IN_LookdownDown() { - KeyDown(in_lookdown); - } - - static void IN_LookdownUp() { - KeyUp(in_lookdown); - } - - static void IN_MoveleftDown() { - KeyDown(in_moveleft); - } - - static void IN_MoveleftUp() { - KeyUp(in_moveleft); - } - - static void IN_MoverightDown() { - KeyDown(in_moveright); - } - - static void IN_MoverightUp() { - KeyUp(in_moveright); - } - - static void IN_SpeedDown() { - KeyDown(in_speed); - } - - static void IN_SpeedUp() { - KeyUp(in_speed); - } - - static void IN_StrafeDown() { - KeyDown(in_strafe); - } - - static void IN_StrafeUp() { - KeyUp(in_strafe); - } - - static void IN_AttackDown() { - KeyDown(in_attack); - } - - static void IN_AttackUp() { - KeyUp(in_attack); - } - - static void IN_UseDown() { - KeyDown(in_use); - } - - static void IN_UseUp() { - KeyUp(in_use); - } - - static void IN_Impulse() { - in_impulse = Lib.atoi(Cmd.Argv(1)); - } - - /* - * =============== CL_KeyState - * - * Returns the fraction of the frame that the key was down =============== - */ - static float KeyState(kbutton_t key) { - float val; - long msec; - - key.state &= 1; // clear impulses - - msec = key.msec; - key.msec = 0; - - if (key.state != 0) { - // still down - msec += Globals.sys_frame_time - key.downtime; - key.downtime = Globals.sys_frame_time; - } - - val = (float) msec / frame_msec; - if (val < 0) - val = 0; - if (val > 1) - val = 1; - - return val; - } - - // ========================================================================== - - /* - * ================ CL_AdjustAngles - * - * Moves the local angle positions ================ - */ - static void AdjustAngles() { - float speed; - float up, down; - - if ((in_speed.state & 1) != 0) - speed = Globals.cls.frametime * Globals.cl_anglespeedkey.value; - else - speed = Globals.cls.frametime; - - if ((in_strafe.state & 1) == 0) { - Globals.cl.viewangles[Defines.YAW] -= speed * Globals.cl_yawspeed.value * KeyState(in_right); - Globals.cl.viewangles[Defines.YAW] += speed * Globals.cl_yawspeed.value * KeyState(in_left); - } - if ((in_klook.state & 1) != 0) { - Globals.cl.viewangles[Defines.PITCH] -= speed * Globals.cl_pitchspeed.value * KeyState(in_forward); - Globals.cl.viewangles[Defines.PITCH] += speed * Globals.cl_pitchspeed.value * KeyState(in_back); - } - - up = KeyState(in_lookup); - down = KeyState(in_lookdown); - - Globals.cl.viewangles[Defines.PITCH] -= speed * Globals.cl_pitchspeed.value * up; - Globals.cl.viewangles[Defines.PITCH] += speed * Globals.cl_pitchspeed.value * down; - } - - /* - * ================ CL_BaseMove - * - * Send the intended movement message to the server ================ - */ - static void BaseMove(usercmd_t cmd) { - AdjustAngles(); - - //memset (cmd, 0, sizeof(*cmd)); - cmd.clear(); - - Math3D.VectorCopy(Globals.cl.viewangles, cmd.angles); - if ((in_strafe.state & 1) != 0) { - cmd.sidemove += Globals.cl_sidespeed.value * KeyState(in_right); - cmd.sidemove -= Globals.cl_sidespeed.value * KeyState(in_left); - } - - cmd.sidemove += Globals.cl_sidespeed.value * KeyState(in_moveright); - cmd.sidemove -= Globals.cl_sidespeed.value * KeyState(in_moveleft); - - cmd.upmove += Globals.cl_upspeed.value * KeyState(in_up); - cmd.upmove -= Globals.cl_upspeed.value * KeyState(in_down); - - if ((in_klook.state & 1) == 0) { - cmd.forwardmove += Globals.cl_forwardspeed.value * KeyState(in_forward); - cmd.forwardmove -= Globals.cl_forwardspeed.value * KeyState(in_back); - } - - // - // adjust for speed key / running - // - if (((in_speed.state & 1) ^ (int) (Globals.cl_run.value)) != 0) { - cmd.forwardmove *= 2; - cmd.sidemove *= 2; - cmd.upmove *= 2; - } - - } - - static void ClampPitch() { - - float pitch; - - pitch = Math3D.SHORT2ANGLE(Globals.cl.frame.playerstate.pmove.delta_angles[Defines.PITCH]); - if (pitch > 180) - pitch -= 360; - - if (Globals.cl.viewangles[Defines.PITCH] + pitch < -360) - Globals.cl.viewangles[Defines.PITCH] += 360; // wrapped - if (Globals.cl.viewangles[Defines.PITCH] + pitch > 360) - Globals.cl.viewangles[Defines.PITCH] -= 360; // wrapped - - if (Globals.cl.viewangles[Defines.PITCH] + pitch > 89) - Globals.cl.viewangles[Defines.PITCH] = 89 - pitch; - if (Globals.cl.viewangles[Defines.PITCH] + pitch < -89) - Globals.cl.viewangles[Defines.PITCH] = -89 - pitch; - } - - /* - * ============== CL_FinishMove ============== - */ - static void FinishMove(usercmd_t cmd) { - int ms; - int i; - - // - // figure button bits - // - if ((in_attack.state & 3) != 0) - cmd.buttons |= Defines.BUTTON_ATTACK; - in_attack.state &= ~2; - - if ((in_use.state & 3) != 0) - cmd.buttons |= Defines.BUTTON_USE; - in_use.state &= ~2; - - if (Key.anykeydown != 0 && Globals.cls.key_dest == Defines.key_game) - cmd.buttons |= Defines.BUTTON_ANY; - - // send milliseconds of time to apply the move - ms = (int) (Globals.cls.frametime * 1000); - if (ms > 250) - ms = 100; // time was unreasonable - cmd.msec = (byte) ms; - - ClampPitch(); - for (i = 0; i < 3; i++) - cmd.angles[i] = (short) Math3D.ANGLE2SHORT(Globals.cl.viewangles[i]); - - cmd.impulse = (byte) in_impulse; - in_impulse = 0; - - // send the ambient light level at the player's current position - cmd.lightlevel = (byte) Globals.cl_lightlevel.value; - } - - /* - * ================= CL_CreateCmd ================= - */ - static void CreateCmd(usercmd_t cmd) { - //usercmd_t cmd = new usercmd_t(); - - frame_msec = Globals.sys_frame_time - old_sys_frame_time; - if (frame_msec < 1) - frame_msec = 1; - if (frame_msec > 200) - frame_msec = 200; - - // get basic movement from keyboard - BaseMove(cmd); - - // allow mice or other external controllers to add to the move - IN.Move(cmd); - - FinishMove(cmd); - - old_sys_frame_time = Globals.sys_frame_time; - - //return cmd; - } - - /* - * ============ CL_InitInput ============ - */ - static void InitInput() { - Cmd.AddCommand("centerview", IN::CenterView); - Cmd.AddCommand("+moveup", CL_input::IN_UpDown); - Cmd.AddCommand("-moveup", CL_input::IN_UpUp); - Cmd.AddCommand("+movedown", CL_input::IN_DownDown); - Cmd.AddCommand("-movedown", CL_input::IN_DownUp); - Cmd.AddCommand("+left", CL_input::IN_LeftDown); - Cmd.AddCommand("-left", CL_input::IN_LeftUp); - Cmd.AddCommand("+right", CL_input::IN_RightDown); - Cmd.AddCommand("-right", CL_input::IN_RightUp); - Cmd.AddCommand("+forward", CL_input::IN_ForwardDown); - Cmd.AddCommand("-forward", CL_input::IN_ForwardUp); - Cmd.AddCommand("+back", CL_input::IN_BackDown); - Cmd.AddCommand("-back", CL_input::IN_BackUp); - Cmd.AddCommand("+lookup", CL_input::IN_LookupDown); - Cmd.AddCommand("-lookup", CL_input::IN_LookupUp); - Cmd.AddCommand("+lookdown", CL_input::IN_LookdownDown); - Cmd.AddCommand("-lookdown", CL_input::IN_LookdownUp); - Cmd.AddCommand("+strafe", CL_input::IN_StrafeDown); - Cmd.AddCommand("-strafe", CL_input::IN_StrafeUp); - Cmd.AddCommand("+moveleft", CL_input::IN_MoveleftDown); - Cmd.AddCommand("-moveleft", CL_input::IN_MoveleftUp); - Cmd.AddCommand("+moveright", CL_input::IN_MoverightDown); - Cmd.AddCommand("-moveright", CL_input::IN_MoverightUp); - Cmd.AddCommand("+speed", CL_input::IN_SpeedDown); - Cmd.AddCommand("-speed", CL_input::IN_SpeedUp); - Cmd.AddCommand("+attack", CL_input::IN_AttackDown); - Cmd.AddCommand("-attack", CL_input::IN_AttackUp); - Cmd.AddCommand("+use", CL_input::IN_UseDown); - Cmd.AddCommand("-use", CL_input::IN_UseUp); - Cmd.AddCommand("impulse", CL_input::IN_Impulse); - Cmd.AddCommand("+klook", CL_input::IN_KLookDown); - Cmd.AddCommand("-klook", CL_input::IN_KLookUp); - - cl_nodelta = Cvar.Get("cl_nodelta", "0", 0); - } - - private static final sizebuf_t buf = new sizebuf_t(); - private static final byte[] data = new byte[128]; - private static final usercmd_t nullcmd = new usercmd_t(); - /* - * ================= CL_SendCmd ================= - */ - static void SendCmd() { - int i; - usercmd_t cmd, oldcmd; - int checksumIndex; - - // build a command even if not connected - - // save this command off for prediction - i = Globals.cls.netchan.outgoing_sequence & (Defines.CMD_BACKUP - 1); - cmd = Globals.cl.cmds[i]; - Globals.cl.cmd_time[i] = (int) Globals.cls.realtime; // for netgraph - // ping calculation - - // fill the cmd - CreateCmd(cmd); - - Globals.cl.cmd.set(cmd); - - if (Globals.cls.state == Defines.ca_disconnected || Globals.cls.state == Defines.ca_connecting) - return; - - if (Globals.cls.state == Defines.ca_connected) { - if (Globals.cls.netchan.message.cursize != 0 || Globals.curtime - Globals.cls.netchan.last_sent > 1000) - Netchan.Transmit(Globals.cls.netchan, 0, new byte[0]); - return; - } - - // send a userinfo update if needed - if (Globals.userinfo_modified) { - CL.FixUpGender(); - Globals.userinfo_modified = false; - MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_userinfo); - MSG.WriteString(Globals.cls.netchan.message, Cvar.Userinfo()); - } - - SZ.Init(buf, data, data.length); - - if (cmd.buttons != 0 && Globals.cl.cinematictime > 0 && !Globals.cl.attractloop - && Globals.cls.realtime - Globals.cl.cinematictime > 1000) { // skip - // the - // rest - // of - // the - // cinematic - SCR.FinishCinematic(); - } - - // begin a client move command - MSG.WriteByte(buf, Defines.clc_move); - - // save the position for a checksum byte - checksumIndex = buf.cursize; - MSG.WriteByte(buf, 0); - - // let the server know what the last frame we - // got was, so the next message can be delta compressed - if (cl_nodelta.value != 0.0f || !Globals.cl.frame.valid || Globals.cls.demowaiting) - MSG.WriteLong(buf, -1); // no compression - else - MSG.WriteLong(buf, Globals.cl.frame.serverframe); - - // send this and the previous cmds in the message, so - // if the last packet was dropped, it can be recovered - i = (Globals.cls.netchan.outgoing_sequence - 2) & (Defines.CMD_BACKUP - 1); - cmd = Globals.cl.cmds[i]; - //memset (nullcmd, 0, sizeof(nullcmd)); - nullcmd.clear(); - - MSG.WriteDeltaUsercmd(buf, nullcmd, cmd); - oldcmd = cmd; - - i = (Globals.cls.netchan.outgoing_sequence - 1) & (Defines.CMD_BACKUP - 1); - cmd = Globals.cl.cmds[i]; - - MSG.WriteDeltaUsercmd(buf, oldcmd, cmd); - oldcmd = cmd; - - i = (Globals.cls.netchan.outgoing_sequence) & (Defines.CMD_BACKUP - 1); - cmd = Globals.cl.cmds[i]; - - MSG.WriteDeltaUsercmd(buf, oldcmd, cmd); - - // calculate a checksum over the move commands - buf.data[checksumIndex] = Com.BlockSequenceCRCByte(buf.data, checksumIndex + 1, buf.cursize - checksumIndex - 1, - Globals.cls.netchan.outgoing_sequence); - - // - // deliver the message - // - Netchan.Transmit(Globals.cls.netchan, buf.cursize, buf.data); - } + static void IN_UpDown() { + KeyDown(in_up); + } + + static void IN_UpUp() { + KeyUp(in_up); + } + + static void IN_DownDown() { + KeyDown(in_down); + } + + static void IN_DownUp() { + KeyUp(in_down); + } + + static void IN_LeftDown() { + KeyDown(in_left); + } + + static void IN_LeftUp() { + KeyUp(in_left); + } + + static void IN_RightDown() { + KeyDown(in_right); + } + + static void IN_RightUp() { + KeyUp(in_right); + } + + static void IN_ForwardDown() { + KeyDown(in_forward); + } + + static void IN_ForwardUp() { + KeyUp(in_forward); + } + + static void IN_BackDown() { + KeyDown(in_back); + } + + static void IN_BackUp() { + KeyUp(in_back); + } + + static void IN_LookupDown() { + KeyDown(in_lookup); + } + + static void IN_LookupUp() { + KeyUp(in_lookup); + } + + static void IN_LookdownDown() { + KeyDown(in_lookdown); + } + + static void IN_LookdownUp() { + KeyUp(in_lookdown); + } + + static void IN_MoveleftDown() { + KeyDown(in_moveleft); + } + + static void IN_MoveleftUp() { + KeyUp(in_moveleft); + } + + static void IN_MoverightDown() { + KeyDown(in_moveright); + } + + static void IN_MoverightUp() { + KeyUp(in_moveright); + } + + static void IN_SpeedDown() { + KeyDown(in_speed); + } + + static void IN_SpeedUp() { + KeyUp(in_speed); + } + + static void IN_StrafeDown() { + KeyDown(in_strafe); + } + + static void IN_StrafeUp() { + KeyUp(in_strafe); + } + + static void IN_AttackDown() { + KeyDown(in_attack); + } + + static void IN_AttackUp() { + KeyUp(in_attack); + } + + static void IN_UseDown() { + KeyDown(in_use); + } + + static void IN_UseUp() { + KeyUp(in_use); + } + + static void IN_Impulse() { + in_impulse = Lib.atoi(Cmd.Argv(1)); + } + + /* + * =============== CL_KeyState + * + * Returns the fraction of the frame that the key was down =============== + */ + static float KeyState(kbutton_t key) { + float val; + long msec; + + key.state &= 1; // clear impulses + + msec = key.msec; + key.msec = 0; + + if (key.state != 0) { + // still down + msec += Globals.sys_frame_time - key.downtime; + key.downtime = Globals.sys_frame_time; + } + + val = (float) msec / frame_msec; + if (val < 0) + val = 0; + if (val > 1) + val = 1; + + return val; + } + + // ========================================================================== + + /* + * ================ CL_AdjustAngles + * + * Moves the local angle positions ================ + */ + static void AdjustAngles() { + float speed; + float up, down; + + if ((in_speed.state & 1) != 0) + speed = Globals.cls.frametime * Globals.cl_anglespeedkey.value; + else + speed = Globals.cls.frametime; + + if ((in_strafe.state & 1) == 0) { + Globals.cl.viewangles[Defines.YAW] -= speed * Globals.cl_yawspeed.value * KeyState(in_right); + Globals.cl.viewangles[Defines.YAW] += speed * Globals.cl_yawspeed.value * KeyState(in_left); + } + if ((in_klook.state & 1) != 0) { + Globals.cl.viewangles[Defines.PITCH] -= speed * Globals.cl_pitchspeed.value * KeyState(in_forward); + Globals.cl.viewangles[Defines.PITCH] += speed * Globals.cl_pitchspeed.value * KeyState(in_back); + } + + up = KeyState(in_lookup); + down = KeyState(in_lookdown); + + Globals.cl.viewangles[Defines.PITCH] -= speed * Globals.cl_pitchspeed.value * up; + Globals.cl.viewangles[Defines.PITCH] += speed * Globals.cl_pitchspeed.value * down; + } + + /* + * ================ CL_BaseMove + * + * Send the intended movement message to the server ================ + */ + static void BaseMove(usercmd_t cmd) { + AdjustAngles(); + + //memset (cmd, 0, sizeof(*cmd)); + cmd.clear(); + + Math3D.VectorCopy(Globals.cl.viewangles, cmd.angles); + if ((in_strafe.state & 1) != 0) { + cmd.sidemove += Globals.cl_sidespeed.value * KeyState(in_right); + cmd.sidemove -= Globals.cl_sidespeed.value * KeyState(in_left); + } + + cmd.sidemove += Globals.cl_sidespeed.value * KeyState(in_moveright); + cmd.sidemove -= Globals.cl_sidespeed.value * KeyState(in_moveleft); + + cmd.upmove += Globals.cl_upspeed.value * KeyState(in_up); + cmd.upmove -= Globals.cl_upspeed.value * KeyState(in_down); + + if ((in_klook.state & 1) == 0) { + cmd.forwardmove += Globals.cl_forwardspeed.value * KeyState(in_forward); + cmd.forwardmove -= Globals.cl_forwardspeed.value * KeyState(in_back); + } + + // + // adjust for speed key / running + // + if (((in_speed.state & 1) ^ (int) (Globals.cl_run.value)) != 0) { + cmd.forwardmove *= 2; + cmd.sidemove *= 2; + cmd.upmove *= 2; + } + + } + + static void ClampPitch() { + + float pitch; + + pitch = Math3D.SHORT2ANGLE(Globals.cl.frame.playerstate.pmove.delta_angles[Defines.PITCH]); + if (pitch > 180) + pitch -= 360; + + if (Globals.cl.viewangles[Defines.PITCH] + pitch < -360) + Globals.cl.viewangles[Defines.PITCH] += 360; // wrapped + if (Globals.cl.viewangles[Defines.PITCH] + pitch > 360) + Globals.cl.viewangles[Defines.PITCH] -= 360; // wrapped + + if (Globals.cl.viewangles[Defines.PITCH] + pitch > 89) + Globals.cl.viewangles[Defines.PITCH] = 89 - pitch; + if (Globals.cl.viewangles[Defines.PITCH] + pitch < -89) + Globals.cl.viewangles[Defines.PITCH] = -89 - pitch; + } + + /* + * ============== CL_FinishMove ============== + */ + static void FinishMove(usercmd_t cmd) { + int ms; + int i; + + // + // figure button bits + // + if ((in_attack.state & 3) != 0) + cmd.buttons |= Defines.BUTTON_ATTACK; + in_attack.state &= ~2; + + if ((in_use.state & 3) != 0) + cmd.buttons |= Defines.BUTTON_USE; + in_use.state &= ~2; + + if (Key.anykeydown != 0 && Globals.cls.key_dest == Defines.key_game) + cmd.buttons |= Defines.BUTTON_ANY; + + // send milliseconds of time to apply the move + ms = (int) (Globals.cls.frametime * 1000); + if (ms > 250) + ms = 100; // time was unreasonable + cmd.msec = (byte) ms; + + ClampPitch(); + for (i = 0; i < 3; i++) + cmd.angles[i] = (short) Math3D.ANGLE2SHORT(Globals.cl.viewangles[i]); + + cmd.impulse = (byte) in_impulse; + in_impulse = 0; + + // send the ambient light level at the player's current position + cmd.lightlevel = (byte) Globals.cl_lightlevel.value; + } + + /* + * ================= CL_CreateCmd ================= + */ + static void CreateCmd(usercmd_t cmd) { + //usercmd_t cmd = new usercmd_t(); + + frame_msec = Globals.sys_frame_time - old_sys_frame_time; + if (frame_msec < 1) + frame_msec = 1; + if (frame_msec > 200) + frame_msec = 200; + + // get basic movement from keyboard + BaseMove(cmd); + + // allow mice or other external controllers to add to the move + IN.Move(cmd); + + FinishMove(cmd); + + old_sys_frame_time = Globals.sys_frame_time; + + //return cmd; + } + + /* + * ============ CL_InitInput ============ + */ + static void InitInput() { + Cmd.AddCommand("centerview", IN::CenterView); + Cmd.AddCommand("+moveup", CL_input::IN_UpDown); + Cmd.AddCommand("-moveup", CL_input::IN_UpUp); + Cmd.AddCommand("+movedown", CL_input::IN_DownDown); + Cmd.AddCommand("-movedown", CL_input::IN_DownUp); + Cmd.AddCommand("+left", CL_input::IN_LeftDown); + Cmd.AddCommand("-left", CL_input::IN_LeftUp); + Cmd.AddCommand("+right", CL_input::IN_RightDown); + Cmd.AddCommand("-right", CL_input::IN_RightUp); + Cmd.AddCommand("+forward", CL_input::IN_ForwardDown); + Cmd.AddCommand("-forward", CL_input::IN_ForwardUp); + Cmd.AddCommand("+back", CL_input::IN_BackDown); + Cmd.AddCommand("-back", CL_input::IN_BackUp); + Cmd.AddCommand("+lookup", CL_input::IN_LookupDown); + Cmd.AddCommand("-lookup", CL_input::IN_LookupUp); + Cmd.AddCommand("+lookdown", CL_input::IN_LookdownDown); + Cmd.AddCommand("-lookdown", CL_input::IN_LookdownUp); + Cmd.AddCommand("+strafe", CL_input::IN_StrafeDown); + Cmd.AddCommand("-strafe", CL_input::IN_StrafeUp); + Cmd.AddCommand("+moveleft", CL_input::IN_MoveleftDown); + Cmd.AddCommand("-moveleft", CL_input::IN_MoveleftUp); + Cmd.AddCommand("+moveright", CL_input::IN_MoverightDown); + Cmd.AddCommand("-moveright", CL_input::IN_MoverightUp); + Cmd.AddCommand("+speed", CL_input::IN_SpeedDown); + Cmd.AddCommand("-speed", CL_input::IN_SpeedUp); + Cmd.AddCommand("+attack", CL_input::IN_AttackDown); + Cmd.AddCommand("-attack", CL_input::IN_AttackUp); + Cmd.AddCommand("+use", CL_input::IN_UseDown); + Cmd.AddCommand("-use", CL_input::IN_UseUp); + Cmd.AddCommand("impulse", CL_input::IN_Impulse); + Cmd.AddCommand("+klook", CL_input::IN_KLookDown); + Cmd.AddCommand("-klook", CL_input::IN_KLookUp); + + cl_nodelta = Cvar.Get("cl_nodelta", "0", 0); + } + + private static final sizebuf_t buf = new sizebuf_t(); + private static final byte[] data = new byte[128]; + private static final usercmd_t nullcmd = new usercmd_t(); + /* + * ================= CL_SendCmd ================= + */ + static void SendCmd() { + int i; + usercmd_t cmd, oldcmd; + int checksumIndex; + + // build a command even if not connected + + // save this command off for prediction + i = Globals.cls.netchan.outgoing_sequence & (Defines.CMD_BACKUP - 1); + cmd = Globals.cl.cmds[i]; + Globals.cl.cmd_time[i] = (int) Globals.cls.realtime; // for netgraph + // ping calculation + + // fill the cmd + CreateCmd(cmd); + + Globals.cl.cmd.set(cmd); + + if (Globals.cls.state == Defines.ca_disconnected || Globals.cls.state == Defines.ca_connecting) + return; + + if (Globals.cls.state == Defines.ca_connected) { + if (Globals.cls.netchan.message.cursize != 0 || Globals.curtime - Globals.cls.netchan.last_sent > 1000) + Netchan.Transmit(Globals.cls.netchan, 0, new byte[0]); + return; + } + + // send a userinfo update if needed + if (Globals.userinfo_modified) { + CL.FixUpGender(); + Globals.userinfo_modified = false; + MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_userinfo); + MSG.WriteString(Globals.cls.netchan.message, Cvar.Userinfo()); + } + + SZ.Init(buf, data, data.length); + + if (cmd.buttons != 0 && Globals.cl.cinematictime > 0 && !Globals.cl.attractloop + && Globals.cls.realtime - Globals.cl.cinematictime > 1000) { // skip + // the + // rest + // of + // the + // cinematic + SCR.FinishCinematic(); + } + + // begin a client move command + MSG.WriteByte(buf, Defines.clc_move); + + // save the position for a checksum byte + checksumIndex = buf.cursize; + MSG.WriteByte(buf, 0); + + // let the server know what the last frame we + // got was, so the next message can be delta compressed + if (cl_nodelta.value != 0.0f || !Globals.cl.frame.valid || Globals.cls.demowaiting) + MSG.WriteLong(buf, -1); // no compression + else + MSG.WriteLong(buf, Globals.cl.frame.serverframe); + + // send this and the previous cmds in the message, so + // if the last packet was dropped, it can be recovered + i = (Globals.cls.netchan.outgoing_sequence - 2) & (Defines.CMD_BACKUP - 1); + cmd = Globals.cl.cmds[i]; + //memset (nullcmd, 0, sizeof(nullcmd)); + nullcmd.clear(); + + MSG.WriteDeltaUsercmd(buf, nullcmd, cmd); + oldcmd = cmd; + + i = (Globals.cls.netchan.outgoing_sequence - 1) & (Defines.CMD_BACKUP - 1); + cmd = Globals.cl.cmds[i]; + + MSG.WriteDeltaUsercmd(buf, oldcmd, cmd); + oldcmd = cmd; + + i = (Globals.cls.netchan.outgoing_sequence) & (Defines.CMD_BACKUP - 1); + cmd = Globals.cl.cmds[i]; + + MSG.WriteDeltaUsercmd(buf, oldcmd, cmd); + + // calculate a checksum over the move commands + buf.data[checksumIndex] = Com.BlockSequenceCRCByte(buf.data, checksumIndex + 1, buf.cursize - checksumIndex - 1, + Globals.cls.netchan.outgoing_sequence); + + // + // deliver the message + // + Netchan.Transmit(Globals.cls.netchan, buf.cursize, buf.data); + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/client/CL_inv.java b/src/main/java/lwjake2/client/CL_inv.java index 989b871..5dcf48b 100644 --- a/src/main/java/lwjake2/client/CL_inv.java +++ b/src/main/java/lwjake2/client/CL_inv.java @@ -30,108 +30,108 @@ import lwjake2.util.Vargs; */ public class CL_inv { - /* - * ================ CL_ParseInventory ================ - */ - static void ParseInventory() { - int i; + /* + * ================ CL_ParseInventory ================ + */ + static void ParseInventory() { + int i; - for (i = 0; i < Defines.MAX_ITEMS; i++) - Globals.cl.inventory[i] = MSG.ReadShort(Globals.net_message); - } + for (i = 0; i < Defines.MAX_ITEMS; i++) + Globals.cl.inventory[i] = MSG.ReadShort(Globals.net_message); + } - /* - * ================ Inv_DrawString ================ - */ - static void Inv_DrawString(int x, int y, String string) { - for (int i = 0; i < string.length(); i++) { - Globals.re.DrawChar(x, y, string.charAt(i)); - x += 8; - } - } + /* + * ================ Inv_DrawString ================ + */ + static void Inv_DrawString(int x, int y, String string) { + for (int i = 0; i < string.length(); i++) { + Globals.re.DrawChar(x, y, string.charAt(i)); + x += 8; + } + } - static String getHighBitString(String s) { - byte[] b = Lib.stringToBytes(s); - for (int i = 0; i < b.length; i++) { - b[i] = (byte) (b[i] | 128); - } - return Lib.bytesToString(b); - } + static String getHighBitString(String s) { + byte[] b = Lib.stringToBytes(s); + for (int i = 0; i < b.length; i++) { + b[i] = (byte) (b[i] | 128); + } + return Lib.bytesToString(b); + } - /* - * ================ CL_DrawInventory ================ - */ - static final int DISPLAY_ITEMS = 17; + /* + * ================ CL_DrawInventory ================ + */ + static final int DISPLAY_ITEMS = 17; - static void DrawInventory() { - int i, j; - int num, selected_num, item; - int[] index = new int[Defines.MAX_ITEMS]; - String string; - int x, y; - String binding; - String bind; - int selected; - int top; + static void DrawInventory() { + int i, j; + int num, selected_num, item; + int[] index = new int[Defines.MAX_ITEMS]; + String string; + int x, y; + String binding; + String bind; + int selected; + int top; - selected = Globals.cl.frame.playerstate.stats[Defines.STAT_SELECTED_ITEM]; + selected = Globals.cl.frame.playerstate.stats[Defines.STAT_SELECTED_ITEM]; - num = 0; - selected_num = 0; - for (i = 0; i < Defines.MAX_ITEMS; i++) { - if (i == selected) - selected_num = num; - if (Globals.cl.inventory[i] != 0) { - index[num] = i; - num++; - } - } + num = 0; + selected_num = 0; + for (i = 0; i < Defines.MAX_ITEMS; i++) { + if (i == selected) + selected_num = num; + if (Globals.cl.inventory[i] != 0) { + index[num] = i; + num++; + } + } - // determine scroll point - top = selected_num - DISPLAY_ITEMS / 2; - if (num - top < DISPLAY_ITEMS) - top = num - DISPLAY_ITEMS; - if (top < 0) - top = 0; + // determine scroll point + top = selected_num - DISPLAY_ITEMS / 2; + if (num - top < DISPLAY_ITEMS) + top = num - DISPLAY_ITEMS; + if (top < 0) + top = 0; - x = (Globals.viddef.width - 256) / 2; - y = (Globals.viddef.height - 240) / 2; + x = (Globals.viddef.width - 256) / 2; + y = (Globals.viddef.height - 240) / 2; - // repaint everything next frame - SCR.DirtyScreen(); + // repaint everything next frame + SCR.DirtyScreen(); - Globals.re.DrawPic(x, y + 8, "inventory"); + Globals.re.DrawPic(x, y + 8, "inventory"); - y += 24; - x += 24; - Inv_DrawString(x, y, "hotkey ### item"); - Inv_DrawString(x, y + 8, "------ --- ----"); - y += 16; - for (i = top; i < num && i < top + DISPLAY_ITEMS; i++) { - item = index[i]; - // search for a binding - //Com_sprintf (binding, sizeof(binding), "use %s", - // cl.configstrings[CS_ITEMS+item]); - binding = "use " + Globals.cl.configstrings[Defines.CS_ITEMS + item]; - bind = ""; - for (j = 0; j < 256; j++) - if (Globals.keybindings[j] != null && Globals.keybindings[j].equals(binding)) { - bind = Key.KeynumToString(j); - break; - } + y += 24; + x += 24; + Inv_DrawString(x, y, "hotkey ### item"); + Inv_DrawString(x, y + 8, "------ --- ----"); + y += 16; + for (i = top; i < num && i < top + DISPLAY_ITEMS; i++) { + item = index[i]; + // search for a binding + //Com_sprintf (binding, sizeof(binding), "use %s", + // cl.configstrings[CS_ITEMS+item]); + binding = "use " + Globals.cl.configstrings[Defines.CS_ITEMS + item]; + bind = ""; + for (j = 0; j < 256; j++) + if (Globals.keybindings[j] != null && Globals.keybindings[j].equals(binding)) { + bind = Key.KeynumToString(j); + break; + } - string = Com.sprintf("%6s %3i %s", new Vargs(3).add(bind).add(Globals.cl.inventory[item]).add( - Globals.cl.configstrings[Defines.CS_ITEMS + item])); - if (item != selected) - string = getHighBitString(string); - else // draw a blinky cursor by the selected item - { - if (((int) (Globals.cls.realtime * 10) & 1) != 0) - Globals.re.DrawChar(x - 8, y, 15); - } - Inv_DrawString(x, y, string); - y += 8; - } + string = Com.sprintf("%6s %3i %s", new Vargs(3).add(bind).add(Globals.cl.inventory[item]).add( + Globals.cl.configstrings[Defines.CS_ITEMS + item])); + if (item != selected) + string = getHighBitString(string); + else // draw a blinky cursor by the selected item + { + if (((int) (Globals.cls.realtime * 10) & 1) != 0) + Globals.re.DrawChar(x - 8, y, 15); + } + Inv_DrawString(x, y, string); + y += 8; + } - } + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/client/CL_newfx.java b/src/main/java/lwjake2/client/CL_newfx.java index cb7c776..77986a8 100644 --- a/src/main/java/lwjake2/client/CL_newfx.java +++ b/src/main/java/lwjake2/client/CL_newfx.java @@ -66,22 +66,22 @@ public class CL_newfx { dl.color[2] = b; } - // stack variable - private static final float[] move = {0, 0, 0}; - private static final float[] vec = {0, 0, 0}; - private static final float[] right = {0, 0, 0}; - private static final float[] up = {0, 0, 0}; + // stack variable + private static final float[] move = {0, 0, 0}; + private static final float[] vec = {0, 0, 0}; + private static final float[] right = {0, 0, 0}; + private static final float[] up = {0, 0, 0}; /* * ====== CL_DebugTrail ====== */ static void DebugTrail(float[] start, float[] end) { float len; - // int j; + // int j; cparticle_t p; float dec; - // int i; - // float d, c, s; - // float[] dir; + // int i; + // float d, c, s; + // float[] dir; Math3D.VectorCopy(start, move); Math3D.VectorSubtract(end, start, vec); @@ -89,10 +89,10 @@ public class CL_newfx { Math3D.MakeNormalVectors(vec, right, up); - // VectorScale(vec, RT2_SKIP, vec); + // VectorScale(vec, RT2_SKIP, vec); - // dec = 1.0; - // dec = 0.75; + // dec = 1.0; + // dec = 0.75; dec = 3; Math3D.VectorScale(vec, dec, vec); Math3D.VectorCopy(start, move); @@ -112,7 +112,7 @@ public class CL_newfx { Math3D.VectorClear(p.vel); p.alpha = 1.0f; p.alphavel = -0.1f; - // p.alphavel = 0; + // p.alphavel = 0; p.color = 0x74 + (Lib.rand() & 7); Math3D.VectorCopy(move, p.org); /* @@ -124,7 +124,7 @@ public class CL_newfx { } - // stack variable + // stack variable // move, vec static void ForceWall(float[] start, float[] end, int color) { float len; @@ -169,7 +169,7 @@ public class CL_newfx { } } - // stack variable + // stack variable // move, vec /* * =============== CL_BubbleTrail2 (lets you control the # of bubbles by @@ -210,14 +210,14 @@ public class CL_newfx { p.vel[j] = Lib.crand() * 10; } p.org[2] -= 4; - // p.vel[2] += 6; + // p.vel[2] += 6; p.vel[2] += 20; Math3D.VectorAdd(move, vec, move); } } - // stack variable + // stack variable // move, vec, right, up private static final float[] dir = {0, 0, 0}; private static final float[] end = {0, 0, 0}; @@ -241,7 +241,7 @@ public class CL_newfx { len = Math3D.VectorNormalize(vec); // FIXME - pmm - these might end up using old values? - // MakeNormalVectors (vec, right, up); + // MakeNormalVectors (vec, right, up); Math3D.VectorCopy(Globals.cl.v_right, right); Math3D.VectorCopy(Globals.cl.v_up, up); if (Globals.vidref_val == Defines.VIDREF_GL) { // GL mode @@ -256,7 +256,7 @@ public class CL_newfx { Math3D.VectorScale(vec, step, vec); - // Com_Printf ("%f\n", ltime); + // Com_Printf ("%f\n", ltime); rstep = (float) (Math.PI / 10.0); float M_PI2 = (float) (Math.PI * 2.0); for (i = (int) start_pt; i < len; i += step) { @@ -275,10 +275,10 @@ public class CL_newfx { p.time = Globals.cl.time; Math3D.VectorClear(p.accel); - // rot+= fmod(ltime, 12.0)*M_PI; - // c = cos(rot)/2.0; - // s = sin(rot)/2.0; - // variance = 0.4 + ((float)rand()/(float)RAND_MAX) *0.2; + // rot+= fmod(ltime, 12.0)*M_PI; + // c = cos(rot)/2.0; + // s = sin(rot)/2.0; + // variance = 0.4 + ((float)rand()/(float)RAND_MAX) *0.2; variance = 0.5f; c = (float) (Math.cos(rot) * variance); s = (float) (Math.sin(rot) * variance); @@ -293,13 +293,13 @@ public class CL_newfx { } p.alpha = 0.5f; - // p.alphavel = -1.0 / (1+frand()*0.2); + // p.alphavel = -1.0 / (1+frand()*0.2); p.alphavel = -1000.0f; - // p.color = 0x74 + (rand()&7); + // p.color = 0x74 + (rand()&7); p.color = 223 - (Lib.rand() & 7); for (j = 0; j < 3; j++) { p.org[j] = move[j] + dir[j] * 3; - // p.vel[j] = dir[j]*6; + // p.vel[j] = dir[j]*6; p.vel[j] = 0; } } @@ -307,7 +307,7 @@ public class CL_newfx { } } - // stack variable + // stack variable private static final float[] r = {0, 0, 0}; private static final float[] u = {0, 0, 0}; /* @@ -322,8 +322,8 @@ public class CL_newfx { cparticle_t p; float d; - // vectoangles2 (dir, angle_dir); - // AngleVectors (angle_dir, f, r, u); + // vectoangles2 (dir, angle_dir); + // AngleVectors (angle_dir, f, r, u); Math3D.MakeNormalVectors(dir, r, u); @@ -340,7 +340,7 @@ public class CL_newfx { for (j = 0; j < 3; j++) { p.org[j] = org[j] + magnitude * 0.1f * Lib.crand(); - // p.vel[j] = dir[j]*magnitude; + // p.vel[j] = dir[j]*magnitude; } Math3D.VectorScale(dir, magnitude, p.vel); d = Lib.crand() * magnitude / 3; @@ -356,17 +356,17 @@ public class CL_newfx { } } - // stack variable + // stack variable // r, u, dir static void ParticleSteamEffect2(cl_sustain_t self) - // float[] org, float[] dir, int color, int count, int magnitude) + // float[] org, float[] dir, int color, int count, int magnitude) { int i, j; cparticle_t p; float d; - // vectoangles2 (dir, angle_dir); - // AngleVectors (angle_dir, f, r, u); + // vectoangles2 (dir, angle_dir); + // AngleVectors (angle_dir, f, r, u); Math3D.VectorCopy(self.dir, dir); Math3D.MakeNormalVectors(dir, r, u); @@ -384,7 +384,7 @@ public class CL_newfx { for (j = 0; j < 3; j++) { p.org[j] = self.org[j] + self.magnitude * 0.1f * Lib.crand(); - // p.vel[j] = dir[j]*magnitude; + // p.vel[j] = dir[j]*magnitude; } Math3D.VectorScale(dir, self.magnitude, p.vel); d = Lib.crand() * self.magnitude / 3; @@ -401,7 +401,7 @@ public class CL_newfx { self.nextthink += self.thinkinterval; } - // stack variable + // stack variable // move, vec, right, up private static final float[] forward = {0, 0, 0}; private static final float[] angle_dir = {0, 0, 0}; @@ -509,7 +509,7 @@ public class CL_newfx { Math3D.VectorNormalize(dir); Math3D.VectorMA(origin, 10, dir, p.org); - // VectorMA(origin, 10*(((rand () & 0x7fff) / ((float)0x7fff))), + // VectorMA(origin, 10*(((rand () & 0x7fff) / ((float)0x7fff))), // dir, p.org); } } @@ -547,7 +547,7 @@ public class CL_newfx { Math3D.VectorNormalize(dir); Math3D.VectorMA(self.org, (45.0f * ratio), dir, p.org); - // VectorMA(origin, 10*(((rand () & 0x7fff) / ((float)0x7fff))), + // VectorMA(origin, 10*(((rand () & 0x7fff) / ((float)0x7fff))), // dir, p.org); } } @@ -585,7 +585,7 @@ public class CL_newfx { Math3D.VectorNormalize(dir); Math3D.VectorMA(self.org, (200.0f * ratio), dir, p.org); - // VectorMA(origin, 10*(((rand () & 0x7fff) / ((float)0x7fff))), + // VectorMA(origin, 10*(((rand () & 0x7fff) / ((float)0x7fff))), // dir, p.org); } } @@ -728,7 +728,7 @@ public class CL_newfx { for (j = 0; j < 3; j++) { p.org[j] = org[j] + magnitude * 0.1f * Lib.crand(); - // p.vel[j] = dir[j]*magnitude; + // p.vel[j] = dir[j]*magnitude; } Math3D.VectorScale(dir, magnitude, p.vel); d = Lib.crand() * magnitude / 3; diff --git a/src/main/java/lwjake2/client/CL_parse.java b/src/main/java/lwjake2/client/CL_parse.java index 2c04213..8fedaa0 100644 --- a/src/main/java/lwjake2/client/CL_parse.java +++ b/src/main/java/lwjake2/client/CL_parse.java @@ -56,7 +56,7 @@ public class CL_parse { "svc_download", "svc_playerinfo", "svc_packetentities", "svc_deltapacketentities", "svc_frame" }; - // ============================================================================= + // ============================================================================= public static String DownloadFileName(String fn) { return fileSystem.getGamedir() + "/" + fn; @@ -90,7 +90,7 @@ public class CL_parse { .StripExtension(Globals.cls.downloadname); Globals.cls.downloadtempname += ".tmp"; - // ZOID + // ZOID // check to see if we already have a tmp for this file, if so, try to // resume // open the file if not opened yet @@ -245,7 +245,7 @@ public class CL_parse { if (percent != 100) { // request next block - // change display routines by zoid + // change display routines by zoid Globals.cls.downloadpercent = percent; MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_stringcmd); SZ.Print(Globals.cls.netchan.message, "nextdl"); @@ -254,7 +254,7 @@ public class CL_parse { //char oldn[MAX_OSPATH]; //char newn[MAX_OSPATH]; - // Com.Printf ("100%%\n"); + // Com.Printf ("100%%\n"); try { Globals.cls.download.close(); @@ -296,12 +296,12 @@ public class CL_parse { Com.DPrintf("ParseServerData():Serverdata packet received.\n"); // - // wipe the client_state_t struct + // wipe the client_state_t struct // CL.ClearState(); Globals.cls.state = Defines.ca_connected; - // parse protocol version number + // parse protocol version number i = MSG.ReadLong(Globals.net_message); Globals.cls.serverProtocol = i; @@ -340,9 +340,9 @@ public class CL_parse { SCR.PlayCinematic(str); } else { // seperate the printfs so the server message can have a color - // Com.Printf( - // "\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"); - // Com.Printf('\02' + str + "\n"); + // Com.Printf( + // "\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"); + // Com.Printf('\02' + str + "\n"); Com.Printf("Levelname:" + str + "\n"); // need to prep refresh at next oportunity Globals.cl.refresh_prepped = false; @@ -648,7 +648,7 @@ public class CL_parse { int i; // - // if recording demos, copy the message out + // if recording demos, copy the message out // //if (cl_shownet.value == 1) //Com.Printf(net_message.cursize + " "); @@ -656,7 +656,7 @@ public class CL_parse { //Com.Printf("------------------\n"); // - // parse the message + // parse the message // while (true) { if (Globals.net_message.readcount > Globals.net_message.cursize) { @@ -688,7 +688,7 @@ public class CL_parse { break; case Defines.svc_nop: - // Com.Printf ("svc_nop\n"); + // Com.Printf ("svc_nop\n"); break; case Defines.svc_disconnect: diff --git a/src/main/java/lwjake2/client/CL_tent.java b/src/main/java/lwjake2/client/CL_tent.java index 9dac910..df9701d 100644 --- a/src/main/java/lwjake2/client/CL_tent.java +++ b/src/main/java/lwjake2/client/CL_tent.java @@ -63,7 +63,7 @@ public class CL_tent { static beam_t[] cl_beams = new beam_t[MAX_BEAMS]; - // PMM - added this for player-linked beams. Currently only used by the + // PMM - added this for player-linked beams. Currently only used by the // plasma beam static beam_t[] cl_playerbeams = new beam_t[MAX_BEAMS]; @@ -71,7 +71,7 @@ public class CL_tent { static laser_t[] cl_lasers = new laser_t[MAX_LASERS]; - // ROGUE + // ROGUE static final int MAX_SUSTAINS = 32; static cl_sustain_t[] cl_sustains = new cl_sustain_t[MAX_SUSTAINS]; @@ -143,7 +143,7 @@ public class CL_tent { static final int ex_poly2 = 6; - // ROGUE + // ROGUE // all are references; static sfx_t cl_sfx_ric1; @@ -191,10 +191,10 @@ public class CL_tent { static model_t cl_mod_powerscreen; - // RAFAEL + // RAFAEL static model_t cl_mod_plasmaexplo; - // ROGUE + // ROGUE static sfx_t cl_sfx_lightning; static sfx_t cl_sfx_disrexp; @@ -207,7 +207,7 @@ public class CL_tent { static model_t cl_mod_explo4_big; - // ROGUE + // ROGUE /* * ================= CL_RegisterTEntSounds ================= */ @@ -216,7 +216,7 @@ public class CL_tent { String name; // PMM - version stuff - // Com_Printf ("%s\n", ROGUE_VERSION_STRING); + // Com_Printf ("%s\n", ROGUE_VERSION_STRING); // PMM cl_sfx_ric1 = S.RegisterSound("world/ric1.wav"); cl_sfx_ric2 = S.RegisterSound("world/ric2.wav"); @@ -242,14 +242,14 @@ public class CL_tent { cl_sfx_footsteps[i] = S.RegisterSound(name); } - // PGM + // PGM cl_sfx_lightning = S.RegisterSound("weapons/tesla.wav"); cl_sfx_disrexp = S.RegisterSound("weapons/disrupthit.wav"); // version stuff - // sprintf (name, "weapons/sound%d.wav", ROGUE_VERSION_ID); - // if (name[0] == 'w') - // name[0] = 'W'; - // PGM + // sprintf (name, "weapons/sound%d.wav", ROGUE_VERSION_ID); + // if (name[0] == 'w') + // name[0] = 'W'; + // PGM } /* @@ -282,15 +282,15 @@ public class CL_tent { Globals.re.RegisterModel("models/objects/gibs/bone/tris.md2"); Globals.re.RegisterModel("models/objects/gibs/sm_meat/tris.md2"); Globals.re.RegisterModel("models/objects/gibs/bone2/tris.md2"); - // RAFAEL - // re.RegisterModel ("models/objects/blaser/tris.md2"); + // RAFAEL + // re.RegisterModel ("models/objects/blaser/tris.md2"); Globals.re.RegisterPic("w_machinegun"); Globals.re.RegisterPic("a_bullets"); Globals.re.RegisterPic("i_health"); Globals.re.RegisterPic("a_grenades"); - // ROGUE + // ROGUE cl_mod_explo4_big = Globals.re .RegisterModel("models/objects/r_explode2/tris.md2"); cl_mod_lightning = Globals.re @@ -298,31 +298,31 @@ public class CL_tent { cl_mod_heatbeam = Globals.re.RegisterModel("models/proj/beam/tris.md2"); cl_mod_monster_heatbeam = Globals.re .RegisterModel("models/proj/widowbeam/tris.md2"); - // ROGUE + // ROGUE } /* * ================= CL_ClearTEnts ================= */ static void ClearTEnts() { - // memset (cl_beams, 0, sizeof(cl_beams)); + // memset (cl_beams, 0, sizeof(cl_beams)); for (int i = 0; i < cl_beams.length; i++) cl_beams[i].clear(); - // memset (cl_explosions, 0, sizeof(cl_explosions)); + // memset (cl_explosions, 0, sizeof(cl_explosions)); for (int i = 0; i < cl_explosions.length; i++) cl_explosions[i].clear(); - // memset (cl_lasers, 0, sizeof(cl_lasers)); + // memset (cl_lasers, 0, sizeof(cl_lasers)); for (int i = 0; i < cl_lasers.length; i++) cl_lasers[i].clear(); // - // ROGUE - // memset (cl_playerbeams, 0, sizeof(cl_playerbeams)); + // ROGUE + // memset (cl_playerbeams, 0, sizeof(cl_playerbeams)); for (int i = 0; i < cl_playerbeams.length; i++) cl_playerbeams[i].clear(); - // memset (cl_sustains, 0, sizeof(cl_sustains)); + // memset (cl_sustains, 0, sizeof(cl_sustains)); for (int i = 0; i < cl_sustains.length; i++) cl_sustains[i].clear(); - // ROGUE + // ROGUE } /* @@ -340,7 +340,7 @@ public class CL_tent { return cl_explosions[i]; } } - // find the oldest explosion + // find the oldest explosion time = Globals.cl.time; index = 0; @@ -394,7 +394,7 @@ public class CL_tent { MSG.ReadPos(Globals.net_message, start); MSG.ReadPos(Globals.net_message, end); - // override any beam with the same entity + // override any beam with the same entity b = cl_beams; for (i = 0; i < MAX_BEAMS; i++) if (b[i].entity == ent) { @@ -407,7 +407,7 @@ public class CL_tent { return ent; } - // find a free beam + // find a free beam b = cl_beams; for (i = 0; i < MAX_BEAMS; i++) { if (b[i].model == null || b[i].endtime < Globals.cl.time) { @@ -441,9 +441,9 @@ public class CL_tent { MSG.ReadPos(Globals.net_message, end); MSG.ReadPos(Globals.net_message, offset); - // Com_Printf ("end- %f %f %f\n", end[0], end[1], end[2]); + // Com_Printf ("end- %f %f %f\n", end[0], end[1], end[2]); - // override any beam with the same entity + // override any beam with the same entity b = cl_beams; for (i = 0; i < MAX_BEAMS; i++) if (b[i].entity == ent) { @@ -456,7 +456,7 @@ public class CL_tent { return ent; } - // find a free beam + // find a free beam b = cl_beams; for (i = 0; i < MAX_BEAMS; i++) { if (b[i].model == null || b[i].endtime < Globals.cl.time) { @@ -473,7 +473,7 @@ public class CL_tent { return ent; } - // ROGUE + // ROGUE /* * ================= CL_ParsePlayerBeam - adds to the cl_playerbeam array * instead of the cl_beams array ================= @@ -499,10 +499,10 @@ public class CL_tent { } else MSG.ReadPos(Globals.net_message, offset); - // Com_Printf ("end- %f %f %f\n", end[0], end[1], end[2]); + // Com_Printf ("end- %f %f %f\n", end[0], end[1], end[2]); - // override any beam with the same entity - // PMM - For player beams, we only want one per player (entity) so.. + // override any beam with the same entity + // PMM - For player beams, we only want one per player (entity) so.. b = cl_playerbeams; for (i = 0; i < MAX_BEAMS; i++) { if (b[i].entity == ent) { @@ -516,7 +516,7 @@ public class CL_tent { } } - // find a free beam + // find a free beam b = cl_playerbeams; for (i = 0; i < MAX_BEAMS; i++) { if (b[i].model == null || b[i].endtime < Globals.cl.time) { @@ -535,7 +535,7 @@ public class CL_tent { return ent; } - // rogue + // rogue // stack variable private static final float[] start = new float[3]; @@ -554,11 +554,11 @@ public class CL_tent { MSG.ReadPos(Globals.net_message, start); MSG.ReadPos(Globals.net_message, end); - // override any beam with the same source AND destination entities + // override any beam with the same source AND destination entities b = cl_beams; for (i = 0; i < MAX_BEAMS; i++) if (b[i].entity == srcEnt && b[i].dest_entity == destEnt) { - // Com_Printf("%d: OVERRIDE %d . %d\n", cl.time, srcEnt, + // Com_Printf("%d: OVERRIDE %d . %d\n", cl.time, srcEnt, // destEnt); b[i].entity = srcEnt; b[i].dest_entity = destEnt; @@ -570,11 +570,11 @@ public class CL_tent { return srcEnt; } - // find a free beam + // find a free beam b = cl_beams; for (i = 0; i < MAX_BEAMS; i++) { if (b[i].model == null || b[i].endtime < Globals.cl.time) { - // Com_Printf("%d: NORMAL %d . %d\n", cl.time, srcEnt, destEnt); + // Com_Printf("%d: NORMAL %d . %d\n", cl.time, srcEnt, destEnt); b[i].entity = srcEnt; b[i].dest_entity = destEnt; b[i].model = model; @@ -620,8 +620,8 @@ public class CL_tent { // stack variable private static final float[] pos = new float[3]; private static final float[] dir = new float[3]; - // ============= - // ROGUE + // ============= + // ROGUE static void ParseSteam() { int id, i; int r; @@ -635,7 +635,7 @@ public class CL_tent { // effect if (id != -1) // sustains { - // Com_Printf ("Sustain effect id %d\n", id); + // Com_Printf ("Sustain effect id %d\n", id); free_sustain = null; s = cl_sustains; for (i = 0; i < MAX_SUSTAINS; i++) { @@ -662,7 +662,7 @@ public class CL_tent { s[i].thinkinterval = 100; s[i].nextthink = Globals.cl.time; } else { - // Com_Printf ("No free sustains!\n"); + // Com_Printf ("No free sustains!\n"); // FIXME - read the stuff anyway MSG.ReadByte(Globals.net_message); MSG.ReadPos(Globals.net_message, pos); @@ -681,7 +681,7 @@ public class CL_tent { magnitude = MSG.ReadShort(Globals.net_message); color = r & 0xff; CL_newfx.ParticleSteamEffect(pos, dir, color, cnt, magnitude); - // S_StartSound (pos, 0, 0, cl_sfx_lashit, 1, ATTN_NORM, 0); + // S_StartSound (pos, 0, 0, cl_sfx_lashit, 1, ATTN_NORM, 0); } } @@ -753,8 +753,8 @@ public class CL_tent { } } - // ROGUE - // ============= + // ROGUE + // ============= /* * ================= CL_ParseTEnt ================= @@ -1079,8 +1079,8 @@ public class CL_tent { CL_fx.ParticleEffect3(pos, dir, color, cnt); break; - // ============= - // PGM + // ============= + // PGM // PMM -following code integrated for flechette (different color) case Defines.TE_BLASTER2: // green blaster hitting wall case Defines.TE_FLECHETTE: // flechette @@ -1194,12 +1194,12 @@ public class CL_tent { break; case Defines.TE_HEATBEAM_SPARKS: - // cnt = MSG.ReadByte (net_message); + // cnt = MSG.ReadByte (net_message); cnt = 50; MSG.ReadPos(Globals.net_message, pos); MSG.ReadDir(Globals.net_message, dir); - // r = MSG.ReadByte (net_message); - // magnitude = MSG.ReadShort (net_message); + // r = MSG.ReadByte (net_message); + // magnitude = MSG.ReadShort (net_message); r = 8; magnitude = 60; color = r & 0xff; @@ -1208,13 +1208,13 @@ public class CL_tent { break; case Defines.TE_HEATBEAM_STEAM: - // cnt = MSG.ReadByte (net_message); + // cnt = MSG.ReadByte (net_message); cnt = 20; MSG.ReadPos(Globals.net_message, pos); MSG.ReadDir(Globals.net_message, dir); - // r = MSG.ReadByte (net_message); - // magnitude = MSG.ReadShort (net_message); - // color = r & 0xff; + // r = MSG.ReadByte (net_message); + // magnitude = MSG.ReadShort (net_message); + // color = r & 0xff; color = 0xe0; magnitude = 60; CL_newfx.ParticleSteamEffect(pos, dir, color, cnt, magnitude); @@ -1226,7 +1226,7 @@ public class CL_tent { break; case Defines.TE_BUBBLETRAIL2: - // cnt = MSG.ReadByte (net_message); + // cnt = MSG.ReadByte (net_message); cnt = 8; MSG.ReadPos(Globals.net_message, pos); MSG.ReadPos(Globals.net_message, pos2); @@ -1251,7 +1251,7 @@ public class CL_tent { case Defines.TE_ELECTRIC_SPARKS: MSG.ReadPos(Globals.net_message, pos); MSG.ReadDir(Globals.net_message, dir); - // CL_ParticleEffect (pos, dir, 109, 40); + // CL_ParticleEffect (pos, dir, 109, 40); CL_fx.ParticleEffect(pos, dir, 0x75, 40); //FIXME : replace or remove this sound S.StartSound(pos, 0, 0, cl_sfx_lashit, 1, Defines.ATTN_NORM, 0); @@ -1282,8 +1282,8 @@ public class CL_tent { MSG.ReadPos(Globals.net_message, pos); CL_newfx.WidowSplash(pos); break; - // PGM - // ============== + // PGM + // ============== default: Com.Error(Defines.ERR_DROP, "CL_ParseTEnt: bad type"); @@ -1305,7 +1305,7 @@ public class CL_tent { float len, steps; float model_length; - // update beams + // update beams b = cl_beams; for (i = 0; i < MAX_BEAMS; i++) { if (b[i].model == null || b[i].endtime < Globals.cl.time) @@ -1367,13 +1367,13 @@ public class CL_tent { // the model from going // through the tesla mine (instead it goes through the target) if ((b[i].model == cl_mod_lightning) && (d <= model_length)) { - // Com_Printf ("special case\n"); + // Com_Printf ("special case\n"); Math3D.VectorCopy(b[i].end, ent.origin); // offset to push beam outside of tesla model (negative because // dist is from end to start // for this beam) - // for (j=0 ; j<3 ; j++) - // ent.origin[j] -= dist[j]*10.0; + // for (j=0 ; j<3 ; j++) + // ent.origin[j] -= dist[j]*10.0; ent.model = b[i].model; ent.flags = Defines.RF_FULLBRIGHT; ent.angles[0] = pitch; @@ -1396,7 +1396,7 @@ public class CL_tent { ent.angles[2] = Lib.rand() % 360; } - // Com_Printf("B: %d . %d\n", b[i].entity, b[i].dest_entity); + // Com_Printf("B: %d . %d\n", b[i].entity, b[i].dest_entity); V.AddEntity(ent); for (j = 0; j < 3; j++) @@ -1431,7 +1431,7 @@ public class CL_tent { frame_t oldframe; player_state_t ps, ops; - // PMM + // PMM if (Globals.hand != null) { if (Globals.hand.value == 2) hand_multiplier = 0; @@ -1442,9 +1442,9 @@ public class CL_tent { } else { hand_multiplier = 1; } - // PMM + // PMM - // update beams + // update beams beam_t[] b = cl_playerbeams; for (int i = 0; i < MAX_BEAMS; i++) { @@ -1505,7 +1505,7 @@ public class CL_tent { // calculate pitch and yaw Math3D.VectorSubtract(b[i].end, org, dist); - // PMM + // PMM if (cl_mod_heatbeam != null && (b[i].model == cl_mod_heatbeam) && (b[i].entity == Globals.cl.playernum + 1)) { @@ -1519,7 +1519,7 @@ public class CL_tent { Math3D.VectorMA(org, -1, Globals.cl.v_up, org); } } - // PMM + // PMM if (dist[1] == 0 && dist[0] == 0) { yaw = 0; @@ -1548,11 +1548,11 @@ public class CL_tent { if (cl_mod_heatbeam != null && (b[i].model == cl_mod_heatbeam)) { if (b[i].entity != Globals.cl.playernum + 1) { framenum = 2; - // Com_Printf ("Third person\n"); + // Com_Printf ("Third person\n"); ent.angles[0] = -pitch; ent.angles[1] = yaw + 180.0f; ent.angles[2] = 0; - // Com_Printf ("%f %f - %f %f %f\n", -pitch, yaw+180.0, + // Com_Printf ("%f %f - %f %f %f\n", -pitch, yaw+180.0, // b[i].offset[0], b[i].offset[1], b[i].offset[2]); Math3D.AngleVectors(ent.angles, f, r, u); @@ -1599,13 +1599,13 @@ public class CL_tent { // the model from going // through the tesla mine (instead it goes through the target) if ((b[i].model == cl_mod_lightning) && (d <= model_length)) { - // Com_Printf ("special case\n"); + // Com_Printf ("special case\n"); Math3D.VectorCopy(b[i].end, ent.origin); // offset to push beam outside of tesla model (negative because // dist is from end to start // for this beam) - // for (j=0 ; j<3 ; j++) - // ent.origin[j] -= dist[j]*10.0; + // for (j=0 ; j<3 ; j++) + // ent.origin[j] -= dist[j]*10.0; ent.model = b[i].model; ent.flags = Defines.RF_FULLBRIGHT; ent.angles[0] = pitch; @@ -1618,13 +1618,13 @@ public class CL_tent { Math3D.VectorCopy(org, ent.origin); ent.model = b[i].model; if (cl_mod_heatbeam != null && (b[i].model == cl_mod_heatbeam)) { - // ent.flags = RF_FULLBRIGHT|RF_TRANSLUCENT; - // ent.alpha = 0.3; + // ent.flags = RF_FULLBRIGHT|RF_TRANSLUCENT; + // ent.alpha = 0.3; ent.flags = Defines.RF_FULLBRIGHT; ent.angles[0] = -pitch; ent.angles[1] = yaw + 180.0f; ent.angles[2] = (Globals.cl.time) % 360; - // ent.angles[2] = rand()%360; + // ent.angles[2] = rand()%360; ent.frame = framenum; } else if (b[i].model == cl_mod_lightning) { ent.flags = Defines.RF_FULLBRIGHT; @@ -1637,7 +1637,7 @@ public class CL_tent { ent.angles[2] = Lib.rand() % 360; } - // Com_Printf("B: %d . %d\n", b[i].entity, b[i].dest_entity); + // Com_Printf("B: %d . %d\n", b[i].entity, b[i].dest_entity); V.AddEntity(ent); for (int j = 0; j < 3; j++) diff --git a/src/main/java/lwjake2/client/Console.java b/src/main/java/lwjake2/client/Console.java index 8ea224e..52ae9f1 100644 --- a/src/main/java/lwjake2/client/Console.java +++ b/src/main/java/lwjake2/client/Console.java @@ -409,7 +409,7 @@ public final class Console extends Globals { // start += 1 + key_linepos - con.linewidth; // draw it - // y = con.vislines-16; + // y = con.vislines-16; for (i = 0; i < con.linewidth; i++) re.DrawChar((i + 1) << 3, con.vislines - 22, text[i]); diff --git a/src/main/java/lwjake2/client/Key.java b/src/main/java/lwjake2/client/Key.java index 98768c8..dea0835 100644 --- a/src/main/java/lwjake2/client/Key.java +++ b/src/main/java/lwjake2/client/Key.java @@ -36,778 +36,778 @@ import java.util.Vector; */ @Slf4j public class Key extends Globals { - // - // these are the key numbers that should be passed to Key_Event - // - public static final int K_TAB = 9; - public static final int K_ENTER = 13; - public static final int K_ESCAPE = 27; - public static final int K_SPACE = 32; - - // normal keys should be passed as lowercased ascii - - public static final int K_BACKSPACE = 127; - public static final int K_UPARROW = 128; - public static final int K_DOWNARROW = 129; - public static final int K_LEFTARROW = 130; - public static final int K_RIGHTARROW = 131; - - public static final int K_ALT = 132; - public static final int K_CTRL = 133; - public static final int K_SHIFT = 134; - public static final int K_F1 = 135; - public static final int K_F2 = 136; - public static final int K_F3 = 137; - public static final int K_F4 = 138; - public static final int K_F5 = 139; - public static final int K_F6 = 140; - public static final int K_F7 = 141; - public static final int K_F8 = 142; - public static final int K_F9 = 143; - public static final int K_F10 = 144; - public static final int K_F11 = 145; - public static final int K_F12 = 146; - public static final int K_INS = 147; - public static final int K_DEL = 148; - public static final int K_PGDN = 149; - public static final int K_PGUP = 150; - public static final int K_HOME = 151; - public static final int K_END = 152; - - public static final int K_KP_HOME = 160; - public static final int K_KP_UPARROW = 161; - public static final int K_KP_PGUP = 162; - public static final int K_KP_LEFTARROW = 163; - public static final int K_KP_5 = 164; - public static final int K_KP_RIGHTARROW = 165; - public static final int K_KP_END = 166; - public static final int K_KP_DOWNARROW = 167; - public static final int K_KP_PGDN = 168; - public static final int K_KP_ENTER = 169; - public static final int K_KP_INS = 170; - public static final int K_KP_DEL = 171; - public static final int K_KP_SLASH = 172; - public static final int K_KP_MINUS = 173; - public static final int K_KP_PLUS = 174; - - public static final int K_PAUSE = 255; - - // - // mouse buttons generate virtual keys - // - public static final int K_MOUSE1 = 200; - public static final int K_MOUSE2 = 201; - public static final int K_MOUSE3 = 202; - - // - // joystick buttons - // - public static final int K_JOY1 = 203; - public static final int K_JOY2 = 204; - public static final int K_JOY3 = 205; - public static final int K_JOY4 = 206; - - public static final int K_MWHEELDOWN = 239; - public static final int K_MWHEELUP = 240; - - static int anykeydown = 0; - static int key_waiting; - static int history_line = 0; - static boolean shift_down = false; - static int[] key_repeats = new int[256]; - //static int[] keyshift = new int[256]; - static boolean[] menubound = new boolean[256]; - static boolean[] consolekeys = new boolean[256]; - - static String[] keynames = new String[256]; - - static { - keynames[K_TAB] = "TAB"; - keynames[K_ENTER] = "ENTER"; - keynames[K_ESCAPE] = "ESCAPE"; - keynames[K_SPACE] = "SPACE"; - keynames[K_BACKSPACE] = "BACKSPACE"; - keynames[K_UPARROW] = "UPARROW"; - keynames[K_DOWNARROW] = "DOWNARROW"; - keynames[K_LEFTARROW] = "LEFTARROW"; - keynames[K_RIGHTARROW] = "RIGHTARROW"; - keynames[K_ALT] = "ALT"; - keynames[K_CTRL] = "CTRL"; - keynames[K_SHIFT] = "SHIFT"; - - keynames[K_F1] = "F1"; - keynames[K_F2] = "F2"; - keynames[K_F3] = "F3"; - keynames[K_F4] = "F4"; - keynames[K_F5] = "F5"; - keynames[K_F6] = "F6"; - keynames[K_F7] = "F7"; - keynames[K_F8] = "F8"; - keynames[K_F9] = "F9"; - keynames[K_F10] = "F10"; - keynames[K_F11] = "F11"; - keynames[K_F12] = "F12"; - - keynames[K_INS] = "INS"; - keynames[K_DEL] = "DEL"; - keynames[K_PGDN] = "PGDN"; - keynames[K_PGUP] = "PGUP"; - keynames[K_HOME] = "HOME"; - keynames[K_END] = "END"; - - keynames[K_MOUSE1] = "MOUSE1"; - keynames[K_MOUSE2] = "MOUSE2"; - keynames[K_MOUSE3] = "MOUSE3"; - - // 00092 {"JOY1", K_JOY1}, - // 00093 {"JOY2", K_JOY2}, - // 00094 {"JOY3", K_JOY3}, - // 00095 {"JOY4", K_JOY4}, - - keynames[K_KP_HOME] = "KP_HOME"; - keynames[K_KP_UPARROW] = "KP_UPARROW"; - keynames[K_KP_PGUP] = "KP_PGUP"; - keynames[K_KP_LEFTARROW] = "KP_LEFTARROW"; - keynames[K_KP_5] = "KP_5"; - keynames[K_KP_RIGHTARROW] = "KP_RIGHTARROW"; - keynames[K_KP_END] = "KP_END"; - keynames[K_KP_DOWNARROW] = "KP_DOWNARROW"; - keynames[K_KP_PGDN] = "KP_PGDN"; - keynames[K_KP_ENTER] = "KP_ENTER"; - keynames[K_KP_INS] = "KP_INS"; - keynames[K_KP_DEL] = "KP_DEL"; - keynames[K_KP_SLASH] = "KP_SLASH"; - - keynames[K_KP_PLUS] = "KP_PLUS"; - keynames[K_KP_MINUS] = "KP_MINUS"; - - keynames[K_MWHEELUP] = "MWHEELUP"; - keynames[K_MWHEELDOWN] = "MWHEELDOWN"; - - keynames[K_PAUSE] = "PAUSE"; - keynames[';'] = "SEMICOLON"; // because a raw semicolon seperates commands - - keynames[0] = "NULL"; - } - - /** - * - */ - public static void Init() { - for (int i = 0; i < 32; i++) { - Globals.key_lines[i][0] = ']'; - Globals.key_lines[i][1] = 0; - } - Globals.key_linepos = 1; - - // - // init ascii characters in console mode - // - for (int i = 32; i < 128; i++) - consolekeys[i] = true; - consolekeys[K_ENTER] = true; - consolekeys[K_KP_ENTER] = true; - consolekeys[K_TAB] = true; - consolekeys[K_LEFTARROW] = true; - consolekeys[K_KP_LEFTARROW] = true; - consolekeys[K_RIGHTARROW] = true; - consolekeys[K_KP_RIGHTARROW] = true; - consolekeys[K_UPARROW] = true; - consolekeys[K_KP_UPARROW] = true; - consolekeys[K_DOWNARROW] = true; - consolekeys[K_KP_DOWNARROW] = true; - consolekeys[K_BACKSPACE] = true; - consolekeys[K_HOME] = true; - consolekeys[K_KP_HOME] = true; - consolekeys[K_END] = true; - consolekeys[K_KP_END] = true; - consolekeys[K_PGUP] = true; - consolekeys[K_KP_PGUP] = true; - consolekeys[K_PGDN] = true; - consolekeys[K_KP_PGDN] = true; - consolekeys[K_SHIFT] = true; - consolekeys[K_INS] = true; - consolekeys[K_KP_INS] = true; - consolekeys[K_KP_DEL] = true; - consolekeys[K_KP_SLASH] = true; - consolekeys[K_KP_PLUS] = true; - consolekeys[K_KP_MINUS] = true; - consolekeys[K_KP_5] = true; - - consolekeys['`'] = false; - consolekeys['~'] = false; - -// for (int i = 0; i < 256; i++) -// keyshift[i] = i; -// for (int i = 'a'; i <= 'z'; i++) -// keyshift[i] = i - 'a' + 'A'; -// keyshift['1'] = '!'; -// keyshift['2'] = '@'; -// keyshift['3'] = '#'; -// keyshift['4'] = '$'; -// keyshift['5'] = '%'; -// keyshift['6'] = '^'; -// keyshift['7'] = '&'; -// keyshift['8'] = '*'; -// keyshift['9'] = '('; -// keyshift['0'] = ')'; -// keyshift['-'] = '_'; -// keyshift['='] = '+'; -// keyshift[','] = '<'; -// keyshift['.'] = '>'; -// keyshift['/'] = '?'; -// keyshift[';'] = ':'; -// keyshift['\''] = '"'; -// keyshift['['] = '{'; -// keyshift[']'] = '}'; -// keyshift['`'] = '~'; -// keyshift['\\'] = '|'; - - menubound[K_ESCAPE] = true; - for (int i = 0; i < 12; i++) - menubound[K_F1 + i] = true; - - // - // register our functions - // - Cmd.AddCommand("bind", Key.Bind_f); - Cmd.AddCommand("unbind", Key.Unbind_f); - Cmd.AddCommand("unbindall", Key.Unbindall_f); - Cmd.AddCommand("bindlist", Key.Bindlist_f); - } - - public static void ClearTyping() { - Globals.key_lines[Globals.edit_line][1] = 0; // clear any typing - Globals.key_linepos = 1; - } - - /** - * Called by the system between frames for both key up and key down events. - */ - public static void Event(int key, boolean down, int time) { - String kb; - String cmd; - - // hack for modal presses - if (key_waiting == -1) { - if (down) - key_waiting = key; - return; - } - - // update auto-repeat status - if (down) { - key_repeats[key]++; - if (key_repeats[key] > 1 - && Globals.cls.key_dest == Defines.key_game - && !(Globals.cls.state == Defines.ca_disconnected)) - return; // ignore most autorepeats - - if (key >= 200 && Globals.keybindings[key] == null) - Com.Printf(Key.KeynumToString(key) + " is unbound, hit F4 to set.\n"); - } - else { - key_repeats[key] = 0; - } - - if (key == K_SHIFT) - shift_down = down; - - // console key is hardcoded, so the user can never unbind it - if (key == '`' || key == '~') { - if (!down) - return; - - Console.ToggleConsole_f.run(); - return; - } - - // any key during the attract mode will bring up the menu - if (Globals.cl.attractloop && Globals.cls.key_dest != Defines.key_menu && !(key >= K_F1 && key <= K_F12)) - key = K_ESCAPE; - - // menu key is hardcoded, so the user can never unbind it - if (key == K_ESCAPE) { - if (!down) - return; - - if (Globals.cl.frame.playerstate.stats[Defines.STAT_LAYOUTS] != 0 && Globals.cls.key_dest == Defines.key_game) { - // put away help computer / inventory - Cbuf.AddText("cmd putaway\n"); - return; - } - switch (Globals.cls.key_dest) { - case Defines.key_message : - Key.Message(key); - break; - case Defines.key_menu : - Menu.Keydown(key); - break; - case Defines.key_game : - case Defines.key_console : - Menu.Menu_Main_f(); - break; - default : - Com.Error(Defines.ERR_FATAL, "Bad cls.key_dest"); - } - return; - } - - // track if any key is down for BUTTON_ANY - Globals.keydown[key] = down; - if (down) { - if (key_repeats[key] == 1) - Key.anykeydown++; - } - else { - Key.anykeydown--; - if (Key.anykeydown < 0) - Key.anykeydown = 0; - } - - // - // key up events only generate commands if the game key binding is - // a button command (leading + sign). These will occur even in console mode, - // to keep the character from continuing an action started before a console - // switch. Button commands include the kenum as a parameter, so multiple - // downs can be matched with ups - // - if (!down) { - kb = Globals.keybindings[key]; - if (kb != null && kb.length()>0 && kb.charAt(0) == '+') { - cmd = "-" + kb.substring(1) + " " + key + " " + time + "\n"; - Cbuf.AddText(cmd); - } -// if (keyshift[key] != key) { -// kb = Globals.keybindings[keyshift[key]]; -// if (kb != null && kb.length()>0 && kb.charAt(0) == '+') { -// cmd = "-" + kb.substring(1) + " " + key + " " + time + "\n"; -// Cbuf.AddText(cmd); -// } -// } - return; - } - - // - // if not a consolekey, send to the interpreter no matter what mode is - // - if ((Globals.cls.key_dest == Defines.key_menu && menubound[key]) - || (Globals.cls.key_dest == Defines.key_console && !consolekeys[key]) - || (Globals.cls.key_dest == Defines.key_game && (Globals.cls.state == Defines.ca_active || !consolekeys[key]))) { - kb = Globals.keybindings[key]; - if (kb != null) { - if (kb.length()>0 && kb.charAt(0) == '+') { - // button commands add keynum and time as a parm - cmd = kb + " " + key + " " + time + "\n"; - Cbuf.AddText(cmd); - } - else { - Cbuf.AddText(kb + "\n"); - } - } - return; - } - - // if (shift_down) -// key = keyshift[key]; - - switch (Globals.cls.key_dest) { - case Defines.key_message : - Key.Message(key); - break; - case Defines.key_menu : - Menu.Keydown(key); - break; - - case Defines.key_game : - case Defines.key_console : - Key.Console(key); - break; - default : - Com.Error(Defines.ERR_FATAL, "Bad cls.key_dest"); - } - } - - /** - * Returns a string (either a single ascii char, or a K_* name) for the - * given keynum. - */ - public static String KeynumToString(int keynum) { - if (keynum < 0 || keynum > 255) - return ""; - if (keynum > 32 && keynum < 127) - return Character.toString((char) keynum); - - if (keynames[keynum] != null) - return keynames[keynum]; - - return ""; - } - - /** - * Returns a key number to be used to index keybindings[] by looking at - * the given string. Single ascii characters return themselves, while - * the K_* names are matched up. - */ - static int StringToKeynum(String str) { - - if (str == null) - return -1; - - if (str.length() == 1) - return str.charAt(0); - - for (int i = 0; i < keynames.length; i++) { - if (str.equalsIgnoreCase(keynames[i])) - return i; - } - - return -1; - } - - public static void Message(int key) { - - if (key == K_ENTER || key == K_KP_ENTER) { - if (Globals.chat_team) - Cbuf.AddText("say_team \""); - else - Cbuf.AddText("say \""); - - Cbuf.AddText(Globals.chat_buffer); - Cbuf.AddText("\"\n"); - - Globals.cls.key_dest = Defines.key_game; - Globals.chat_buffer = ""; - return; - } - - if (key == K_ESCAPE) { - Globals.cls.key_dest = Defines.key_game; - Globals.chat_buffer = ""; - return; - } - - if (key < 32 || key > 127) - return; // non printable - - if (key == K_BACKSPACE) { - if (Globals.chat_buffer.length() > 2) { - Globals.chat_buffer = Globals.chat_buffer.substring(0, Globals.chat_buffer.length() - 2); - } - else - Globals.chat_buffer = ""; - return; - } - - if (Globals.chat_buffer.length() > Defines.MAXCMDLINE) - return; // all full - - Globals.chat_buffer += (char) key; - } - - /** - * Interactive line editing and console scrollback. - */ - public static void Console(int key) { - - switch (key) { - case K_KP_SLASH : - key = '/'; - break; - case K_KP_MINUS : - key = '-'; - break; - case K_KP_PLUS : - key = '+'; - break; - case K_KP_HOME : - key = '7'; - break; - case K_KP_UPARROW : - key = '8'; - break; - case K_KP_PGUP : - key = '9'; - break; - case K_KP_LEFTARROW : - key = '4'; - break; - case K_KP_5 : - key = '5'; - break; - case K_KP_RIGHTARROW : - key = '6'; - break; - case K_KP_END : - key = '1'; - break; - case K_KP_DOWNARROW : - key = '2'; - break; - case K_KP_PGDN : - key = '3'; - break; - case K_KP_INS : - key = '0'; - break; - case K_KP_DEL : - key = '.'; - break; - } - - if (key == 'l') { - if (Globals.keydown[K_CTRL]) { - Cbuf.AddText("clear\n"); - return; - } - } - - if (key == K_ENTER || key == K_KP_ENTER) { - // backslash text are commands, else chat - if (Globals.key_lines[Globals.edit_line][1] == '\\' || Globals.key_lines[Globals.edit_line][1] == '/') - Cbuf.AddText( - new String(Globals.key_lines[Globals.edit_line], 2, Lib.strlen(Globals.key_lines[Globals.edit_line]) - 2)); - else - Cbuf.AddText( - new String(Globals.key_lines[Globals.edit_line], 1, Lib.strlen(Globals.key_lines[Globals.edit_line]) - 1)); - - - Cbuf.AddText("\n"); - - log.info(new String(Globals.key_lines[Globals.edit_line], 0, Lib.strlen(Globals.key_lines[Globals.edit_line]))); - Globals.edit_line = (Globals.edit_line + 1) & 31; - history_line = Globals.edit_line; - - Globals.key_lines[Globals.edit_line][0] = ']'; - Globals.key_linepos = 1; - if (Globals.cls.state == Defines.ca_disconnected) - SCR.UpdateScreen(); // force an update, because the command may take some time - return; - } - - if (key == K_TAB) { - // command completion - CompleteCommand(); - return; - } - - if ((key == K_BACKSPACE) || (key == K_LEFTARROW) || (key == K_KP_LEFTARROW) || ((key == 'h') && (Globals.keydown[K_CTRL]))) { - if (Globals.key_linepos > 1) - Globals.key_linepos--; - return; - } - - if ((key == K_UPARROW) || (key == K_KP_UPARROW) || ((key == 'p') && Globals.keydown[K_CTRL])) { - do { - history_line = (history_line - 1) & 31; - } - while (history_line != Globals.edit_line && Globals.key_lines[history_line][1] == 0); - if (history_line == Globals.edit_line) - history_line = (Globals.edit_line + 1) & 31; - //Lib.strcpy(Globals.key_lines[Globals.edit_line], Globals.key_lines[history_line]); - System.arraycopy(Globals.key_lines[history_line], 0, Globals.key_lines[Globals.edit_line], 0, Globals.key_lines[Globals.edit_line].length); - Globals.key_linepos = Lib.strlen(Globals.key_lines[Globals.edit_line]); - return; - } - - if ((key == K_DOWNARROW) || (key == K_KP_DOWNARROW) || ((key == 'n') && Globals.keydown[K_CTRL])) { - if (history_line == Globals.edit_line) - return; - do { - history_line = (history_line + 1) & 31; - } - while (history_line != Globals.edit_line && Globals.key_lines[history_line][1] == 0); - if (history_line == Globals.edit_line) { - Globals.key_lines[Globals.edit_line][0] = ']'; - Globals.key_linepos = 1; - } - else { - //Lib.strcpy(Globals.key_lines[Globals.edit_line], Globals.key_lines[history_line]); - System.arraycopy(Globals.key_lines[history_line], 0, Globals.key_lines[Globals.edit_line], 0, Globals.key_lines[Globals.edit_line].length); - Globals.key_linepos = Lib.strlen(Globals.key_lines[Globals.edit_line]); - } - return; - } - - if (key == K_PGUP || key == K_KP_PGUP) { - Globals.con.display -= 2; - return; - } - - if (key == K_PGDN || key == K_KP_PGDN) { - Globals.con.display += 2; - if (Globals.con.display > Globals.con.current) - Globals.con.display = Globals.con.current; - return; - } - - if (key == K_HOME || key == K_KP_HOME) { - Globals.con.display = Globals.con.current - Globals.con.totallines + 10; - return; - } - - if (key == K_END || key == K_KP_END) { - Globals.con.display = Globals.con.current; - return; - } - - if (key < 32 || key > 127) - return; // non printable - - if (Globals.key_linepos < Defines.MAXCMDLINE - 1) { - Globals.key_lines[Globals.edit_line][Globals.key_linepos] = (byte) key; - Globals.key_linepos++; - Globals.key_lines[Globals.edit_line][Globals.key_linepos] = 0; - } - - } - - private static void printCompletions(String type, Vector compl) { - StringBuilder sb = new StringBuilder(compl.size()); - for (int i = 0; i < compl.size(); i++) { - sb.append(compl.get(i)).append(' '); - } - //TODO потом убрать - while (type.startsWith("\n")) { type = type.substring(1); } - while (type.endsWith("\n")) { type = type.substring(0, type.lastIndexOf("\n")); } - while (type.endsWith("\r")) { type = type.substring(0, type.lastIndexOf("\r")); } - type = type.trim(); - log.info("{} {}", type, sb.toString()); - } - - static void CompleteCommand() { - - int start = 1; - if (key_lines[edit_line][start] == '\\' || key_lines[edit_line][start] == '/') - start++; - - int end = start; - while (key_lines[edit_line][end] != 0) end++; - - String s = new String(key_lines[edit_line], start, end-start); - - Vector cmds = Cmd.CompleteCommand(s); - Vector vars = Cvar.CompleteVariable(s); - - int c = cmds.size(); - int v = vars.size(); - - if ((c + v) > 1) { - if (c > 0) printCompletions("\nCommands:\n", cmds); - if (v > 0) printCompletions("\nVariables:\n", vars); - return; - } else if (c == 1) { - s = (String)cmds.get(0); - } else if (v == 1) { - s = (String)vars.get(0); - } else return; - - key_lines[edit_line][1] = '/'; - byte[] bytes = Lib.stringToBytes(s); - System.arraycopy(bytes, 0, key_lines[edit_line], 2, bytes.length); - key_linepos = bytes.length + 2; - key_lines[edit_line][key_linepos++] = ' '; - key_lines[edit_line][key_linepos] = 0; - - return; - } - - public static Runnable Bind_f = Key::Key_Bind_f; - - static void Key_Bind_f() { - int c = Cmd.Argc(); - - if (c < 2) { - Com.Printf("bind [command] : attach a command to a key\n"); - return; - } - int b = StringToKeynum(Cmd.Argv(1)); - if (b == -1) { - Com.Printf("\"" + Cmd.Argv(1) + "\" isn't a valid key\n"); - return; - } - - if (c == 2) { - if (Globals.keybindings[b] != null) - Com.Printf("\"" + Cmd.Argv(1) + "\" = \"" + Globals.keybindings[b] + "\"\n"); - else - Com.Printf("\"" + Cmd.Argv(1) + "\" is not bound\n"); - return; - } - - // copy the rest of the command line - String cmd = ""; // start out with a null string - for (int i = 2; i < c; i++) { - cmd += Cmd.Argv(i); - if (i != (c - 1)) - cmd += " "; - } - - SetBinding(b, cmd); - } - - static void SetBinding(int keynum, String binding) { - if (keynum == -1) - return; - - // free old bindings - Globals.keybindings[keynum] = null; - - Globals.keybindings[keynum] = binding; - } - - static Runnable Unbind_f = Key::Key_Unbind_f; - - static void Key_Unbind_f() { - - if (Cmd.Argc() != 2) { - Com.Printf("unbind : remove commands from a key\n"); - return; - } - - int b = Key.StringToKeynum(Cmd.Argv(1)); - if (b == -1) { - Com.Printf("\"" + Cmd.Argv(1) + "\" isn't a valid key\n"); - return; - } - - Key.SetBinding(b, null); - } - - static Runnable Unbindall_f = Key::Key_Unbindall_f; - - static void Key_Unbindall_f() { - for (int i = 0; i < 256; i++) - Key.SetBinding(i, null); - } - - static Runnable Bindlist_f = Key::Key_Bindlist_f; - - static void Key_Bindlist_f() { - for (int i = 0; i < 256; i++) - if (Globals.keybindings[i] != null && Globals.keybindings[i].length() != 0) - Com.Printf(Key.KeynumToString(i) + " \"" + Globals.keybindings[i] + "\"\n"); - } - - static void ClearStates() { - int i; - - Key.anykeydown = 0; - - for (i = 0; i < 256; i++) { - if (keydown[i] || key_repeats[i]!=0) - Event(i, false, 0); - keydown[i] = false; - key_repeats[i] = 0; - } - } - - public static void WriteBindings(RandomAccessFile f) { - for (int i = 0; i < 256; i++) - if (keybindings[i] != null && keybindings[i].length() > 0) - try { - f.writeBytes("bind " + KeynumToString(i) + " \"" + keybindings[i] + "\"\n"); - } catch (IOException e) {} - } + // + // these are the key numbers that should be passed to Key_Event + // + public static final int K_TAB = 9; + public static final int K_ENTER = 13; + public static final int K_ESCAPE = 27; + public static final int K_SPACE = 32; + + // normal keys should be passed as lowercased ascii + + public static final int K_BACKSPACE = 127; + public static final int K_UPARROW = 128; + public static final int K_DOWNARROW = 129; + public static final int K_LEFTARROW = 130; + public static final int K_RIGHTARROW = 131; + + public static final int K_ALT = 132; + public static final int K_CTRL = 133; + public static final int K_SHIFT = 134; + public static final int K_F1 = 135; + public static final int K_F2 = 136; + public static final int K_F3 = 137; + public static final int K_F4 = 138; + public static final int K_F5 = 139; + public static final int K_F6 = 140; + public static final int K_F7 = 141; + public static final int K_F8 = 142; + public static final int K_F9 = 143; + public static final int K_F10 = 144; + public static final int K_F11 = 145; + public static final int K_F12 = 146; + public static final int K_INS = 147; + public static final int K_DEL = 148; + public static final int K_PGDN = 149; + public static final int K_PGUP = 150; + public static final int K_HOME = 151; + public static final int K_END = 152; + + public static final int K_KP_HOME = 160; + public static final int K_KP_UPARROW = 161; + public static final int K_KP_PGUP = 162; + public static final int K_KP_LEFTARROW = 163; + public static final int K_KP_5 = 164; + public static final int K_KP_RIGHTARROW = 165; + public static final int K_KP_END = 166; + public static final int K_KP_DOWNARROW = 167; + public static final int K_KP_PGDN = 168; + public static final int K_KP_ENTER = 169; + public static final int K_KP_INS = 170; + public static final int K_KP_DEL = 171; + public static final int K_KP_SLASH = 172; + public static final int K_KP_MINUS = 173; + public static final int K_KP_PLUS = 174; + + public static final int K_PAUSE = 255; + + // + // mouse buttons generate virtual keys + // + public static final int K_MOUSE1 = 200; + public static final int K_MOUSE2 = 201; + public static final int K_MOUSE3 = 202; + + // + // joystick buttons + // + public static final int K_JOY1 = 203; + public static final int K_JOY2 = 204; + public static final int K_JOY3 = 205; + public static final int K_JOY4 = 206; + + public static final int K_MWHEELDOWN = 239; + public static final int K_MWHEELUP = 240; + + static int anykeydown = 0; + static int key_waiting; + static int history_line = 0; + static boolean shift_down = false; + static int[] key_repeats = new int[256]; + //static int[] keyshift = new int[256]; + static boolean[] menubound = new boolean[256]; + static boolean[] consolekeys = new boolean[256]; + + static String[] keynames = new String[256]; + + static { + keynames[K_TAB] = "TAB"; + keynames[K_ENTER] = "ENTER"; + keynames[K_ESCAPE] = "ESCAPE"; + keynames[K_SPACE] = "SPACE"; + keynames[K_BACKSPACE] = "BACKSPACE"; + keynames[K_UPARROW] = "UPARROW"; + keynames[K_DOWNARROW] = "DOWNARROW"; + keynames[K_LEFTARROW] = "LEFTARROW"; + keynames[K_RIGHTARROW] = "RIGHTARROW"; + keynames[K_ALT] = "ALT"; + keynames[K_CTRL] = "CTRL"; + keynames[K_SHIFT] = "SHIFT"; + + keynames[K_F1] = "F1"; + keynames[K_F2] = "F2"; + keynames[K_F3] = "F3"; + keynames[K_F4] = "F4"; + keynames[K_F5] = "F5"; + keynames[K_F6] = "F6"; + keynames[K_F7] = "F7"; + keynames[K_F8] = "F8"; + keynames[K_F9] = "F9"; + keynames[K_F10] = "F10"; + keynames[K_F11] = "F11"; + keynames[K_F12] = "F12"; + + keynames[K_INS] = "INS"; + keynames[K_DEL] = "DEL"; + keynames[K_PGDN] = "PGDN"; + keynames[K_PGUP] = "PGUP"; + keynames[K_HOME] = "HOME"; + keynames[K_END] = "END"; + + keynames[K_MOUSE1] = "MOUSE1"; + keynames[K_MOUSE2] = "MOUSE2"; + keynames[K_MOUSE3] = "MOUSE3"; + + // 00092 {"JOY1", K_JOY1}, + // 00093 {"JOY2", K_JOY2}, + // 00094 {"JOY3", K_JOY3}, + // 00095 {"JOY4", K_JOY4}, + + keynames[K_KP_HOME] = "KP_HOME"; + keynames[K_KP_UPARROW] = "KP_UPARROW"; + keynames[K_KP_PGUP] = "KP_PGUP"; + keynames[K_KP_LEFTARROW] = "KP_LEFTARROW"; + keynames[K_KP_5] = "KP_5"; + keynames[K_KP_RIGHTARROW] = "KP_RIGHTARROW"; + keynames[K_KP_END] = "KP_END"; + keynames[K_KP_DOWNARROW] = "KP_DOWNARROW"; + keynames[K_KP_PGDN] = "KP_PGDN"; + keynames[K_KP_ENTER] = "KP_ENTER"; + keynames[K_KP_INS] = "KP_INS"; + keynames[K_KP_DEL] = "KP_DEL"; + keynames[K_KP_SLASH] = "KP_SLASH"; + + keynames[K_KP_PLUS] = "KP_PLUS"; + keynames[K_KP_MINUS] = "KP_MINUS"; + + keynames[K_MWHEELUP] = "MWHEELUP"; + keynames[K_MWHEELDOWN] = "MWHEELDOWN"; + + keynames[K_PAUSE] = "PAUSE"; + keynames[';'] = "SEMICOLON"; // because a raw semicolon seperates commands + + keynames[0] = "NULL"; + } + + /** + * + */ + public static void Init() { + for (int i = 0; i < 32; i++) { + Globals.key_lines[i][0] = ']'; + Globals.key_lines[i][1] = 0; + } + Globals.key_linepos = 1; + + // + // init ascii characters in console mode + // + for (int i = 32; i < 128; i++) + consolekeys[i] = true; + consolekeys[K_ENTER] = true; + consolekeys[K_KP_ENTER] = true; + consolekeys[K_TAB] = true; + consolekeys[K_LEFTARROW] = true; + consolekeys[K_KP_LEFTARROW] = true; + consolekeys[K_RIGHTARROW] = true; + consolekeys[K_KP_RIGHTARROW] = true; + consolekeys[K_UPARROW] = true; + consolekeys[K_KP_UPARROW] = true; + consolekeys[K_DOWNARROW] = true; + consolekeys[K_KP_DOWNARROW] = true; + consolekeys[K_BACKSPACE] = true; + consolekeys[K_HOME] = true; + consolekeys[K_KP_HOME] = true; + consolekeys[K_END] = true; + consolekeys[K_KP_END] = true; + consolekeys[K_PGUP] = true; + consolekeys[K_KP_PGUP] = true; + consolekeys[K_PGDN] = true; + consolekeys[K_KP_PGDN] = true; + consolekeys[K_SHIFT] = true; + consolekeys[K_INS] = true; + consolekeys[K_KP_INS] = true; + consolekeys[K_KP_DEL] = true; + consolekeys[K_KP_SLASH] = true; + consolekeys[K_KP_PLUS] = true; + consolekeys[K_KP_MINUS] = true; + consolekeys[K_KP_5] = true; + + consolekeys['`'] = false; + consolekeys['~'] = false; + +// for (int i = 0; i < 256; i++) +// keyshift[i] = i; +// for (int i = 'a'; i <= 'z'; i++) +// keyshift[i] = i - 'a' + 'A'; +// keyshift['1'] = '!'; +// keyshift['2'] = '@'; +// keyshift['3'] = '#'; +// keyshift['4'] = '$'; +// keyshift['5'] = '%'; +// keyshift['6'] = '^'; +// keyshift['7'] = '&'; +// keyshift['8'] = '*'; +// keyshift['9'] = '('; +// keyshift['0'] = ')'; +// keyshift['-'] = '_'; +// keyshift['='] = '+'; +// keyshift[','] = '<'; +// keyshift['.'] = '>'; +// keyshift['/'] = '?'; +// keyshift[';'] = ':'; +// keyshift['\''] = '"'; +// keyshift['['] = '{'; +// keyshift[']'] = '}'; +// keyshift['`'] = '~'; +// keyshift['\\'] = '|'; + + menubound[K_ESCAPE] = true; + for (int i = 0; i < 12; i++) + menubound[K_F1 + i] = true; + + // + // register our functions + // + Cmd.AddCommand("bind", Key.Bind_f); + Cmd.AddCommand("unbind", Key.Unbind_f); + Cmd.AddCommand("unbindall", Key.Unbindall_f); + Cmd.AddCommand("bindlist", Key.Bindlist_f); + } + + public static void ClearTyping() { + Globals.key_lines[Globals.edit_line][1] = 0; // clear any typing + Globals.key_linepos = 1; + } + + /** + * Called by the system between frames for both key up and key down events. + */ + public static void Event(int key, boolean down, int time) { + String kb; + String cmd; + + // hack for modal presses + if (key_waiting == -1) { + if (down) + key_waiting = key; + return; + } + + // update auto-repeat status + if (down) { + key_repeats[key]++; + if (key_repeats[key] > 1 + && Globals.cls.key_dest == Defines.key_game + && !(Globals.cls.state == Defines.ca_disconnected)) + return; // ignore most autorepeats + + if (key >= 200 && Globals.keybindings[key] == null) + Com.Printf(Key.KeynumToString(key) + " is unbound, hit F4 to set.\n"); + } + else { + key_repeats[key] = 0; + } + + if (key == K_SHIFT) + shift_down = down; + + // console key is hardcoded, so the user can never unbind it + if (key == '`' || key == '~') { + if (!down) + return; + + Console.ToggleConsole_f.run(); + return; + } + + // any key during the attract mode will bring up the menu + if (Globals.cl.attractloop && Globals.cls.key_dest != Defines.key_menu && !(key >= K_F1 && key <= K_F12)) + key = K_ESCAPE; + + // menu key is hardcoded, so the user can never unbind it + if (key == K_ESCAPE) { + if (!down) + return; + + if (Globals.cl.frame.playerstate.stats[Defines.STAT_LAYOUTS] != 0 && Globals.cls.key_dest == Defines.key_game) { + // put away help computer / inventory + Cbuf.AddText("cmd putaway\n"); + return; + } + switch (Globals.cls.key_dest) { + case Defines.key_message : + Key.Message(key); + break; + case Defines.key_menu : + Menu.Keydown(key); + break; + case Defines.key_game : + case Defines.key_console : + Menu.Menu_Main_f(); + break; + default : + Com.Error(Defines.ERR_FATAL, "Bad cls.key_dest"); + } + return; + } + + // track if any key is down for BUTTON_ANY + Globals.keydown[key] = down; + if (down) { + if (key_repeats[key] == 1) + Key.anykeydown++; + } + else { + Key.anykeydown--; + if (Key.anykeydown < 0) + Key.anykeydown = 0; + } + + // + // key up events only generate commands if the game key binding is + // a button command (leading + sign). These will occur even in console mode, + // to keep the character from continuing an action started before a console + // switch. Button commands include the kenum as a parameter, so multiple + // downs can be matched with ups + // + if (!down) { + kb = Globals.keybindings[key]; + if (kb != null && kb.length()>0 && kb.charAt(0) == '+') { + cmd = "-" + kb.substring(1) + " " + key + " " + time + "\n"; + Cbuf.AddText(cmd); + } +// if (keyshift[key] != key) { +// kb = Globals.keybindings[keyshift[key]]; +// if (kb != null && kb.length()>0 && kb.charAt(0) == '+') { +// cmd = "-" + kb.substring(1) + " " + key + " " + time + "\n"; +// Cbuf.AddText(cmd); +// } +// } + return; + } + + // + // if not a consolekey, send to the interpreter no matter what mode is + // + if ((Globals.cls.key_dest == Defines.key_menu && menubound[key]) + || (Globals.cls.key_dest == Defines.key_console && !consolekeys[key]) + || (Globals.cls.key_dest == Defines.key_game && (Globals.cls.state == Defines.ca_active || !consolekeys[key]))) { + kb = Globals.keybindings[key]; + if (kb != null) { + if (kb.length()>0 && kb.charAt(0) == '+') { + // button commands add keynum and time as a parm + cmd = kb + " " + key + " " + time + "\n"; + Cbuf.AddText(cmd); + } + else { + Cbuf.AddText(kb + "\n"); + } + } + return; + } + + // if (shift_down) +// key = keyshift[key]; + + switch (Globals.cls.key_dest) { + case Defines.key_message : + Key.Message(key); + break; + case Defines.key_menu : + Menu.Keydown(key); + break; + + case Defines.key_game : + case Defines.key_console : + Key.Console(key); + break; + default : + Com.Error(Defines.ERR_FATAL, "Bad cls.key_dest"); + } + } + + /** + * Returns a string (either a single ascii char, or a K_* name) for the + * given keynum. + */ + public static String KeynumToString(int keynum) { + if (keynum < 0 || keynum > 255) + return ""; + if (keynum > 32 && keynum < 127) + return Character.toString((char) keynum); + + if (keynames[keynum] != null) + return keynames[keynum]; + + return ""; + } + + /** + * Returns a key number to be used to index keybindings[] by looking at + * the given string. Single ascii characters return themselves, while + * the K_* names are matched up. + */ + static int StringToKeynum(String str) { + + if (str == null) + return -1; + + if (str.length() == 1) + return str.charAt(0); + + for (int i = 0; i < keynames.length; i++) { + if (str.equalsIgnoreCase(keynames[i])) + return i; + } + + return -1; + } + + public static void Message(int key) { + + if (key == K_ENTER || key == K_KP_ENTER) { + if (Globals.chat_team) + Cbuf.AddText("say_team \""); + else + Cbuf.AddText("say \""); + + Cbuf.AddText(Globals.chat_buffer); + Cbuf.AddText("\"\n"); + + Globals.cls.key_dest = Defines.key_game; + Globals.chat_buffer = ""; + return; + } + + if (key == K_ESCAPE) { + Globals.cls.key_dest = Defines.key_game; + Globals.chat_buffer = ""; + return; + } + + if (key < 32 || key > 127) + return; // non printable + + if (key == K_BACKSPACE) { + if (Globals.chat_buffer.length() > 2) { + Globals.chat_buffer = Globals.chat_buffer.substring(0, Globals.chat_buffer.length() - 2); + } + else + Globals.chat_buffer = ""; + return; + } + + if (Globals.chat_buffer.length() > Defines.MAXCMDLINE) + return; // all full + + Globals.chat_buffer += (char) key; + } + + /** + * Interactive line editing and console scrollback. + */ + public static void Console(int key) { + + switch (key) { + case K_KP_SLASH : + key = '/'; + break; + case K_KP_MINUS : + key = '-'; + break; + case K_KP_PLUS : + key = '+'; + break; + case K_KP_HOME : + key = '7'; + break; + case K_KP_UPARROW : + key = '8'; + break; + case K_KP_PGUP : + key = '9'; + break; + case K_KP_LEFTARROW : + key = '4'; + break; + case K_KP_5 : + key = '5'; + break; + case K_KP_RIGHTARROW : + key = '6'; + break; + case K_KP_END : + key = '1'; + break; + case K_KP_DOWNARROW : + key = '2'; + break; + case K_KP_PGDN : + key = '3'; + break; + case K_KP_INS : + key = '0'; + break; + case K_KP_DEL : + key = '.'; + break; + } + + if (key == 'l') { + if (Globals.keydown[K_CTRL]) { + Cbuf.AddText("clear\n"); + return; + } + } + + if (key == K_ENTER || key == K_KP_ENTER) { + // backslash text are commands, else chat + if (Globals.key_lines[Globals.edit_line][1] == '\\' || Globals.key_lines[Globals.edit_line][1] == '/') + Cbuf.AddText( + new String(Globals.key_lines[Globals.edit_line], 2, Lib.strlen(Globals.key_lines[Globals.edit_line]) - 2)); + else + Cbuf.AddText( + new String(Globals.key_lines[Globals.edit_line], 1, Lib.strlen(Globals.key_lines[Globals.edit_line]) - 1)); + + + Cbuf.AddText("\n"); + + log.info(new String(Globals.key_lines[Globals.edit_line], 0, Lib.strlen(Globals.key_lines[Globals.edit_line]))); + Globals.edit_line = (Globals.edit_line + 1) & 31; + history_line = Globals.edit_line; + + Globals.key_lines[Globals.edit_line][0] = ']'; + Globals.key_linepos = 1; + if (Globals.cls.state == Defines.ca_disconnected) + SCR.UpdateScreen(); // force an update, because the command may take some time + return; + } + + if (key == K_TAB) { + // command completion + CompleteCommand(); + return; + } + + if ((key == K_BACKSPACE) || (key == K_LEFTARROW) || (key == K_KP_LEFTARROW) || ((key == 'h') && (Globals.keydown[K_CTRL]))) { + if (Globals.key_linepos > 1) + Globals.key_linepos--; + return; + } + + if ((key == K_UPARROW) || (key == K_KP_UPARROW) || ((key == 'p') && Globals.keydown[K_CTRL])) { + do { + history_line = (history_line - 1) & 31; + } + while (history_line != Globals.edit_line && Globals.key_lines[history_line][1] == 0); + if (history_line == Globals.edit_line) + history_line = (Globals.edit_line + 1) & 31; + //Lib.strcpy(Globals.key_lines[Globals.edit_line], Globals.key_lines[history_line]); + System.arraycopy(Globals.key_lines[history_line], 0, Globals.key_lines[Globals.edit_line], 0, Globals.key_lines[Globals.edit_line].length); + Globals.key_linepos = Lib.strlen(Globals.key_lines[Globals.edit_line]); + return; + } + + if ((key == K_DOWNARROW) || (key == K_KP_DOWNARROW) || ((key == 'n') && Globals.keydown[K_CTRL])) { + if (history_line == Globals.edit_line) + return; + do { + history_line = (history_line + 1) & 31; + } + while (history_line != Globals.edit_line && Globals.key_lines[history_line][1] == 0); + if (history_line == Globals.edit_line) { + Globals.key_lines[Globals.edit_line][0] = ']'; + Globals.key_linepos = 1; + } + else { + //Lib.strcpy(Globals.key_lines[Globals.edit_line], Globals.key_lines[history_line]); + System.arraycopy(Globals.key_lines[history_line], 0, Globals.key_lines[Globals.edit_line], 0, Globals.key_lines[Globals.edit_line].length); + Globals.key_linepos = Lib.strlen(Globals.key_lines[Globals.edit_line]); + } + return; + } + + if (key == K_PGUP || key == K_KP_PGUP) { + Globals.con.display -= 2; + return; + } + + if (key == K_PGDN || key == K_KP_PGDN) { + Globals.con.display += 2; + if (Globals.con.display > Globals.con.current) + Globals.con.display = Globals.con.current; + return; + } + + if (key == K_HOME || key == K_KP_HOME) { + Globals.con.display = Globals.con.current - Globals.con.totallines + 10; + return; + } + + if (key == K_END || key == K_KP_END) { + Globals.con.display = Globals.con.current; + return; + } + + if (key < 32 || key > 127) + return; // non printable + + if (Globals.key_linepos < Defines.MAXCMDLINE - 1) { + Globals.key_lines[Globals.edit_line][Globals.key_linepos] = (byte) key; + Globals.key_linepos++; + Globals.key_lines[Globals.edit_line][Globals.key_linepos] = 0; + } + + } + + private static void printCompletions(String type, Vector compl) { + StringBuilder sb = new StringBuilder(compl.size()); + for (int i = 0; i < compl.size(); i++) { + sb.append(compl.get(i)).append(' '); + } + //TODO потом убрать + while (type.startsWith("\n")) { type = type.substring(1); } + while (type.endsWith("\n")) { type = type.substring(0, type.lastIndexOf("\n")); } + while (type.endsWith("\r")) { type = type.substring(0, type.lastIndexOf("\r")); } + type = type.trim(); + log.info("{} {}", type, sb.toString()); + } + + static void CompleteCommand() { + + int start = 1; + if (key_lines[edit_line][start] == '\\' || key_lines[edit_line][start] == '/') + start++; + + int end = start; + while (key_lines[edit_line][end] != 0) end++; + + String s = new String(key_lines[edit_line], start, end-start); + + Vector cmds = Cmd.CompleteCommand(s); + Vector vars = Cvar.CompleteVariable(s); + + int c = cmds.size(); + int v = vars.size(); + + if ((c + v) > 1) { + if (c > 0) printCompletions("\nCommands:\n", cmds); + if (v > 0) printCompletions("\nVariables:\n", vars); + return; + } else if (c == 1) { + s = (String)cmds.get(0); + } else if (v == 1) { + s = (String)vars.get(0); + } else return; + + key_lines[edit_line][1] = '/'; + byte[] bytes = Lib.stringToBytes(s); + System.arraycopy(bytes, 0, key_lines[edit_line], 2, bytes.length); + key_linepos = bytes.length + 2; + key_lines[edit_line][key_linepos++] = ' '; + key_lines[edit_line][key_linepos] = 0; + + return; + } + + public static Runnable Bind_f = Key::Key_Bind_f; + + static void Key_Bind_f() { + int c = Cmd.Argc(); + + if (c < 2) { + Com.Printf("bind [command] : attach a command to a key\n"); + return; + } + int b = StringToKeynum(Cmd.Argv(1)); + if (b == -1) { + Com.Printf("\"" + Cmd.Argv(1) + "\" isn't a valid key\n"); + return; + } + + if (c == 2) { + if (Globals.keybindings[b] != null) + Com.Printf("\"" + Cmd.Argv(1) + "\" = \"" + Globals.keybindings[b] + "\"\n"); + else + Com.Printf("\"" + Cmd.Argv(1) + "\" is not bound\n"); + return; + } + + // copy the rest of the command line + String cmd = ""; // start out with a null string + for (int i = 2; i < c; i++) { + cmd += Cmd.Argv(i); + if (i != (c - 1)) + cmd += " "; + } + + SetBinding(b, cmd); + } + + static void SetBinding(int keynum, String binding) { + if (keynum == -1) + return; + + // free old bindings + Globals.keybindings[keynum] = null; + + Globals.keybindings[keynum] = binding; + } + + static Runnable Unbind_f = Key::Key_Unbind_f; + + static void Key_Unbind_f() { + + if (Cmd.Argc() != 2) { + Com.Printf("unbind : remove commands from a key\n"); + return; + } + + int b = Key.StringToKeynum(Cmd.Argv(1)); + if (b == -1) { + Com.Printf("\"" + Cmd.Argv(1) + "\" isn't a valid key\n"); + return; + } + + Key.SetBinding(b, null); + } + + static Runnable Unbindall_f = Key::Key_Unbindall_f; + + static void Key_Unbindall_f() { + for (int i = 0; i < 256; i++) + Key.SetBinding(i, null); + } + + static Runnable Bindlist_f = Key::Key_Bindlist_f; + + static void Key_Bindlist_f() { + for (int i = 0; i < 256; i++) + if (Globals.keybindings[i] != null && Globals.keybindings[i].length() != 0) + Com.Printf(Key.KeynumToString(i) + " \"" + Globals.keybindings[i] + "\"\n"); + } + + static void ClearStates() { + int i; + + Key.anykeydown = 0; + + for (i = 0; i < 256; i++) { + if (keydown[i] || key_repeats[i]!=0) + Event(i, false, 0); + keydown[i] = false; + key_repeats[i] = 0; + } + } + + public static void WriteBindings(RandomAccessFile f) { + for (int i = 0; i < 256; i++) + if (keybindings[i] != null && keybindings[i].length() > 0) + try { + f.writeBytes("bind " + KeynumToString(i) + " \"" + keybindings[i] + "\"\n"); + } catch (IOException e) {} + } } diff --git a/src/main/java/lwjake2/client/M.java b/src/main/java/lwjake2/client/M.java index 607e18f..e647111 100644 --- a/src/main/java/lwjake2/client/M.java +++ b/src/main/java/lwjake2/client/M.java @@ -92,9 +92,9 @@ public final class M { Math3D.VectorAdd(ent.s.origin, ent.mins, mins); Math3D.VectorAdd(ent.s.origin, ent.maxs, maxs); - // if all of the points under the corners are solid world, don't bother - // with the tougher checks - // the corners must be within 16 of the midpoint + // if all of the points under the corners are solid world, don't bother + // with the tougher checks + // the corners must be within 16 of the midpoint start[2] = mins[2] - 1; for (x = 0; x <= 1; x++) for (y = 0; y <= 1; y++) { @@ -103,11 +103,11 @@ public final class M { if (GameBase.gi.pointcontents.pointcontents(start) != Defines.CONTENTS_SOLID) { GameBase.c_no++; // - // check it for real... + // check it for real... // start[2] = mins[2]; - // the midpoint must be within 16 of the bottom + // the midpoint must be within 16 of the bottom start[0] = stop[0] = (mins[0] + maxs[0]) * 0.5f; start[1] = stop[1] = (mins[1] + maxs[1]) * 0.5f; stop[2] = start[2] - 2 * GameBase.STEPSIZE; @@ -119,7 +119,7 @@ public final class M { return false; mid = bottom = trace.endpos[2]; - // the corners must be within 16 of the midpoint + // the corners must be within 16 of the midpoint for (x = 0; x <= 1; x++) for (y = 0; y <= 1; y++) { start[0] = stop[0] = x != 0 ? maxs[0] : mins[0]; @@ -191,11 +191,11 @@ public final class M { && (ent.flags & (Defines.FL_FLY | Defines.FL_SWIM)) == 0) return; - // if the next step hits the enemy, return immediately + // if the next step hits the enemy, return immediately if (ent.enemy != null && SV.SV_CloseEnough(ent, ent.enemy, dist)) return; - // bump around... + // bump around... if ((Lib.rand() & 3) == 1 || !SV.SV_StepDirection(ent, ent.ideal_yaw, dist)) { if (ent.inuse) @@ -227,7 +227,7 @@ public final class M { int cont; // - // get waterlevel + // get waterlevel // point[0] = ent.s.origin[0]; point[1] = ent.s.origin[1]; diff --git a/src/main/java/lwjake2/client/Menu.java b/src/main/java/lwjake2/client/Menu.java index 4588bc3..596b350 100644 --- a/src/main/java/lwjake2/client/Menu.java +++ b/src/main/java/lwjake2/client/Menu.java @@ -67,7 +67,7 @@ public final class Menu extends Key { static KeyCallback m_keyfunc; - // ============================================================================= + // ============================================================================= /* Support Routines */ public final static int MAX_MENU_DEPTH = 8; @@ -220,8 +220,8 @@ public final class Menu extends Key { Com.Error(ERR_FATAL, "PopMenu: depth < 1"); if (0 < m_menudepth){ - m_drawfunc = m_layers[m_menudepth-1].draw; - m_keyfunc = m_layers[m_menudepth-1].key; + m_drawfunc = m_layers[m_menudepth-1].draw; + m_keyfunc = m_layers[m_menudepth-1].key; } if (0 == m_menudepth) @@ -1119,9 +1119,9 @@ public final class Menu extends Key { // Cvar.VariableValue("s_loadas8bit")); String s = Cvar.VariableString("s_impl"); for (int i = 0; i < s_drivers.length; i++) { - if (s.equals(s_drivers[i])) { - s_options_quality_list.curvalue = i; - } + if (s.equals(s_drivers[i])) { + s_options_quality_list.curvalue = i; + } } s_options_sensitivity_slider.curvalue = (sensitivity.value) * 2; @@ -1199,13 +1199,13 @@ public final class Menu extends Key { String current = s_drivers[s_options_quality_list.curvalue]; driverNotChanged = S.getDriverName().equals(current); // if (s_options_quality_list.curvalue != 0) { -// // Cvar.SetValue("s_khz", 22); -// // Cvar.SetValue("s_loadas8bit", 0); +// // Cvar.SetValue("s_khz", 22); +// // Cvar.SetValue("s_loadas8bit", 0); // driverNotChanged = S.getDriverName().equals("dummy"); // Cvar.Set("s_impl", "dummy"); // } else { -// // Cvar.SetValue("s_khz", 11); -// // Cvar.SetValue("s_loadas8bit", 1); +// // Cvar.SetValue("s_khz", 11); +// // Cvar.SetValue("s_loadas8bit", 1); // driverNotChanged = S.getDriverName().equals("joal"); // Cvar.Set("s_impl", "joal"); // } @@ -1215,7 +1215,7 @@ public final class Menu extends Key { if (driverNotChanged) { re.EndFrame(); } else { - Cvar.Set("s_impl", current); + Cvar.Set("s_impl", current); DrawTextBox(8, 120 - 48, 36, 3); Print(16 + 16, 120 - 48 + 8, "Restarting the sound system. This"); @@ -1240,15 +1240,15 @@ public final class Menu extends Key { static void Options_MenuInit() { - s_drivers = S.getDriverNames(); - s_labels = new String[s_drivers.length]; - for (int i = 0; i < s_drivers.length; i++) { - if ("dummy".equals(s_drivers[i])) { - s_labels[i] = "off"; - } else { - s_labels[i] = s_drivers[i]; - } - } + s_drivers = S.getDriverNames(); + s_labels = new String[s_drivers.length]; + for (int i = 0; i < s_drivers.length; i++) { + if ("dummy".equals(s_drivers[i])) { + s_labels[i] = "off"; + } else { + s_labels[i] = s_drivers[i]; + } + } win_noalttab = Cvar.Get("win_noalttab", "0", CVAR_ARCHIVE); @@ -1366,7 +1366,7 @@ public final class Menu extends Key { Menu_AddItem(s_options_menu, s_options_cdvolume_box); Menu_AddItem(s_options_menu, s_options_quality_list); - // Menu_AddItem(s_options_menu, s_options_compatibility_list); + // Menu_AddItem(s_options_menu, s_options_compatibility_list); Menu_AddItem(s_options_menu, s_options_sensitivity_slider); Menu_AddItem(s_options_menu, s_options_alwaysrun_box); Menu_AddItem(s_options_menu, s_options_invertmouse_box); @@ -1374,7 +1374,7 @@ public final class Menu extends Key { Menu_AddItem(s_options_menu, s_options_lookstrafe_box); Menu_AddItem(s_options_menu, s_options_freelook_box); Menu_AddItem(s_options_menu, s_options_crosshair_box); - // Menu_AddItem(s_options_menu, s_options_joystick_box); + // Menu_AddItem(s_options_menu, s_options_joystick_box); Menu_AddItem(s_options_menu, s_options_customize_options_action); Menu_AddItem(s_options_menu, s_options_defaults_action); Menu_AddItem(s_options_menu, s_options_console_action); @@ -1836,7 +1836,7 @@ public final class Menu extends Key { f = new QuakeFile(name, "r"); String str = f.readString(); if (str != null) - m_savestrings[i] = str; + m_savestrings[i] = str; f.close(); m_savevalid[i] = true; } catch (Exception e) { @@ -1882,7 +1882,7 @@ public final class Menu extends Key { static void LoadGame_MenuDraw() { Banner("m_banner_load_game"); - // Menu_AdjustCursor( &s_loadgame_menu, 1 ); + // Menu_AdjustCursor( &s_loadgame_menu, 1 ); Menu_Draw(s_loadgame_menu); } @@ -1998,8 +1998,8 @@ public final class Menu extends Key { static menuaction_s s_joinserver_server_actions[] = new menuaction_s[MAX_LOCAL_SERVERS]; - // user readable information - // network address + // user readable information + // network address static { for (int n = 0; n < MAX_LOCAL_SERVERS; n++) { local_server_netadr[n] = new netadr_t(); @@ -2189,8 +2189,8 @@ public final class Menu extends Key { s_maxclients_field.buffer = new StringBuffer("4"); s_startserver_dmoptions_action.statusbar = "N/A for cooperative"; } - // ===== - // PGM + // ===== + // PGM // ROGUE GAMES else if (fileSystem.developer_searchpath(2) == 2) { if (s_rules_box.curvalue == 2) // tag @@ -2204,8 +2204,8 @@ public final class Menu extends Key { * s_startserver_dmoptions_action.statusbar = null; } */ } - // PGM - // ===== + // PGM + // ===== } static void StartServerActionFunc() { @@ -2234,10 +2234,10 @@ public final class Menu extends Key { Cvar.SetValue("timelimit", ClampCvar(timelimit, timelimit)); Cvar.SetValue("fraglimit", ClampCvar(fraglimit, fraglimit)); Cvar.Set("hostname", s_hostname_field.buffer.toString()); - // Cvar.SetValue ("deathmatch", !s_rules_box.curvalue ); - // Cvar.SetValue ("coop", s_rules_box.curvalue ); + // Cvar.SetValue ("deathmatch", !s_rules_box.curvalue ); + // Cvar.SetValue ("coop", s_rules_box.curvalue ); - // PGM + // PGM if ((s_rules_box.curvalue < 2) || (fileSystem.developer_searchpath(2) != 2)) { Cvar.SetValue("deathmatch", 1 - s_rules_box.curvalue); Cvar.SetValue("coop", s_rules_box.curvalue); @@ -2249,7 +2249,7 @@ public final class Menu extends Key { // FIXME - this might need to depend on which game we're running Cvar.SetValue("gamerules", s_rules_box.curvalue); } - // PGM + // PGM spot = null; if (s_rules_box.curvalue == 1) // PGM @@ -2289,9 +2289,9 @@ public final class Menu extends Key { static void StartServer_MenuInit() { - // ======= - // PGM - // ======= + // ======= + // PGM + // ======= byte[] buffer = null; String mapsname; @@ -2306,14 +2306,14 @@ public final class Menu extends Key { // Check user dir first (default ~/.lwjake2) if ((fp = Lib.fopen(mapsname, "r")) == null) { - // Check base dir first (baseq2 folder) - mapsname = fileSystem.getBaseGamedir() + "/maps.lst"; - if ((fp = Lib.fopen(mapsname, "r")) == null) { - // Open the pak's maplist - buffer = fileSystem.loadFile("maps.lst"); - if (buffer == null) - Com.Error(ERR_DROP, "couldn't find maps.lst\n"); - } else { + // Check base dir first (baseq2 folder) + mapsname = fileSystem.getBaseGamedir() + "/maps.lst"; + if ((fp = Lib.fopen(mapsname, "r")) == null) { + // Open the pak's maplist + buffer = fileSystem.loadFile("maps.lst"); + if (buffer == null) + Com.Error(ERR_DROP, "couldn't find maps.lst\n"); + } else { try { int len = (int) fp.length(); buffer = new byte[len]; @@ -2375,12 +2375,12 @@ public final class Menu extends Key { s_rules_box.y = 20; s_rules_box.name = "rules"; - // PGM - rogue games only available with rogue DLL. + // PGM - rogue games only available with rogue DLL. if (fileSystem.developer_searchpath(2) == 2) s_rules_box.itemnames = dm_coop_names_rogue; else s_rules_box.itemnames = dm_coop_names; - // PGM + // PGM if (Cvar.VariableValue("coop") != 0) s_rules_box.curvalue = 1; @@ -2542,7 +2542,7 @@ public final class Menu extends Key { static menulist_s s_quad_drop_box = new menulist_s(); - // ROGUE + // ROGUE static menulist_s s_no_mines_box = new menulist_s(); static menulist_s s_no_nukes_box = new menulist_s(); @@ -2551,7 +2551,7 @@ public final class Menu extends Key { static menulist_s s_no_spheres_box = new menulist_s(); - // ROGUE + // ROGUE static void setvalue(int flags) { Cvar.SetValue("dmflags", flags); @@ -2633,8 +2633,8 @@ public final class Menu extends Key { bit = DF_QUAD_DROP; } - // ======= - // ROGUE + // ======= + // ROGUE else if (fileSystem.developer_searchpath(2) == 2) { if (f == s_no_mines_box) { bit = DF_NO_MINES; @@ -2646,8 +2646,8 @@ public final class Menu extends Key { bit = DF_NO_SPHERES; } } - // ROGUE - // ======= + // ROGUE + // ======= if (f != null) { if (f.curvalue == 0) @@ -2798,8 +2798,8 @@ public final class Menu extends Key { s_friendlyfire_box.itemnames = yes_no_names; s_friendlyfire_box.curvalue = (dmflags & DF_NO_FRIENDLY_FIRE) == 0 ? 1 : 0; - // ============ - // ROGUE + // ============ + // ROGUE if (fileSystem.developer_searchpath(2) == 2) { s_no_mines_box.type = MTYPE_SPINCONTROL; s_no_mines_box.x = 0; @@ -2834,8 +2834,8 @@ public final class Menu extends Key { s_no_spheres_box.curvalue = (dmflags & DF_NO_SPHERES) != 0 ? 1 : 0; } - // ROGUE - // ============ + // ROGUE + // ============ Menu_AddItem(s_dmoptions_menu, s_falls_box); Menu_AddItem(s_dmoptions_menu, s_weapons_stay_box); @@ -2853,16 +2853,16 @@ public final class Menu extends Key { Menu_AddItem(s_dmoptions_menu, s_quad_drop_box); Menu_AddItem(s_dmoptions_menu, s_friendlyfire_box); - // ======= - // ROGUE + // ======= + // ROGUE if (fileSystem.developer_searchpath(2) == 2) { Menu_AddItem(s_dmoptions_menu, s_no_mines_box); Menu_AddItem(s_dmoptions_menu, s_no_nukes_box); Menu_AddItem(s_dmoptions_menu, s_stack_double_box); Menu_AddItem(s_dmoptions_menu, s_no_spheres_box); } - // ROGUE - // ======= + // ROGUE + // ======= Menu_Center(s_dmoptions_menu); @@ -3647,7 +3647,7 @@ public final class Menu extends Key { PushMenu(Menu::Quit_Draw, Menu::Quit_Key); } - // ============================================================================= + // ============================================================================= /* Menu Subsystem */ /** diff --git a/src/main/java/lwjake2/client/SCR.java b/src/main/java/lwjake2/client/SCR.java index 447e76f..84aadcd 100644 --- a/src/main/java/lwjake2/client/SCR.java +++ b/src/main/java/lwjake2/client/SCR.java @@ -40,7 +40,7 @@ import java.util.Arrays; @Slf4j public final class SCR extends Globals { private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); - // cl_scrn.c -- master for refresh, status bar, console, chat, notify, etc + // cl_scrn.c -- master for refresh, status bar, console, chat, notify, etc static String[][] sb_nums = { { "num_0", "num_1", "num_2", "num_3", "num_4", "num_5", "num_6", @@ -132,11 +132,11 @@ public final class SCR extends Globals { * =============================================================================== */ - // typedef struct - // { - // float value; - // int color; - // } graphsamp_t; + // typedef struct + // { + // float value; + // int color; + // } graphsamp_t; static class graphsamp_t { float value; @@ -861,7 +861,7 @@ public final class SCR extends Globals { if (cls.state != ca_active || !cl.refresh_prepped) return; - // if (!s[0]) + // if (!s[0]) if (s == null || s.length() == 0) return; @@ -1238,12 +1238,12 @@ public final class SCR extends Globals { DrawFPS(); // - // if (scr_timegraph->value) - // SCR_DebugGraph (cls.frametime*300, 0); + // if (scr_timegraph->value) + // SCR_DebugGraph (cls.frametime*300, 0); // - // if (scr_debuggraph->value || scr_timegraph->value || + // if (scr_debuggraph->value || scr_timegraph->value || // scr_netgraph->value) - // SCR_DrawDebugGraph (); + // SCR_DrawDebugGraph (); // DrawPause(); DrawConsole(); @@ -1767,7 +1767,7 @@ public final class SCR extends Globals { if (!cl.cinematicpalette_active) { re.CinematicSetPalette(cl.cinematicpalette); - cl.cinematicpalette_active = true; + cl.cinematicpalette_active = true; } if (cin.pic == null) diff --git a/src/main/java/lwjake2/client/V.java b/src/main/java/lwjake2/client/V.java index 6b150b2..fb388c0 100644 --- a/src/main/java/lwjake2/client/V.java +++ b/src/main/java/lwjake2/client/V.java @@ -186,7 +186,7 @@ public final class V extends Globals { r_numentities = 32; //memset (r_entities, 0, sizeof(r_entities)); for (i = 0; i < r_entities.length; i++) - r_entities[i].clear(); + r_entities[i].clear(); for (i = 0; i < r_numentities; i++) { ent = r_entities[i]; @@ -261,7 +261,7 @@ public final class V extends Globals { * ================== */ static void RenderView(float stereo_separation) { - // extern int entitycmpfnc( const entity_t *, const entity_t * ); + // extern int entitycmpfnc( const entity_t *, const entity_t * ); // if (cls.state != ca_active) return; diff --git a/src/main/java/lwjake2/client/VID.java b/src/main/java/lwjake2/client/VID.java index 8298ec0..9e8163e 100644 --- a/src/main/java/lwjake2/client/VID.java +++ b/src/main/java/lwjake2/client/VID.java @@ -43,571 +43,571 @@ import java.awt.DisplayMode; */ @Slf4j public class VID extends Globals { - // Main windowed and fullscreen graphics interface module. This module - // is used for both the software and OpenGL rendering versions of the - // Quake refresh engine. - - // Global variables used internally by this module - // Globals.viddef - // global video state; used by other modules - - // Structure containing functions exported from refresh DLL - // Globals.re; - - // Console variables that we need to access from this module - static cvar_t vid_gamma; - static cvar_t vid_ref; // Name of Refresh DLL loaded - static cvar_t vid_xpos; // X coordinate of window position - static cvar_t vid_ypos; // Y coordinate of window position - static cvar_t vid_width; - static cvar_t vid_height; - static cvar_t vid_fullscreen; - - // Global variables used internally by this module - // void *reflib_library; // Handle to refresh DLL - static boolean reflib_active = false; - // const char so_file[] = "/etc/quake2.conf"; - - /* - ========================================================================== - - DLL GLUE - - ========================================================================== - */ - - public static void Printf(int print_level, String fmt) { - while (fmt.startsWith("\n")) { fmt = fmt.substring(1); } - while (fmt.endsWith("\n")) { fmt = fmt.substring(0, fmt.lastIndexOf("\n")); } - while (fmt.endsWith("\r")) { fmt = fmt.substring(0, fmt.lastIndexOf("\r")); } - fmt = fmt.trim(); - log.warn("{}", fmt); - } - - public static void Printf(int print_level, String fmt, Vargs vargs) { - // static qboolean inupdate; - if (print_level == Defines.PRINT_ALL) - Com.Printf(fmt, vargs); - else - Com.DPrintf(fmt, vargs); - } - - // ========================================================================== - - /* - ============ - VID_Restart_f - - Console command to re-start the video mode and refresh DLL. We do this - simply by setting the modified flag for the vid_ref variable, which will - cause the entire video mode and refresh DLL to be reset on the next frame. - ============ - */ - static void Restart_f() { - vid_modes[11].width = (int) vid_width.value; - vid_modes[11].height = (int) vid_height.value; - - vid_ref.modified = true; - } - - /* - ** VID_GetModeInfo - */ - static vidmode_t vid_modes[] = - { - new vidmode_t("Mode 0: 320x240", 320, 240, 0), - new vidmode_t("Mode 1: 400x300", 400, 300, 1), - new vidmode_t("Mode 2: 512x384", 512, 384, 2), - new vidmode_t("Mode 3: 640x480", 640, 480, 3), - new vidmode_t("Mode 4: 800x600", 800, 600, 4), - new vidmode_t("Mode 5: 960x720", 960, 720, 5), - new vidmode_t("Mode 6: 1024x768", 1024, 768, 6), - new vidmode_t("Mode 7: 1152x864", 1152, 864, 7), - new vidmode_t("Mode 8: 1280x1024", 1280, 1024, 8), - new vidmode_t("Mode 9: 1600x1200", 1600, 1200, 9), - new vidmode_t("Mode 10: 2048x1536", 2048, 1536, 10), - new vidmode_t("Mode 11: user", 640, 480, 11)}; - static vidmode_t fs_modes[]; - - public static boolean GetModeInfo(Dimension dim, int mode) { - if (fs_modes == null) initModeList(); - - vidmode_t[] modes = vid_modes; - if (vid_fullscreen.value != 0.0f) modes = fs_modes; - - if (mode < 0 || mode >= modes.length) - return false; - - dim.width = modes[mode].width; - dim.height = modes[mode].height; - - return true; - } - - /* - ** VID_NewWindow - */ - public static void NewWindow(int width, int height) { - Globals.viddef.width = width; - Globals.viddef.height = height; - } - - static void FreeReflib() - { - if (Globals.re != null) { - Globals.re.getKeyboardHandler().Close(); - IN.Shutdown(); - } - - Globals.re = null; - reflib_active = false; - } - - /* - ============== - VID_LoadRefresh - ============== - */ - static boolean LoadRefresh( String name ) - { - - if ( reflib_active ) - { - Globals.re.getKeyboardHandler().Close(); - IN.Shutdown(); - - Globals.re.Shutdown(); - FreeReflib(); - } - - log.info("------- Loading {} -------", name); - - - boolean found = false; - - String[] driverNames = Renderer.getDriverNames(); - for (int i = 0; i < driverNames.length; i++) { - if (driverNames[i].equals(name)) { - found = true; - break; - } - } - - if (!found) { - log.warn("LoadLibrary(\"{}\") failed", name); - return false; - } - - log.info("LoadLibrary(\"{}\")", name); - Globals.re = Renderer.getDriver(name); - - if (Globals.re == null) - { - Com.Error(Defines.ERR_FATAL, name + " can't load but registered"); - } - - if (Globals.re.apiVersion() != Defines.API_VERSION) - { - FreeReflib(); - Com.Error(Defines.ERR_FATAL, name + " has incompatible api_version"); - } - - IN.Real_IN_Init(); - - if ( !Globals.re.Init((int)vid_xpos.value, (int)vid_ypos.value) ) - { - Globals.re.Shutdown(); - FreeReflib(); - return false; - } - - /* Init KBD */ - Globals.re.getKeyboardHandler().Init(); - - log.info("------------------------------------"); - reflib_active = true; - return true; - } - - /* - ============ - VID_CheckChanges - - This function gets called once just before drawing each frame, and it's sole purpose in life - is to check to see if any of the video mode parameters have changed, and if they have to - update the rendering DLL and/or video mode to match. - ============ - */ - public static void CheckChanges() - { - cvar_t gl_mode; - - if ( vid_ref.modified ) - { - S.StopAllSounds(); - } - - while (vid_ref.modified) - { - /* - ** refresh has changed - */ - vid_ref.modified = false; - vid_fullscreen.modified = true; - Globals.cl.refresh_prepped = false; - Globals.cls.disable_screen = 1.0f; // true; - - - if ( !LoadRefresh( vid_ref.string ) ) - { - String renderer; - if (vid_ref.string.equals(Renderer.getPreferedName())) { - // try the default renderer as fallback after prefered - renderer = Renderer.getDefaultName(); - } else { - // try the prefered renderer as first fallback - renderer = Renderer.getPreferedName(); - } - if ( vid_ref.string.equals(Renderer.getDefaultName())) { - renderer = vid_ref.string; - log.info("Refresh failed"); - gl_mode = Cvar.Get( "gl_mode", "0", 0 ); - if (gl_mode.value != 0.0f) { - log.info("Trying mode 0"); - Cvar.SetValue("gl_mode", 0); - if ( !LoadRefresh( vid_ref.string ) ) - Com.Error(Defines.ERR_FATAL, "Couldn't fall back to " + renderer +" refresh!"); - } else - Com.Error(Defines.ERR_FATAL, "Couldn't fall back to " + renderer +" refresh!"); - } - - Cvar.Set("vid_ref", renderer); - - /* - * drop the console if we fail to load a refresh - */ - if ( Globals.cls.key_dest != Defines.key_console ) - { - try { - Console.ToggleConsole_f.run(); - } catch (Exception e) { - } - } - } - Globals.cls.disable_screen = 0.0f; //false; - } - } - - /* - ============ - VID_Init - ============ - */ - public static void Init() - { - /* Create the video variables so we know how to start the graphics drivers */ - vid_ref = Cvar.Get("vid_ref", Renderer.getPreferedName(), CVAR_ARCHIVE); - vid_xpos = Cvar.Get("vid_xpos", "3", CVAR_ARCHIVE); - vid_ypos = Cvar.Get("vid_ypos", "22", CVAR_ARCHIVE); - vid_width = Cvar.Get("vid_width", "640", CVAR_ARCHIVE); - vid_height = Cvar.Get("vid_height", "480", CVAR_ARCHIVE); - vid_fullscreen = Cvar.Get("vid_fullscreen", "0", CVAR_ARCHIVE); - vid_gamma = Cvar.Get( "vid_gamma", "1", CVAR_ARCHIVE ); - - vid_modes[11].width = (int)vid_width.value; - vid_modes[11].height = (int)vid_height.value; - - /* Add some console commands that we want to handle */ - Cmd.AddCommand ("vid_restart", VID::Restart_f); - - /* Disable the 3Dfx splash screen */ - // putenv("FX_GLIDE_NO_SPLASH=0"); - - /* Start the graphics mode and load refresh DLL */ - CheckChanges(); - } - - /* - ============ - VID_Shutdown - ============ - */ - public static void Shutdown() - { - if ( reflib_active ) - { - Globals.re.getKeyboardHandler().Close(); - IN.Shutdown(); - - Globals.re.Shutdown(); - FreeReflib(); - } - } - - // ========================================================================== - // - // vid_menu.c - // - // ========================================================================== - - static final int REF_OPENGL_JOGL = 0; - static final int REF_OPENGL_FASTJOGL =1; - static final int REF_OPENGL_LWJGL =2; - - static cvar_t gl_mode; - static cvar_t gl_driver; - static cvar_t gl_picmip; - static cvar_t gl_ext_palettedtexture; - - static cvar_t sw_mode; - static cvar_t sw_stipplealpha; - - static cvar_t _windowed_mouse; - - /* - ==================================================================== - - MENU INTERACTION - - ==================================================================== - */ - - static Menu.menuframework_s s_opengl_menu = new Menu.menuframework_s(); - static Menu.menuframework_s s_current_menu; // referenz - - static Menu.menulist_s s_mode_list = new Menu.menulist_s(); - - static Menu.menulist_s s_ref_list = new Menu.menulist_s(); - - static Menu.menuslider_s s_tq_slider = new Menu.menuslider_s(); - static Menu.menuslider_s s_screensize_slider = new Menu.menuslider_s(); - - static Menu.menuslider_s s_brightness_slider = new Menu.menuslider_s(); - - static Menu.menulist_s s_fs_box = new Menu.menulist_s(); - - static Menu.menulist_s s_stipple_box = new Menu.menulist_s(); - static Menu.menulist_s s_paletted_texture_box = new Menu.menulist_s(); - static Menu.menulist_s s_windowed_mouse = new Menu.menulist_s(); - static Menu.menuaction_s s_apply_action = new Menu.menuaction_s(); - - static Menu.menuaction_s s_defaults_action= new Menu.menuaction_s(); - - static void DriverCallback( Object unused ) - { - s_current_menu = s_opengl_menu; // s_software_menu; - } - - static void ScreenSizeCallback( Object s ) - { - Menu.menuslider_s slider = (Menu.menuslider_s) s; - - Cvar.SetValue( "viewsize", slider.curvalue * 10 ); - } - - static void BrightnessCallback( Object s ) - { - Menu.menuslider_s slider = (Menu.menuslider_s) s; - - // if ( stricmp( vid_ref.string, "soft" ) == 0 || - // stricmp( vid_ref.string, "softx" ) == 0 ) - if ( vid_ref.string.equalsIgnoreCase("soft") || - vid_ref.string.equalsIgnoreCase("softx") ) - { - float gamma = ( 0.8f - ( slider.curvalue/10.0f - 0.5f ) ) + 0.5f; - - Cvar.SetValue( "vid_gamma", gamma ); - } - } - - static void ResetDefaults( Object unused ) - { - MenuInit(); - } - - static void ApplyChanges( Object unused ) - { - - /* - ** invert sense so greater = brighter, and scale to a range of 0.5 to 1.3 - */ - // the original was modified, because on CRTs it was too dark. - // the slider range is [5; 13] - // gamma: [1.1; 0.7] - float gamma = ( 0.4f - ( s_brightness_slider.curvalue/20.0f - 0.25f ) ) + 0.7f; - // modulate: [1.0; 2.6] - float modulate = s_brightness_slider.curvalue * 0.2f; - - Cvar.SetValue( "vid_gamma", gamma ); - Cvar.SetValue( "gl_modulate", modulate); - Cvar.SetValue( "sw_stipplealpha", s_stipple_box.curvalue ); - Cvar.SetValue( "gl_picmip", 3 - s_tq_slider.curvalue ); - Cvar.SetValue( "vid_fullscreen", s_fs_box.curvalue ); - Cvar.SetValue( "gl_ext_palettedtexture", s_paletted_texture_box.curvalue ); - Cvar.SetValue( "gl_mode", s_mode_list.curvalue ); - Cvar.SetValue( "_windowed_mouse", s_windowed_mouse.curvalue); - - Cvar.Set( "vid_ref", drivers[s_ref_list.curvalue] ); - Cvar.Set( "gl_driver", drivers[s_ref_list.curvalue] ); - if (gl_driver.modified) - vid_ref.modified = true; - - Menu.ForceMenuOff(); - } - - static final String[] resolutions = - { - "[320 240 ]", - "[400 300 ]", - "[512 384 ]", - "[640 480 ]", - "[800 600 ]", - "[960 720 ]", - "[1024 768 ]", - "[1152 864 ]", - "[1280 1024]", - "[1600 1200]", - "[2048 1536]", - "user mode", - }; - static String[] fs_resolutions; - static int mode_x; - - static String[] refs; - static String[] drivers; - - static final String[] yesno_names = - { - "no", - "yes", - }; - - static void initModeList() { - DisplayMode[] modes = re.getModeList(); - fs_resolutions = new String[modes.length]; - fs_modes = new vidmode_t[modes.length]; - for (int i = 0; i < modes.length; i++) { - DisplayMode m = modes[i]; - StringBuffer sb = new StringBuffer(18); - sb.append('['); - sb.append(m.getWidth()); - sb.append(' '); - sb.append(m.getHeight()); - while (sb.length() < 10) sb.append(' '); - sb.append(']'); - fs_resolutions[i] = sb.toString(); - sb.setLength(0); - sb.append("Mode "); - sb.append(i); - sb.append(':'); - sb.append(m.getWidth()); - sb.append('x'); - sb.append(m.getHeight()); - fs_modes[i] = new vidmode_t(sb.toString(), m.getWidth(), m.getHeight(), i); - } - } - - private static void initRefs() { - drivers = Renderer.getDriverNames(); - refs = new String[drivers.length]; - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < drivers.length; i++) { - sb.setLength(0); - sb.append("[OpenGL ").append(drivers[i]); - while (sb.length() < 16) sb.append(" "); - sb.append("]"); - refs[i] = sb.toString(); - } - } - - /* - ** VID_MenuInit - */ - public static void MenuInit() { - - initRefs(); - - if ( gl_driver == null ) - gl_driver = Cvar.Get( "gl_driver", Renderer.getPreferedName(), 0 ); - if ( gl_picmip == null ) - gl_picmip = Cvar.Get( "gl_picmip", "0", 0 ); - if ( gl_mode == null) - gl_mode = Cvar.Get( "gl_mode", "3", 0 ); - if ( sw_mode == null ) - sw_mode = Cvar.Get( "sw_mode", "0", 0 ); - if ( gl_ext_palettedtexture == null ) - gl_ext_palettedtexture = Cvar.Get( "gl_ext_palettedtexture", "1", CVAR_ARCHIVE ); - - if ( sw_stipplealpha == null ) - sw_stipplealpha = Cvar.Get( "sw_stipplealpha", "0", CVAR_ARCHIVE ); - - if ( _windowed_mouse == null) - _windowed_mouse = Cvar.Get( "_windowed_mouse", "0", CVAR_ARCHIVE ); - - s_mode_list.curvalue = (int)gl_mode.value; - if (vid_fullscreen.value != 0.0f) { - s_mode_list.itemnames = fs_resolutions; - if (s_mode_list.curvalue >= fs_resolutions.length - 1) { - s_mode_list.curvalue = 0; - } - mode_x = fs_modes[s_mode_list.curvalue].width; - } else { - s_mode_list.itemnames = resolutions; - if (s_mode_list.curvalue >= resolutions.length - 1) { - s_mode_list.curvalue = 0; - } - mode_x = vid_modes[s_mode_list.curvalue].width; - } - - if ( SCR.scr_viewsize == null ) - SCR.scr_viewsize = Cvar.Get ("viewsize", "100", CVAR_ARCHIVE); - - s_screensize_slider.curvalue = (int)(SCR.scr_viewsize.value/10); - - for (int i = 0; i < drivers.length; i++) { - if (vid_ref.string.equals(drivers[i])) { - s_ref_list.curvalue = i; - } - } - - s_opengl_menu.x = (int)(viddef.width * 0.50f); - s_opengl_menu.nitems = 0; - - s_ref_list.type = MTYPE_SPINCONTROL; - s_ref_list.name = "driver"; - s_ref_list.x = 0; - s_ref_list.y = 0; - s_ref_list.callback = VID::DriverCallback; - s_ref_list.itemnames = refs; - - s_mode_list.type = MTYPE_SPINCONTROL; - s_mode_list.name = "video mode"; - s_mode_list.x = 0; - s_mode_list.y = 10; - - s_screensize_slider.type = MTYPE_SLIDER; - s_screensize_slider.x = 0; - s_screensize_slider.y = 20; - s_screensize_slider.name = "screen size"; - s_screensize_slider.minvalue = 3; - s_screensize_slider.maxvalue = 12; - s_screensize_slider.callback = VID::ScreenSizeCallback; - s_brightness_slider.type = MTYPE_SLIDER; - s_brightness_slider.x = 0; - s_brightness_slider.y = 30; - s_brightness_slider.name = "brightness"; - s_brightness_slider.callback = VID::BrightnessCallback; - s_brightness_slider.minvalue = 5; - s_brightness_slider.maxvalue = 13; - s_brightness_slider.curvalue = ( 1.3f - vid_gamma.value + 0.5f ) * 10; - - s_fs_box.type = MTYPE_SPINCONTROL; - s_fs_box.x = 0; - s_fs_box.y = 40; - s_fs_box.name = "fullscreen"; - s_fs_box.itemnames = yesno_names; - s_fs_box.curvalue = (int)vid_fullscreen.value; - s_fs_box.callback = o -> { + // Main windowed and fullscreen graphics interface module. This module + // is used for both the software and OpenGL rendering versions of the + // Quake refresh engine. + + // Global variables used internally by this module + // Globals.viddef + // global video state; used by other modules + + // Structure containing functions exported from refresh DLL + // Globals.re; + + // Console variables that we need to access from this module + static cvar_t vid_gamma; + static cvar_t vid_ref; // Name of Refresh DLL loaded + static cvar_t vid_xpos; // X coordinate of window position + static cvar_t vid_ypos; // Y coordinate of window position + static cvar_t vid_width; + static cvar_t vid_height; + static cvar_t vid_fullscreen; + + // Global variables used internally by this module + // void *reflib_library; // Handle to refresh DLL + static boolean reflib_active = false; + // const char so_file[] = "/etc/quake2.conf"; + + /* + ========================================================================== + + DLL GLUE + + ========================================================================== + */ + + public static void Printf(int print_level, String fmt) { + while (fmt.startsWith("\n")) { fmt = fmt.substring(1); } + while (fmt.endsWith("\n")) { fmt = fmt.substring(0, fmt.lastIndexOf("\n")); } + while (fmt.endsWith("\r")) { fmt = fmt.substring(0, fmt.lastIndexOf("\r")); } + fmt = fmt.trim(); + log.warn("{}", fmt); + } + + public static void Printf(int print_level, String fmt, Vargs vargs) { + // static qboolean inupdate; + if (print_level == Defines.PRINT_ALL) + Com.Printf(fmt, vargs); + else + Com.DPrintf(fmt, vargs); + } + + // ========================================================================== + + /* + ============ + VID_Restart_f + + Console command to re-start the video mode and refresh DLL. We do this + simply by setting the modified flag for the vid_ref variable, which will + cause the entire video mode and refresh DLL to be reset on the next frame. + ============ + */ + static void Restart_f() { + vid_modes[11].width = (int) vid_width.value; + vid_modes[11].height = (int) vid_height.value; + + vid_ref.modified = true; + } + + /* + ** VID_GetModeInfo + */ + static vidmode_t vid_modes[] = + { + new vidmode_t("Mode 0: 320x240", 320, 240, 0), + new vidmode_t("Mode 1: 400x300", 400, 300, 1), + new vidmode_t("Mode 2: 512x384", 512, 384, 2), + new vidmode_t("Mode 3: 640x480", 640, 480, 3), + new vidmode_t("Mode 4: 800x600", 800, 600, 4), + new vidmode_t("Mode 5: 960x720", 960, 720, 5), + new vidmode_t("Mode 6: 1024x768", 1024, 768, 6), + new vidmode_t("Mode 7: 1152x864", 1152, 864, 7), + new vidmode_t("Mode 8: 1280x1024", 1280, 1024, 8), + new vidmode_t("Mode 9: 1600x1200", 1600, 1200, 9), + new vidmode_t("Mode 10: 2048x1536", 2048, 1536, 10), + new vidmode_t("Mode 11: user", 640, 480, 11)}; + static vidmode_t fs_modes[]; + + public static boolean GetModeInfo(Dimension dim, int mode) { + if (fs_modes == null) initModeList(); + + vidmode_t[] modes = vid_modes; + if (vid_fullscreen.value != 0.0f) modes = fs_modes; + + if (mode < 0 || mode >= modes.length) + return false; + + dim.width = modes[mode].width; + dim.height = modes[mode].height; + + return true; + } + + /* + ** VID_NewWindow + */ + public static void NewWindow(int width, int height) { + Globals.viddef.width = width; + Globals.viddef.height = height; + } + + static void FreeReflib() + { + if (Globals.re != null) { + Globals.re.getKeyboardHandler().Close(); + IN.Shutdown(); + } + + Globals.re = null; + reflib_active = false; + } + + /* + ============== + VID_LoadRefresh + ============== + */ + static boolean LoadRefresh( String name ) + { + + if ( reflib_active ) + { + Globals.re.getKeyboardHandler().Close(); + IN.Shutdown(); + + Globals.re.Shutdown(); + FreeReflib(); + } + + log.info("------- Loading {} -------", name); + + + boolean found = false; + + String[] driverNames = Renderer.getDriverNames(); + for (int i = 0; i < driverNames.length; i++) { + if (driverNames[i].equals(name)) { + found = true; + break; + } + } + + if (!found) { + log.warn("LoadLibrary(\"{}\") failed", name); + return false; + } + + log.info("LoadLibrary(\"{}\")", name); + Globals.re = Renderer.getDriver(name); + + if (Globals.re == null) + { + Com.Error(Defines.ERR_FATAL, name + " can't load but registered"); + } + + if (Globals.re.apiVersion() != Defines.API_VERSION) + { + FreeReflib(); + Com.Error(Defines.ERR_FATAL, name + " has incompatible api_version"); + } + + IN.Real_IN_Init(); + + if ( !Globals.re.Init((int)vid_xpos.value, (int)vid_ypos.value) ) + { + Globals.re.Shutdown(); + FreeReflib(); + return false; + } + + /* Init KBD */ + Globals.re.getKeyboardHandler().Init(); + + log.info("------------------------------------"); + reflib_active = true; + return true; + } + + /* + ============ + VID_CheckChanges + + This function gets called once just before drawing each frame, and it's sole purpose in life + is to check to see if any of the video mode parameters have changed, and if they have to + update the rendering DLL and/or video mode to match. + ============ + */ + public static void CheckChanges() + { + cvar_t gl_mode; + + if ( vid_ref.modified ) + { + S.StopAllSounds(); + } + + while (vid_ref.modified) + { + /* + ** refresh has changed + */ + vid_ref.modified = false; + vid_fullscreen.modified = true; + Globals.cl.refresh_prepped = false; + Globals.cls.disable_screen = 1.0f; // true; + + + if ( !LoadRefresh( vid_ref.string ) ) + { + String renderer; + if (vid_ref.string.equals(Renderer.getPreferedName())) { + // try the default renderer as fallback after prefered + renderer = Renderer.getDefaultName(); + } else { + // try the prefered renderer as first fallback + renderer = Renderer.getPreferedName(); + } + if ( vid_ref.string.equals(Renderer.getDefaultName())) { + renderer = vid_ref.string; + log.info("Refresh failed"); + gl_mode = Cvar.Get( "gl_mode", "0", 0 ); + if (gl_mode.value != 0.0f) { + log.info("Trying mode 0"); + Cvar.SetValue("gl_mode", 0); + if ( !LoadRefresh( vid_ref.string ) ) + Com.Error(Defines.ERR_FATAL, "Couldn't fall back to " + renderer +" refresh!"); + } else + Com.Error(Defines.ERR_FATAL, "Couldn't fall back to " + renderer +" refresh!"); + } + + Cvar.Set("vid_ref", renderer); + + /* + * drop the console if we fail to load a refresh + */ + if ( Globals.cls.key_dest != Defines.key_console ) + { + try { + Console.ToggleConsole_f.run(); + } catch (Exception e) { + } + } + } + Globals.cls.disable_screen = 0.0f; //false; + } + } + + /* + ============ + VID_Init + ============ + */ + public static void Init() + { + /* Create the video variables so we know how to start the graphics drivers */ + vid_ref = Cvar.Get("vid_ref", Renderer.getPreferedName(), CVAR_ARCHIVE); + vid_xpos = Cvar.Get("vid_xpos", "3", CVAR_ARCHIVE); + vid_ypos = Cvar.Get("vid_ypos", "22", CVAR_ARCHIVE); + vid_width = Cvar.Get("vid_width", "640", CVAR_ARCHIVE); + vid_height = Cvar.Get("vid_height", "480", CVAR_ARCHIVE); + vid_fullscreen = Cvar.Get("vid_fullscreen", "0", CVAR_ARCHIVE); + vid_gamma = Cvar.Get( "vid_gamma", "1", CVAR_ARCHIVE ); + + vid_modes[11].width = (int)vid_width.value; + vid_modes[11].height = (int)vid_height.value; + + /* Add some console commands that we want to handle */ + Cmd.AddCommand ("vid_restart", VID::Restart_f); + + /* Disable the 3Dfx splash screen */ + // putenv("FX_GLIDE_NO_SPLASH=0"); + + /* Start the graphics mode and load refresh DLL */ + CheckChanges(); + } + + /* + ============ + VID_Shutdown + ============ + */ + public static void Shutdown() + { + if ( reflib_active ) + { + Globals.re.getKeyboardHandler().Close(); + IN.Shutdown(); + + Globals.re.Shutdown(); + FreeReflib(); + } + } + + // ========================================================================== + // + // vid_menu.c + // + // ========================================================================== + + static final int REF_OPENGL_JOGL = 0; + static final int REF_OPENGL_FASTJOGL =1; + static final int REF_OPENGL_LWJGL =2; + + static cvar_t gl_mode; + static cvar_t gl_driver; + static cvar_t gl_picmip; + static cvar_t gl_ext_palettedtexture; + + static cvar_t sw_mode; + static cvar_t sw_stipplealpha; + + static cvar_t _windowed_mouse; + + /* + ==================================================================== + + MENU INTERACTION + + ==================================================================== + */ + + static Menu.menuframework_s s_opengl_menu = new Menu.menuframework_s(); + static Menu.menuframework_s s_current_menu; // referenz + + static Menu.menulist_s s_mode_list = new Menu.menulist_s(); + + static Menu.menulist_s s_ref_list = new Menu.menulist_s(); + + static Menu.menuslider_s s_tq_slider = new Menu.menuslider_s(); + static Menu.menuslider_s s_screensize_slider = new Menu.menuslider_s(); + + static Menu.menuslider_s s_brightness_slider = new Menu.menuslider_s(); + + static Menu.menulist_s s_fs_box = new Menu.menulist_s(); + + static Menu.menulist_s s_stipple_box = new Menu.menulist_s(); + static Menu.menulist_s s_paletted_texture_box = new Menu.menulist_s(); + static Menu.menulist_s s_windowed_mouse = new Menu.menulist_s(); + static Menu.menuaction_s s_apply_action = new Menu.menuaction_s(); + + static Menu.menuaction_s s_defaults_action= new Menu.menuaction_s(); + + static void DriverCallback( Object unused ) + { + s_current_menu = s_opengl_menu; // s_software_menu; + } + + static void ScreenSizeCallback( Object s ) + { + Menu.menuslider_s slider = (Menu.menuslider_s) s; + + Cvar.SetValue( "viewsize", slider.curvalue * 10 ); + } + + static void BrightnessCallback( Object s ) + { + Menu.menuslider_s slider = (Menu.menuslider_s) s; + + // if ( stricmp( vid_ref.string, "soft" ) == 0 || + // stricmp( vid_ref.string, "softx" ) == 0 ) + if ( vid_ref.string.equalsIgnoreCase("soft") || + vid_ref.string.equalsIgnoreCase("softx") ) + { + float gamma = ( 0.8f - ( slider.curvalue/10.0f - 0.5f ) ) + 0.5f; + + Cvar.SetValue( "vid_gamma", gamma ); + } + } + + static void ResetDefaults( Object unused ) + { + MenuInit(); + } + + static void ApplyChanges( Object unused ) + { + + /* + ** invert sense so greater = brighter, and scale to a range of 0.5 to 1.3 + */ + // the original was modified, because on CRTs it was too dark. + // the slider range is [5; 13] + // gamma: [1.1; 0.7] + float gamma = ( 0.4f - ( s_brightness_slider.curvalue/20.0f - 0.25f ) ) + 0.7f; + // modulate: [1.0; 2.6] + float modulate = s_brightness_slider.curvalue * 0.2f; + + Cvar.SetValue( "vid_gamma", gamma ); + Cvar.SetValue( "gl_modulate", modulate); + Cvar.SetValue( "sw_stipplealpha", s_stipple_box.curvalue ); + Cvar.SetValue( "gl_picmip", 3 - s_tq_slider.curvalue ); + Cvar.SetValue( "vid_fullscreen", s_fs_box.curvalue ); + Cvar.SetValue( "gl_ext_palettedtexture", s_paletted_texture_box.curvalue ); + Cvar.SetValue( "gl_mode", s_mode_list.curvalue ); + Cvar.SetValue( "_windowed_mouse", s_windowed_mouse.curvalue); + + Cvar.Set( "vid_ref", drivers[s_ref_list.curvalue] ); + Cvar.Set( "gl_driver", drivers[s_ref_list.curvalue] ); + if (gl_driver.modified) + vid_ref.modified = true; + + Menu.ForceMenuOff(); + } + + static final String[] resolutions = + { + "[320 240 ]", + "[400 300 ]", + "[512 384 ]", + "[640 480 ]", + "[800 600 ]", + "[960 720 ]", + "[1024 768 ]", + "[1152 864 ]", + "[1280 1024]", + "[1600 1200]", + "[2048 1536]", + "user mode", + }; + static String[] fs_resolutions; + static int mode_x; + + static String[] refs; + static String[] drivers; + + static final String[] yesno_names = + { + "no", + "yes", + }; + + static void initModeList() { + DisplayMode[] modes = re.getModeList(); + fs_resolutions = new String[modes.length]; + fs_modes = new vidmode_t[modes.length]; + for (int i = 0; i < modes.length; i++) { + DisplayMode m = modes[i]; + StringBuffer sb = new StringBuffer(18); + sb.append('['); + sb.append(m.getWidth()); + sb.append(' '); + sb.append(m.getHeight()); + while (sb.length() < 10) sb.append(' '); + sb.append(']'); + fs_resolutions[i] = sb.toString(); + sb.setLength(0); + sb.append("Mode "); + sb.append(i); + sb.append(':'); + sb.append(m.getWidth()); + sb.append('x'); + sb.append(m.getHeight()); + fs_modes[i] = new vidmode_t(sb.toString(), m.getWidth(), m.getHeight(), i); + } + } + + private static void initRefs() { + drivers = Renderer.getDriverNames(); + refs = new String[drivers.length]; + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < drivers.length; i++) { + sb.setLength(0); + sb.append("[OpenGL ").append(drivers[i]); + while (sb.length() < 16) sb.append(" "); + sb.append("]"); + refs[i] = sb.toString(); + } + } + + /* + ** VID_MenuInit + */ + public static void MenuInit() { + + initRefs(); + + if ( gl_driver == null ) + gl_driver = Cvar.Get( "gl_driver", Renderer.getPreferedName(), 0 ); + if ( gl_picmip == null ) + gl_picmip = Cvar.Get( "gl_picmip", "0", 0 ); + if ( gl_mode == null) + gl_mode = Cvar.Get( "gl_mode", "3", 0 ); + if ( sw_mode == null ) + sw_mode = Cvar.Get( "sw_mode", "0", 0 ); + if ( gl_ext_palettedtexture == null ) + gl_ext_palettedtexture = Cvar.Get( "gl_ext_palettedtexture", "1", CVAR_ARCHIVE ); + + if ( sw_stipplealpha == null ) + sw_stipplealpha = Cvar.Get( "sw_stipplealpha", "0", CVAR_ARCHIVE ); + + if ( _windowed_mouse == null) + _windowed_mouse = Cvar.Get( "_windowed_mouse", "0", CVAR_ARCHIVE ); + + s_mode_list.curvalue = (int)gl_mode.value; + if (vid_fullscreen.value != 0.0f) { + s_mode_list.itemnames = fs_resolutions; + if (s_mode_list.curvalue >= fs_resolutions.length - 1) { + s_mode_list.curvalue = 0; + } + mode_x = fs_modes[s_mode_list.curvalue].width; + } else { + s_mode_list.itemnames = resolutions; + if (s_mode_list.curvalue >= resolutions.length - 1) { + s_mode_list.curvalue = 0; + } + mode_x = vid_modes[s_mode_list.curvalue].width; + } + + if ( SCR.scr_viewsize == null ) + SCR.scr_viewsize = Cvar.Get ("viewsize", "100", CVAR_ARCHIVE); + + s_screensize_slider.curvalue = (int)(SCR.scr_viewsize.value/10); + + for (int i = 0; i < drivers.length; i++) { + if (vid_ref.string.equals(drivers[i])) { + s_ref_list.curvalue = i; + } + } + + s_opengl_menu.x = (int)(viddef.width * 0.50f); + s_opengl_menu.nitems = 0; + + s_ref_list.type = MTYPE_SPINCONTROL; + s_ref_list.name = "driver"; + s_ref_list.x = 0; + s_ref_list.y = 0; + s_ref_list.callback = VID::DriverCallback; + s_ref_list.itemnames = refs; + + s_mode_list.type = MTYPE_SPINCONTROL; + s_mode_list.name = "video mode"; + s_mode_list.x = 0; + s_mode_list.y = 10; + + s_screensize_slider.type = MTYPE_SLIDER; + s_screensize_slider.x = 0; + s_screensize_slider.y = 20; + s_screensize_slider.name = "screen size"; + s_screensize_slider.minvalue = 3; + s_screensize_slider.maxvalue = 12; + s_screensize_slider.callback = VID::ScreenSizeCallback; + s_brightness_slider.type = MTYPE_SLIDER; + s_brightness_slider.x = 0; + s_brightness_slider.y = 30; + s_brightness_slider.name = "brightness"; + s_brightness_slider.callback = VID::BrightnessCallback; + s_brightness_slider.minvalue = 5; + s_brightness_slider.maxvalue = 13; + s_brightness_slider.curvalue = ( 1.3f - vid_gamma.value + 0.5f ) * 10; + + s_fs_box.type = MTYPE_SPINCONTROL; + s_fs_box.x = 0; + s_fs_box.y = 40; + s_fs_box.name = "fullscreen"; + s_fs_box.itemnames = yesno_names; + s_fs_box.curvalue = (int)vid_fullscreen.value; + s_fs_box.callback = o -> { int fs = ((Menu.menulist_s)o).curvalue; if (fs == 0) { s_mode_list.itemnames = resolutions; @@ -622,125 +622,125 @@ public class VID extends Globals { } }; - s_defaults_action.type = MTYPE_ACTION; - s_defaults_action.name = "reset to default"; - s_defaults_action.x = 0; - s_defaults_action.y = 90; - s_defaults_action.callback = VID::ResetDefaults; + s_defaults_action.type = MTYPE_ACTION; + s_defaults_action.name = "reset to default"; + s_defaults_action.x = 0; + s_defaults_action.y = 90; + s_defaults_action.callback = VID::ResetDefaults; - s_apply_action.type = MTYPE_ACTION; - s_apply_action.name = "apply"; - s_apply_action.x = 0; - s_apply_action.y = 100; - s_apply_action.callback = VID::ApplyChanges; - + s_apply_action.type = MTYPE_ACTION; + s_apply_action.name = "apply"; + s_apply_action.x = 0; + s_apply_action.y = 100; + s_apply_action.callback = VID::ApplyChanges; - s_stipple_box.type = MTYPE_SPINCONTROL; - s_stipple_box.x = 0; - s_stipple_box.y = 60; - s_stipple_box.name = "stipple alpha"; - s_stipple_box.curvalue = (int)sw_stipplealpha.value; - s_stipple_box.itemnames = yesno_names; - s_windowed_mouse.type = MTYPE_SPINCONTROL; - s_windowed_mouse.x = 0; - s_windowed_mouse.y = 72; - s_windowed_mouse.name = "windowed mouse"; - s_windowed_mouse.curvalue = (int)_windowed_mouse.value; - s_windowed_mouse.itemnames = yesno_names; + s_stipple_box.type = MTYPE_SPINCONTROL; + s_stipple_box.x = 0; + s_stipple_box.y = 60; + s_stipple_box.name = "stipple alpha"; + s_stipple_box.curvalue = (int)sw_stipplealpha.value; + s_stipple_box.itemnames = yesno_names; - s_tq_slider.type = MTYPE_SLIDER; - s_tq_slider.x = 0; - s_tq_slider.y = 60; - s_tq_slider.name = "texture quality"; - s_tq_slider.minvalue = 0; - s_tq_slider.maxvalue = 3; - s_tq_slider.curvalue = 3 - gl_picmip.value; + s_windowed_mouse.type = MTYPE_SPINCONTROL; + s_windowed_mouse.x = 0; + s_windowed_mouse.y = 72; + s_windowed_mouse.name = "windowed mouse"; + s_windowed_mouse.curvalue = (int)_windowed_mouse.value; + s_windowed_mouse.itemnames = yesno_names; - s_paletted_texture_box.type = MTYPE_SPINCONTROL; - s_paletted_texture_box.x = 0; - s_paletted_texture_box.y = 70; - s_paletted_texture_box.name = "8-bit textures"; - s_paletted_texture_box.itemnames = yesno_names; - s_paletted_texture_box.curvalue = (int)gl_ext_palettedtexture.value; + s_tq_slider.type = MTYPE_SLIDER; + s_tq_slider.x = 0; + s_tq_slider.y = 60; + s_tq_slider.name = "texture quality"; + s_tq_slider.minvalue = 0; + s_tq_slider.maxvalue = 3; + s_tq_slider.curvalue = 3 - gl_picmip.value; - Menu.Menu_AddItem( s_opengl_menu, s_ref_list ); - Menu.Menu_AddItem( s_opengl_menu, s_mode_list ); - Menu.Menu_AddItem( s_opengl_menu, s_screensize_slider ); - Menu.Menu_AddItem( s_opengl_menu, s_brightness_slider ); - Menu.Menu_AddItem( s_opengl_menu, s_fs_box ); - Menu.Menu_AddItem( s_opengl_menu, s_tq_slider ); - Menu.Menu_AddItem( s_opengl_menu, s_paletted_texture_box ); + s_paletted_texture_box.type = MTYPE_SPINCONTROL; + s_paletted_texture_box.x = 0; + s_paletted_texture_box.y = 70; + s_paletted_texture_box.name = "8-bit textures"; + s_paletted_texture_box.itemnames = yesno_names; + s_paletted_texture_box.curvalue = (int)gl_ext_palettedtexture.value; - Menu.Menu_AddItem( s_opengl_menu, s_defaults_action ); - Menu.Menu_AddItem( s_opengl_menu, s_apply_action ); + Menu.Menu_AddItem( s_opengl_menu, s_ref_list ); + Menu.Menu_AddItem( s_opengl_menu, s_mode_list ); + Menu.Menu_AddItem( s_opengl_menu, s_screensize_slider ); + Menu.Menu_AddItem( s_opengl_menu, s_brightness_slider ); + Menu.Menu_AddItem( s_opengl_menu, s_fs_box ); + Menu.Menu_AddItem( s_opengl_menu, s_tq_slider ); + Menu.Menu_AddItem( s_opengl_menu, s_paletted_texture_box ); - Menu.Menu_Center( s_opengl_menu ); - s_opengl_menu.x -= 8; - } + Menu.Menu_AddItem( s_opengl_menu, s_defaults_action ); + Menu.Menu_AddItem( s_opengl_menu, s_apply_action ); - /* - ================ - VID_MenuDraw - ================ - */ - static void MenuDraw() - { - s_current_menu = s_opengl_menu; + Menu.Menu_Center( s_opengl_menu ); + s_opengl_menu.x -= 8; + } - /* - ** draw the banner - */ - Dimension dim = new Dimension(); - re.DrawGetPicSize( dim, "m_banner_video" ); - re.DrawPic( viddef.width / 2 - dim.width / 2, viddef.height /2 - 110, "m_banner_video" ); + /* + ================ + VID_MenuDraw + ================ + */ + static void MenuDraw() + { + s_current_menu = s_opengl_menu; - /* - ** move cursor to a reasonable starting position - */ - Menu.Menu_AdjustCursor( s_current_menu, 1 ); + /* + ** draw the banner + */ + Dimension dim = new Dimension(); + re.DrawGetPicSize( dim, "m_banner_video" ); + re.DrawPic( viddef.width / 2 - dim.width / 2, viddef.height /2 - 110, "m_banner_video" ); - /* - ** draw the menu - */ - Menu.Menu_Draw( s_current_menu ); - } + /* + ** move cursor to a reasonable starting position + */ + Menu.Menu_AdjustCursor( s_current_menu, 1 ); - /* - ================ - VID_MenuKey - ================ - */ - static String MenuKey( int key ) - { - Menu.menuframework_s m = s_current_menu; - final String sound = "misc/menu1.wav"; + /* + ** draw the menu + */ + Menu.Menu_Draw( s_current_menu ); + } - switch ( key ) - { - case K_ESCAPE: - Menu.PopMenu(); - return null; - case K_UPARROW: - m.cursor--; - Menu.Menu_AdjustCursor( m, -1 ); - break; - case K_DOWNARROW: - m.cursor++; - Menu.Menu_AdjustCursor( m, 1 ); - break; - case K_LEFTARROW: - Menu.Menu_SlideItem( m, -1 ); - break; - case K_RIGHTARROW: - Menu.Menu_SlideItem( m, 1 ); - break; - case K_ENTER: - Menu.Menu_SelectItem( m ); - break; - } + /* + ================ + VID_MenuKey + ================ + */ + static String MenuKey( int key ) + { + Menu.menuframework_s m = s_current_menu; + final String sound = "misc/menu1.wav"; - return sound; - } + switch ( key ) + { + case K_ESCAPE: + Menu.PopMenu(); + return null; + case K_UPARROW: + m.cursor--; + Menu.Menu_AdjustCursor( m, -1 ); + break; + case K_DOWNARROW: + m.cursor++; + Menu.Menu_AdjustCursor( m, 1 ); + break; + case K_LEFTARROW: + Menu.Menu_SlideItem( m, -1 ); + break; + case K_RIGHTARROW: + Menu.Menu_SlideItem( m, 1 ); + break; + case K_ENTER: + Menu.Menu_SelectItem( m ); + break; + } + + return sound; + } } diff --git a/src/main/java/lwjake2/client/centity_t.java b/src/main/java/lwjake2/client/centity_t.java index aa3f9f7..2c6a1ea 100644 --- a/src/main/java/lwjake2/client/centity_t.java +++ b/src/main/java/lwjake2/client/centity_t.java @@ -21,14 +21,14 @@ package lwjake2.client; import lwjake2.game.entity_state_t; public class centity_t { - entity_state_t baseline= new entity_state_t(null); // delta from this if not from a previous frame - public entity_state_t current= new entity_state_t(null); - entity_state_t prev= new entity_state_t(null); // will always be valid, but might just be a copy of current + entity_state_t baseline= new entity_state_t(null); // delta from this if not from a previous frame + public entity_state_t current= new entity_state_t(null); + entity_state_t prev= new entity_state_t(null); // will always be valid, but might just be a copy of current - int serverframe; // if not current, this ent isn't in the frame + int serverframe; // if not current, this ent isn't in the frame - int trailcount; // for diminishing grenade trails - float[] lerp_origin = { 0, 0, 0 }; // for trails (variable hz) + int trailcount; // for diminishing grenade trails + float[] lerp_origin = { 0, 0, 0 }; // for trails (variable hz) - int fly_stoptime; + int fly_stoptime; } diff --git a/src/main/java/lwjake2/client/cl_sustain_t.java b/src/main/java/lwjake2/client/cl_sustain_t.java index fb335c7..d910372 100644 --- a/src/main/java/lwjake2/client/cl_sustain_t.java +++ b/src/main/java/lwjake2/client/cl_sustain_t.java @@ -22,27 +22,27 @@ package lwjake2.client; * cl_sustain_t */ public class cl_sustain_t { - static abstract class ThinkAdapter { - abstract void think(cl_sustain_t self); - } - - int id; - int type; - int endtime; - int nextthink; - int thinkinterval; - float[] org = new float[3]; - float[] dir = new float[3]; - int color; - int count; - int magnitude; - - ThinkAdapter think; - - void clear() { - org[0] = org[1] = org[2] = - dir[0] = dir[1] = dir[2] = - id = type = endtime = nextthink = thinkinterval = color = count = magnitude = 0; - think = null; - } + static abstract class ThinkAdapter { + abstract void think(cl_sustain_t self); + } + + int id; + int type; + int endtime; + int nextthink; + int thinkinterval; + float[] org = new float[3]; + float[] dir = new float[3]; + int color; + int count; + int magnitude; + + ThinkAdapter think; + + void clear() { + org[0] = org[1] = org[2] = + dir[0] = dir[1] = dir[2] = + id = type = endtime = nextthink = thinkinterval = color = count = magnitude = 0; + think = null; + } } diff --git a/src/main/java/lwjake2/client/client_state_t.java b/src/main/java/lwjake2/client/client_state_t.java index 190a1f2..375135d 100644 --- a/src/main/java/lwjake2/client/client_state_t.java +++ b/src/main/java/lwjake2/client/client_state_t.java @@ -29,105 +29,105 @@ import java.nio.ByteBuffer; public class client_state_t { - public client_state_t() { - for (int n = 0; n < Defines.CMD_BACKUP; n++) - cmds[n] = new usercmd_t(); - for (int i = 0; i < frames.length; i++) { - frames[i] = new frame_t(); - } + public client_state_t() { + for (int n = 0; n < Defines.CMD_BACKUP; n++) + cmds[n] = new usercmd_t(); + for (int i = 0; i < frames.length; i++) { + frames[i] = new frame_t(); + } - for (int n = 0; n < Defines.MAX_CONFIGSTRINGS; n++) - configstrings[n] = new String(); - - for (int n=0; n < Defines.MAX_CLIENTS; n++) - clientinfo[n] = new clientinfo_t(); - } - // - // the client_state_t structure is wiped completely at every - // server map change - // - int timeoutcount; + for (int n = 0; n < Defines.MAX_CONFIGSTRINGS; n++) + configstrings[n] = new String(); + + for (int n=0; n < Defines.MAX_CLIENTS; n++) + clientinfo[n] = new clientinfo_t(); + } + // + // the client_state_t structure is wiped completely at every + // server map change + // + int timeoutcount; - int timedemo_frames; - int timedemo_start; + int timedemo_frames; + int timedemo_start; - public boolean refresh_prepped; // false if on new level or new ref dll - public boolean sound_prepped; // ambient sounds can start - boolean force_refdef; // vid has changed, so we can't use a paused refdef + public boolean refresh_prepped; // false if on new level or new ref dll + public boolean sound_prepped; // ambient sounds can start + boolean force_refdef; // vid has changed, so we can't use a paused refdef - int parse_entities; // index (not anded off) into cl_parse_entities[] + int parse_entities; // index (not anded off) into cl_parse_entities[] - usercmd_t cmd = new usercmd_t(); - usercmd_t cmds[] = new usercmd_t[Defines.CMD_BACKUP]; // each mesage will send several old cmds + usercmd_t cmd = new usercmd_t(); + usercmd_t cmds[] = new usercmd_t[Defines.CMD_BACKUP]; // each mesage will send several old cmds - int cmd_time[] = new int[Defines.CMD_BACKUP]; // time sent, for calculating pings - short predicted_origins[][] = new short[Defines.CMD_BACKUP][3]; // for debug comparing against server + int cmd_time[] = new int[Defines.CMD_BACKUP]; // time sent, for calculating pings + short predicted_origins[][] = new short[Defines.CMD_BACKUP][3]; // for debug comparing against server - float predicted_step; // for stair up smoothing - int predicted_step_time; + float predicted_step; // for stair up smoothing + int predicted_step_time; - float[] predicted_origin ={0,0,0}; // generated by CL_PredictMovement - float[] predicted_angles={0,0,0}; - float[] prediction_error={0,0,0}; + float[] predicted_origin ={0,0,0}; // generated by CL_PredictMovement + float[] predicted_angles={0,0,0}; + float[] prediction_error={0,0,0}; - public frame_t frame = new frame_t(); // received from server - int surpressCount; // number of messages rate supressed - frame_t frames[] = new frame_t[Defines.UPDATE_BACKUP]; + public frame_t frame = new frame_t(); // received from server + int surpressCount; // number of messages rate supressed + frame_t frames[] = new frame_t[Defines.UPDATE_BACKUP]; - // the client maintains its own idea of view angles, which are - // sent to the server each frame. It is cleared to 0 upon entering each level. - // the server sends a delta each frame which is added to the locally - // tracked view angles to account for standing on rotating objects, - // and teleport direction changes - public float[] viewangles = { 0, 0, 0 }; + // the client maintains its own idea of view angles, which are + // sent to the server each frame. It is cleared to 0 upon entering each level. + // the server sends a delta each frame which is added to the locally + // tracked view angles to account for standing on rotating objects, + // and teleport direction changes + public float[] viewangles = { 0, 0, 0 }; - public int time; // this is the time value that the client - // is rendering at. always <= cls.realtime - float lerpfrac; // between oldframe and frame + public int time; // this is the time value that the client + // is rendering at. always <= cls.realtime + float lerpfrac; // between oldframe and frame - refdef_t refdef = new refdef_t(); + refdef_t refdef = new refdef_t(); - float[] v_forward = { 0, 0, 0 }; - float[] v_right = { 0, 0, 0 }; - float[] v_up = { 0, 0, 0 }; // set when refdef.angles is set + float[] v_forward = { 0, 0, 0 }; + float[] v_right = { 0, 0, 0 }; + float[] v_up = { 0, 0, 0 }; // set when refdef.angles is set - // - // transient data from server - // + // + // transient data from server + // - String layout = ""; // general 2D overlay - int inventory[] = new int[Defines.MAX_ITEMS]; + String layout = ""; // general 2D overlay + int inventory[] = new int[Defines.MAX_ITEMS]; - // - // non-gameserver infornamtion - // FIXME: move this cinematic stuff into the cin_t structure - ByteBuffer cinematic_file; - - int cinematictime; // cls.realtime for first cinematic frame - int cinematicframe; - byte cinematicpalette[] = new byte[768]; - boolean cinematicpalette_active; + // + // non-gameserver infornamtion + // FIXME: move this cinematic stuff into the cin_t structure + ByteBuffer cinematic_file; + + int cinematictime; // cls.realtime for first cinematic frame + int cinematicframe; + byte cinematicpalette[] = new byte[768]; + boolean cinematicpalette_active; - // - // server state information - // - boolean attractloop; // running the attract loop, any key will menu - int servercount; // server identification for prespawns - String gamedir =""; - public int playernum; + // + // server state information + // + boolean attractloop; // running the attract loop, any key will menu + int servercount; // server identification for prespawns + String gamedir =""; + public int playernum; - public String configstrings[] = new String[Defines.MAX_CONFIGSTRINGS]; + public String configstrings[] = new String[Defines.MAX_CONFIGSTRINGS]; - // - // locally derived information from server state - // - model_t model_draw[] = new model_t[Defines.MAX_MODELS]; - cmodel_t model_clip[] = new cmodel_t[Defines.MAX_MODELS]; + // + // locally derived information from server state + // + model_t model_draw[] = new model_t[Defines.MAX_MODELS]; + cmodel_t model_clip[] = new cmodel_t[Defines.MAX_MODELS]; - public sfx_t sound_precache[] = new sfx_t[Defines.MAX_SOUNDS]; - image_t image_precache[] = new image_t[Defines.MAX_IMAGES]; + public sfx_t sound_precache[] = new sfx_t[Defines.MAX_SOUNDS]; + image_t image_precache[] = new image_t[Defines.MAX_IMAGES]; - clientinfo_t clientinfo[] = new clientinfo_t[Defines.MAX_CLIENTS]; - clientinfo_t baseclientinfo = new clientinfo_t(); + clientinfo_t clientinfo[] = new clientinfo_t[Defines.MAX_CLIENTS]; + clientinfo_t baseclientinfo = new clientinfo_t(); } diff --git a/src/main/java/lwjake2/client/client_static_t.java b/src/main/java/lwjake2/client/client_static_t.java index 3013521..76d261c 100644 --- a/src/main/java/lwjake2/client/client_static_t.java +++ b/src/main/java/lwjake2/client/client_static_t.java @@ -24,44 +24,44 @@ import java.io.RandomAccessFile; public class client_static_t { - // was enum connstate_t - public int state; + // was enum connstate_t + public int state; - // was enum keydest_t - public int key_dest; + // was enum keydest_t + public int key_dest; - public int framecount; - public int realtime; // always increasing, no clamping, etc - public float frametime; // seconds since last frame + public int framecount; + public int realtime; // always increasing, no clamping, etc + public float frametime; // seconds since last frame - // screen rendering information - public float disable_screen; // showing loading plaque between levels - // or changing rendering dlls - // if time gets > 30 seconds ahead, break it - public int disable_servercount; // when we receive a frame and cl.servercount - // > cls.disable_servercount, clear disable_screen + // screen rendering information + public float disable_screen; // showing loading plaque between levels + // or changing rendering dlls + // if time gets > 30 seconds ahead, break it + public int disable_servercount; // when we receive a frame and cl.servercount + // > cls.disable_servercount, clear disable_screen - // connection information - public String servername = ""; // name of server from original connect - public float connect_time; // for connection retransmits + // connection information + public String servername = ""; // name of server from original connect + public float connect_time; // for connection retransmits - int quakePort; // a 16 bit value that allows quake servers - // to work around address translating routers - public netchan_t netchan = new netchan_t(); - public int serverProtocol; // in case we are doing some kind of version hack + int quakePort; // a 16 bit value that allows quake servers + // to work around address translating routers + public netchan_t netchan = new netchan_t(); + public int serverProtocol; // in case we are doing some kind of version hack - public int challenge; // from the server to use for connecting + public int challenge; // from the server to use for connecting - public RandomAccessFile download; // file transfer from server - public String downloadtempname=""; - public String downloadname=""; - public int downloadnumber; - // was enum dltype_t - public int downloadtype; - public int downloadpercent; + public RandomAccessFile download; // file transfer from server + public String downloadtempname=""; + public String downloadname=""; + public int downloadnumber; + // was enum dltype_t + public int downloadtype; + public int downloadpercent; - // demo recording info must be here, so it isn't cleared on level change - public boolean demorecording; - public boolean demowaiting; // don't record until a non-delta message is received - public RandomAccessFile demofile; + // demo recording info must be here, so it isn't cleared on level change + public boolean demorecording; + public boolean demowaiting; // don't record until a non-delta message is received + public RandomAccessFile demofile; } diff --git a/src/main/java/lwjake2/client/clientinfo_t.java b/src/main/java/lwjake2/client/clientinfo_t.java index 345a0ec..7872d42 100644 --- a/src/main/java/lwjake2/client/clientinfo_t.java +++ b/src/main/java/lwjake2/client/clientinfo_t.java @@ -23,27 +23,27 @@ import lwjake2.render.image_t; import lwjake2.render.model_t; public class clientinfo_t { - String name =""; - String cinfo =""; - image_t skin; // ptr - image_t icon; // ptr - String iconname =""; - model_t model; // ptr - model_t weaponmodel[] = new model_t[Defines.MAX_CLIENTWEAPONMODELS]; // arary of references - -// public void reset() -// { -// set(new clientinfo_t()); -// } - - public void set (clientinfo_t from) - { - name = from.name; - cinfo = from.cinfo; - skin = from.skin; - icon = from.icon; - iconname = from.iconname; - model = from.model; - System.arraycopy(from.weaponmodel,0, weaponmodel, 0 , Defines.MAX_CLIENTWEAPONMODELS); - } + String name =""; + String cinfo =""; + image_t skin; // ptr + image_t icon; // ptr + String iconname =""; + model_t model; // ptr + model_t weaponmodel[] = new model_t[Defines.MAX_CLIENTWEAPONMODELS]; // arary of references + +// public void reset() +// { +// set(new clientinfo_t()); +// } + + public void set (clientinfo_t from) + { + name = from.name; + cinfo = from.cinfo; + skin = from.skin; + icon = from.icon; + iconname = from.iconname; + model = from.model; + System.arraycopy(from.weaponmodel,0, weaponmodel, 0 , Defines.MAX_CLIENTWEAPONMODELS); + } } diff --git a/src/main/java/lwjake2/client/console_t.java b/src/main/java/lwjake2/client/console_t.java index 3a841f4..9627afa 100644 --- a/src/main/java/lwjake2/client/console_t.java +++ b/src/main/java/lwjake2/client/console_t.java @@ -24,21 +24,21 @@ import lwjake2.Defines; * console_t */ public final class console_t { - boolean initialized; - byte[] text = new byte[Defines.CON_TEXTSIZE]; - int current; // line where next message will be printed - int x; // offset in current line for next print - int display; // bottom of console displays this line + boolean initialized; + byte[] text = new byte[Defines.CON_TEXTSIZE]; + int current; // line where next message will be printed + int x; // offset in current line for next print + int display; // bottom of console displays this line - int ormask; // high bit mask for colored characters + int ormask; // high bit mask for colored characters - int linewidth; // characters across screen - int totallines; // total lines in console scrollback + int linewidth; // characters across screen + int totallines; // total lines in console scrollback - float cursorspeed; + float cursorspeed; - int vislines; + int vislines; - float[] times = new float[Defines.NUM_CON_TIMES]; // cls.realtime time the line was generated - // for transparent notify lines + float[] times = new float[Defines.NUM_CON_TIMES]; // cls.realtime time the line was generated + // for transparent notify lines } diff --git a/src/main/java/lwjake2/client/cparticle_t.java b/src/main/java/lwjake2/client/cparticle_t.java index 7dec141..d534728 100644 --- a/src/main/java/lwjake2/client/cparticle_t.java +++ b/src/main/java/lwjake2/client/cparticle_t.java @@ -25,15 +25,15 @@ package lwjake2.client; */ public class cparticle_t { - public cparticle_t next; - public float time; + public cparticle_t next; + public float time; - public float[] org = {0, 0, 0}; // vec3_t - public float[] vel = {0, 0, 0}; // vec3_t - public float[] accel = {0, 0, 0}; // vec3_t + public float[] org = {0, 0, 0}; // vec3_t + public float[] vel = {0, 0, 0}; // vec3_t + public float[] accel = {0, 0, 0}; // vec3_t - public float color; - //public float colorvel; - public float alpha; - public float alphavel; + public float color; + //public float colorvel; + public float alpha; + public float alphavel; } diff --git a/src/main/java/lwjake2/client/dlight_t.java b/src/main/java/lwjake2/client/dlight_t.java index 8e757b8..a78b063 100644 --- a/src/main/java/lwjake2/client/dlight_t.java +++ b/src/main/java/lwjake2/client/dlight_t.java @@ -20,7 +20,7 @@ package lwjake2.client; public class dlight_t { - public float origin[] = { 0, 0, 0 }; - public float color[] = { 0, 0, 0 }; - public float intensity; + public float origin[] = { 0, 0, 0 }; + public float color[] = { 0, 0, 0 }; + public float intensity; } diff --git a/src/main/java/lwjake2/client/entity_t.java b/src/main/java/lwjake2/client/entity_t.java index b9943d6..2748973 100644 --- a/src/main/java/lwjake2/client/entity_t.java +++ b/src/main/java/lwjake2/client/entity_t.java @@ -23,64 +23,64 @@ import lwjake2.render.model_t; import lwjake2.util.Math3D; public class entity_t implements Cloneable{ - //ptr - public model_t model; // opaque type outside refresh - public float angles[] = { 0, 0, 0 }; + //ptr + public model_t model; // opaque type outside refresh + public float angles[] = { 0, 0, 0 }; - /* - ** most recent data - */ - public float origin[] = { 0, 0, 0 }; // also used as RF_BEAM's "from" - public int frame; // also used as RF_BEAM's diameter + /* + ** most recent data + */ + public float origin[] = { 0, 0, 0 }; // also used as RF_BEAM's "from" + public int frame; // also used as RF_BEAM's diameter - /* - ** previous data for lerping - */ - public float oldorigin[] = { 0, 0, 0 }; // also used as RF_BEAM's "to" - public int oldframe; + /* + ** previous data for lerping + */ + public float oldorigin[] = { 0, 0, 0 }; // also used as RF_BEAM's "to" + public int oldframe; - /* - ** misc - */ - public float backlerp; // 0.0 = current, 1.0 = old - public int skinnum; // also used as RF_BEAM's palette index + /* + ** misc + */ + public float backlerp; // 0.0 = current, 1.0 = old + public int skinnum; // also used as RF_BEAM's palette index - public int lightstyle; // for flashing entities - public float alpha; // ignore if RF_TRANSLUCENT isn't set + public int lightstyle; // for flashing entities + public float alpha; // ignore if RF_TRANSLUCENT isn't set - // reference - public image_t skin; // NULL for inline skin - public int flags; - - - public void set(entity_t src) { - this.model = src.model; - Math3D.VectorCopy(src.angles, this.angles); - Math3D.VectorCopy(src.origin, this.origin); - this.frame = src.frame; - Math3D.VectorCopy(src.oldorigin, this.oldorigin); - this.oldframe = src.oldframe; - this.backlerp = src.backlerp; - this.skinnum = src.skinnum; - this.lightstyle = src.lightstyle; - this.alpha = src.alpha; - this.skin = src.skin; - this.flags = src.flags; - } + // reference + public image_t skin; // NULL for inline skin + public int flags; + + + public void set(entity_t src) { + this.model = src.model; + Math3D.VectorCopy(src.angles, this.angles); + Math3D.VectorCopy(src.origin, this.origin); + this.frame = src.frame; + Math3D.VectorCopy(src.oldorigin, this.oldorigin); + this.oldframe = src.oldframe; + this.backlerp = src.backlerp; + this.skinnum = src.skinnum; + this.lightstyle = src.lightstyle; + this.alpha = src.alpha; + this.skin = src.skin; + this.flags = src.flags; + } - public void clear() { - model = null; - Math3D.VectorClear(angles); - Math3D.VectorClear(origin); - frame = 0; - Math3D.VectorClear(oldorigin); - oldframe = 0; - backlerp = 0; - skinnum = 0; - lightstyle = 0; - alpha = 0; - skin = null; - flags = 0; - } - + public void clear() { + model = null; + Math3D.VectorClear(angles); + Math3D.VectorClear(origin); + frame = 0; + Math3D.VectorClear(oldorigin); + oldframe = 0; + backlerp = 0; + skinnum = 0; + lightstyle = 0; + alpha = 0; + skin = null; + flags = 0; + } + } diff --git a/src/main/java/lwjake2/client/frame_t.java b/src/main/java/lwjake2/client/frame_t.java index b849fb2..ee1172b 100644 --- a/src/main/java/lwjake2/client/frame_t.java +++ b/src/main/java/lwjake2/client/frame_t.java @@ -23,34 +23,34 @@ import lwjake2.game.player_state_t; import java.util.Arrays; public class frame_t { - - public static final int MAX_MAP_AREAS = 256; - - boolean valid; // cleared if delta parsing was invalid - int serverframe; - public int servertime; // server time the message is valid for (in msec) - int deltaframe; - byte areabits[] = new byte [MAX_MAP_AREAS/8]; // portalarea visibility bits - public player_state_t playerstate = new player_state_t(); // mem - public int num_entities; - public int parse_entities; // non-masked index into cl_parse_entities array - - public void set(frame_t from) { - valid = from.valid; - serverframe = from.serverframe; - deltaframe = from.deltaframe; - num_entities = from.num_entities; - parse_entities = from.parse_entities; - System.arraycopy(from.areabits, 0, areabits, 0, areabits.length); - playerstate.set(from.playerstate); - } - - public void reset() - { - valid = false; - serverframe = servertime = deltaframe = 0; - Arrays.fill(areabits, (byte)0); - playerstate.clear(); - num_entities = parse_entities = 0; - } + + public static final int MAX_MAP_AREAS = 256; + + boolean valid; // cleared if delta parsing was invalid + int serverframe; + public int servertime; // server time the message is valid for (in msec) + int deltaframe; + byte areabits[] = new byte [MAX_MAP_AREAS/8]; // portalarea visibility bits + public player_state_t playerstate = new player_state_t(); // mem + public int num_entities; + public int parse_entities; // non-masked index into cl_parse_entities array + + public void set(frame_t from) { + valid = from.valid; + serverframe = from.serverframe; + deltaframe = from.deltaframe; + num_entities = from.num_entities; + parse_entities = from.parse_entities; + System.arraycopy(from.areabits, 0, areabits, 0, areabits.length); + playerstate.set(from.playerstate); + } + + public void reset() + { + valid = false; + serverframe = servertime = deltaframe = 0; + Arrays.fill(areabits, (byte)0); + playerstate.clear(); + num_entities = parse_entities = 0; + } } diff --git a/src/main/java/lwjake2/client/kbutton_t.java b/src/main/java/lwjake2/client/kbutton_t.java index 7f9c472..e2c18dd 100644 --- a/src/main/java/lwjake2/client/kbutton_t.java +++ b/src/main/java/lwjake2/client/kbutton_t.java @@ -22,8 +22,8 @@ package lwjake2.client; * kbutton_t */ public class kbutton_t { - int[] down = new int[2]; // key nums holding it down - long downtime; // msec timestamp - long msec; // msec down this frame - public int state; + int[] down = new int[2]; // key nums holding it down + long downtime; // msec timestamp + long msec; // msec down this frame + public int state; } diff --git a/src/main/java/lwjake2/client/lightstyle_t.java b/src/main/java/lwjake2/client/lightstyle_t.java index 0e9b322..369d4a4 100644 --- a/src/main/java/lwjake2/client/lightstyle_t.java +++ b/src/main/java/lwjake2/client/lightstyle_t.java @@ -20,6 +20,6 @@ package lwjake2.client; public class lightstyle_t { - public float rgb[] = { 0, 0, 0 }; // 0.0 - 2.0 - public float white; // highest of rgb + public float rgb[] = { 0, 0, 0 }; // 0.0 - 2.0 + public float white; // highest of rgb } diff --git a/src/main/java/lwjake2/client/particle_t.java b/src/main/java/lwjake2/client/particle_t.java index 2724869..d8264b2 100644 --- a/src/main/java/lwjake2/client/particle_t.java +++ b/src/main/java/lwjake2/client/particle_t.java @@ -27,22 +27,22 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; public class particle_t { - - // lwjgl renderer needs a ByteBuffer - private static ByteBuffer colorByteArray = Lib.newByteBuffer(Defines.MAX_PARTICLES * Lib.SIZEOF_INT, ByteOrder.LITTLE_ENDIAN); + + // lwjgl renderer needs a ByteBuffer + private static ByteBuffer colorByteArray = Lib.newByteBuffer(Defines.MAX_PARTICLES * Lib.SIZEOF_INT, ByteOrder.LITTLE_ENDIAN); - public static FloatBuffer vertexArray = Lib.newFloatBuffer(Defines.MAX_PARTICLES * 3); - public static int[] colorTable = new int[256]; - public static IntBuffer colorArray = colorByteArray.asIntBuffer(); - - - public static void setColorPalette(int[] palette) { - for (int i=0; i < 256; i++) { - colorTable[i] = palette[i] & 0x00FFFFFF; - } - } - - public static ByteBuffer getColorAsByteBuffer() { - return colorByteArray; - } + public static FloatBuffer vertexArray = Lib.newFloatBuffer(Defines.MAX_PARTICLES * 3); + public static int[] colorTable = new int[256]; + public static IntBuffer colorArray = colorByteArray.asIntBuffer(); + + + public static void setColorPalette(int[] palette) { + for (int i=0; i < 256; i++) { + colorTable[i] = palette[i] & 0x00FFFFFF; + } + } + + public static ByteBuffer getColorAsByteBuffer() { + return colorByteArray; + } } diff --git a/src/main/java/lwjake2/client/refdef_t.java b/src/main/java/lwjake2/client/refdef_t.java index 4665a0a..f13cddc 100644 --- a/src/main/java/lwjake2/client/refdef_t.java +++ b/src/main/java/lwjake2/client/refdef_t.java @@ -19,24 +19,24 @@ package lwjake2.client; public class refdef_t { - public int x, y, width, height;// in virtual screen coordinates - public float fov_x, fov_y; - public float vieworg[] ={0,0,0}; - public float viewangles[]={0,0,0}; - public float blend[]={0,0,0,0}; // rgba 0-1 full screen blend - public float time; // time is uesed to auto animate - public int rdflags; // RDF_UNDERWATER, etc + public int x, y, width, height;// in virtual screen coordinates + public float fov_x, fov_y; + public float vieworg[] ={0,0,0}; + public float viewangles[]={0,0,0}; + public float blend[]={0,0,0,0}; // rgba 0-1 full screen blend + public float time; // time is uesed to auto animate + public int rdflags; // RDF_UNDERWATER, etc - public byte areabits[]; // if not NULL, only areas with set bits will be drawn + public byte areabits[]; // if not NULL, only areas with set bits will be drawn - public lightstyle_t lightstyles[]; // [MAX_LIGHTSTYLES] + public lightstyle_t lightstyles[]; // [MAX_LIGHTSTYLES] - public int num_entities; - public entity_t entities[]; + public int num_entities; + public entity_t entities[]; - public int num_dlights; - public dlight_t dlights[]; + public int num_dlights; + public dlight_t dlights[]; - public int num_particles; - //public particle_t particles[]; + public int num_particles; + //public particle_t particles[]; } diff --git a/src/main/java/lwjake2/client/refexport_t.java b/src/main/java/lwjake2/client/refexport_t.java index ed3cfd6..b688b47 100644 --- a/src/main/java/lwjake2/client/refexport_t.java +++ b/src/main/java/lwjake2/client/refexport_t.java @@ -31,74 +31,74 @@ import java.awt.DisplayMode; * @author cwei */ public interface refexport_t { - // ============================================================================ - // public interface for Renderer implementations - // - // ref.h, refexport_t - // ============================================================================ - // - // these are the functions exported by the refresh module - // - // called when the library is loaded - boolean Init(int vid_xpos, int vid_ypos); + // ============================================================================ + // public interface for Renderer implementations + // + // ref.h, refexport_t + // ============================================================================ + // + // these are the functions exported by the refresh module + // + // called when the library is loaded + boolean Init(int vid_xpos, int vid_ypos); - // called before the library is unloaded - void Shutdown(); + // called before the library is unloaded + void Shutdown(); - // All data that will be used in a level should be - // registered before rendering any frames to prevent disk hits, - // but they can still be registered at a later time - // if necessary. - // - // EndRegistration will free any remaining data that wasn't registered. - // Any model_s or skin_s pointers from before the BeginRegistration - // are no longer valid after EndRegistration. - // - // Skins and images need to be differentiated, because skins - // are flood filled to eliminate mip map edge errors, and pics have - // an implicit "pics/" prepended to the name. (a pic name that starts with a - // slash will not use the "pics/" prefix or the ".pcx" postfix) - void BeginRegistration(String map); - model_t RegisterModel(String name); - image_t RegisterSkin(String name); - image_t RegisterPic(String name); - void SetSky(String name, float rotate, /* vec3_t */ - float[] axis); - void EndRegistration(); + // All data that will be used in a level should be + // registered before rendering any frames to prevent disk hits, + // but they can still be registered at a later time + // if necessary. + // + // EndRegistration will free any remaining data that wasn't registered. + // Any model_s or skin_s pointers from before the BeginRegistration + // are no longer valid after EndRegistration. + // + // Skins and images need to be differentiated, because skins + // are flood filled to eliminate mip map edge errors, and pics have + // an implicit "pics/" prepended to the name. (a pic name that starts with a + // slash will not use the "pics/" prefix or the ".pcx" postfix) + void BeginRegistration(String map); + model_t RegisterModel(String name); + image_t RegisterSkin(String name); + image_t RegisterPic(String name); + void SetSky(String name, float rotate, /* vec3_t */ + float[] axis); + void EndRegistration(); - void RenderFrame(refdef_t fd); + void RenderFrame(refdef_t fd); - void DrawGetPicSize(Dimension dim /* int *w, *h */, String name); - // will return 0 0 if not found - void DrawPic(int x, int y, String name); - void DrawStretchPic(int x, int y, int w, int h, String name); - void DrawChar(int x, int y, int num); // num is 8 bit ASCII - void DrawTileClear(int x, int y, int w, int h, String name); - void DrawFill(int x, int y, int w, int h, int c); - void DrawFadeScreen(); + void DrawGetPicSize(Dimension dim /* int *w, *h */, String name); + // will return 0 0 if not found + void DrawPic(int x, int y, String name); + void DrawStretchPic(int x, int y, int w, int h, String name); + void DrawChar(int x, int y, int num); // num is 8 bit ASCII + void DrawTileClear(int x, int y, int w, int h, String name); + void DrawFill(int x, int y, int w, int h, int c); + void DrawFadeScreen(); - // Draw images for cinematic rendering (which can have a different palette). Note that calls - void DrawStretchRaw(int x, int y, int w, int h, int cols, int rows, byte[] data); + // Draw images for cinematic rendering (which can have a different palette). Note that calls + void DrawStretchRaw(int x, int y, int w, int h, int cols, int rows, byte[] data); - /* - ** video mode and refresh state management entry points - */ - /* 256 r,g,b values; null = game palette, size = 768 bytes */ - void CinematicSetPalette(final byte[] palette); - void BeginFrame(float camera_separation); - void EndFrame(); + /* + ** video mode and refresh state management entry points + */ + /* 256 r,g,b values; null = game palette, size = 768 bytes */ + void CinematicSetPalette(final byte[] palette); + void BeginFrame(float camera_separation); + void EndFrame(); - void AppActivate(boolean activate); - - /** - * - * - */ - void updateScreen(Runnable callback); - - int apiVersion(); - - DisplayMode[] getModeList(); - - KBD getKeyboardHandler(); + void AppActivate(boolean activate); + + /** + * + * + */ + void updateScreen(Runnable callback); + + int apiVersion(); + + DisplayMode[] getModeList(); + + KBD getKeyboardHandler(); } diff --git a/src/main/java/lwjake2/client/viddef_t.java b/src/main/java/lwjake2/client/viddef_t.java index 7076ca0..0dd3cef 100644 --- a/src/main/java/lwjake2/client/viddef_t.java +++ b/src/main/java/lwjake2/client/viddef_t.java @@ -19,5 +19,5 @@ package lwjake2.client; public class viddef_t { - public int width, height; + public int width, height; } diff --git a/src/main/java/lwjake2/client/vidmode_t.java b/src/main/java/lwjake2/client/vidmode_t.java index 75512b6..3130e14 100644 --- a/src/main/java/lwjake2/client/vidmode_t.java +++ b/src/main/java/lwjake2/client/vidmode_t.java @@ -24,14 +24,14 @@ package lwjake2.client; * @author cwei */ public class vidmode_t { - String description; - int width, height; - int mode; - - vidmode_t (String description, int width, int height, int mode) { - this.description = description; - this.width = width; - this.height = height; - this.mode = mode; - } + String description; + int width, height; + int mode; + + vidmode_t (String description, int width, int height, int mode) { + this.description = description; + this.width = width; + this.height = height; + this.mode = mode; + } } diff --git a/src/main/java/lwjake2/client/vrect_t.java b/src/main/java/lwjake2/client/vrect_t.java index 196115f..edb3391 100644 --- a/src/main/java/lwjake2/client/vrect_t.java +++ b/src/main/java/lwjake2/client/vrect_t.java @@ -24,9 +24,9 @@ package lwjake2.client; * @author cwei */ public class vrect_t { - public int x; - public int y; - public int width; - public int height; - vrect_t pnext; + public int x; + public int y; + public int width; + public int height; + vrect_t pnext; } diff --git a/src/main/java/lwjake2/game/AIAdapter.java b/src/main/java/lwjake2/game/AIAdapter.java index d65a26f..f5f5e69 100644 --- a/src/main/java/lwjake2/game/AIAdapter.java +++ b/src/main/java/lwjake2/game/AIAdapter.java @@ -20,5 +20,5 @@ package lwjake2.game; public abstract class AIAdapter extends SuperAdapter { - public abstract void ai(edict_t self, float dist); + public abstract void ai(edict_t self, float dist); } diff --git a/src/main/java/lwjake2/game/Cmd.java b/src/main/java/lwjake2/game/Cmd.java index 56451b5..e4e1344 100644 --- a/src/main/java/lwjake2/game/Cmd.java +++ b/src/main/java/lwjake2/game/Cmd.java @@ -427,7 +427,7 @@ public final class Cmd { if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0) { SV_GAME.PF_cprintfhigh(ent, - "You must run the server with '+set cheats 1' to enable this command.\n"); + "You must run the server with '+set cheats 1' to enable this command.\n"); return; } @@ -559,7 +559,7 @@ public final class Cmd { if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0) { SV_GAME.PF_cprintfhigh(ent, - "You must run the server with '+set cheats 1' to enable this command.\n"); + "You must run the server with '+set cheats 1' to enable this command.\n"); return; } @@ -584,7 +584,7 @@ public final class Cmd { if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0) { SV_GAME.PF_cprintfhigh(ent, - "You must run the server with '+set cheats 1' to enable this command.\n"); + "You must run the server with '+set cheats 1' to enable this command.\n"); return; } @@ -607,7 +607,7 @@ public final class Cmd { if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0) { SV_GAME.PF_cprintfhigh(ent, - "You must run the server with '+set cheats 1' to enable this command.\n"); + "You must run the server with '+set cheats 1' to enable this command.\n"); return; } @@ -1256,7 +1256,7 @@ public final class Cmd { Say_f(ent, false, true); } - public static void ValidateSelectedItem(edict_t ent) { + public static void ValidateSelectedItem(edict_t ent) { gclient_t cl = ent.client; if (cl.pers.inventory[cl.pers.selected_item] != 0) diff --git a/src/main/java/lwjake2/game/EdictFindFilter.java b/src/main/java/lwjake2/game/EdictFindFilter.java index 488b104..907181a 100644 --- a/src/main/java/lwjake2/game/EdictFindFilter.java +++ b/src/main/java/lwjake2/game/EdictFindFilter.java @@ -22,8 +22,8 @@ package lwjake2.game; public class EdictFindFilter { - boolean matches(edict_t e, String s) - { - return false; - }; + boolean matches(edict_t e, String s) + { + return false; + }; } \ No newline at end of file diff --git a/src/main/java/lwjake2/game/EdictIterator.java b/src/main/java/lwjake2/game/EdictIterator.java index b68976b..d42a9e5 100644 --- a/src/main/java/lwjake2/game/EdictIterator.java +++ b/src/main/java/lwjake2/game/EdictIterator.java @@ -22,10 +22,10 @@ package lwjake2.game; public class EdictIterator { - EdictIterator(int i) - { - this.i = i; - } - public edict_t o; - int i; + EdictIterator(int i) + { + this.i = i; + } + public edict_t o; + int i; } \ No newline at end of file diff --git a/src/main/java/lwjake2/game/EndianHandler.java b/src/main/java/lwjake2/game/EndianHandler.java index ff909ec..d56cb55 100644 --- a/src/main/java/lwjake2/game/EndianHandler.java +++ b/src/main/java/lwjake2/game/EndianHandler.java @@ -20,50 +20,50 @@ package lwjake2.game; public abstract class EndianHandler { - private static final int mask = 0xFF; + private static final int mask = 0xFF; - abstract public float BigFloat(float f); - abstract public short BigShort(short s); - abstract public int BigLong(int i); - abstract public float LittleFloat(float f); - abstract public short LittleShort(short s); - abstract public int LittleLong(int i); + abstract public float BigFloat(float f); + abstract public short BigShort(short s); + abstract public int BigLong(int i); + abstract public float LittleFloat(float f); + abstract public short LittleShort(short s); + abstract public int LittleLong(int i); - public static float swapFloat(float f) - { - int i = Float.floatToRawIntBits(f); - i = swapInt(i); - f = Float.intBitsToFloat(i); + public static float swapFloat(float f) + { + int i = Float.floatToRawIntBits(f); + i = swapInt(i); + f = Float.intBitsToFloat(i); - return f; - } + return f; + } - public static int swapInt(int i) - { + public static int swapInt(int i) + { - int a = i & mask; - i >>>= 8; + int a = i & mask; + i >>>= 8; - a <<= 24; + a <<= 24; - int b = i & mask; + int b = i & mask; - i >>>= 8; - b <<= 16; + i >>>= 8; + b <<= 16; - int c = i & mask; - i >>>= 8; - c <<= 8; + int c = i & mask; + i >>>= 8; + c <<= 8; - return i | c | b | a; - } + return i | c | b | a; + } - public static short swapShort(short s) - { - int a = s & mask; - a <<= 8; - int b = (s >>> 8) & mask; + public static short swapShort(short s) + { + int a = s & mask; + a <<= 8; + int b = (s >>> 8) & mask; - return (short) (b | a); - } + return (short) (b | a); + } } diff --git a/src/main/java/lwjake2/game/EntBlockedAdapter.java b/src/main/java/lwjake2/game/EntBlockedAdapter.java index ef12af1..1a109fb 100644 --- a/src/main/java/lwjake2/game/EntBlockedAdapter.java +++ b/src/main/java/lwjake2/game/EntBlockedAdapter.java @@ -20,6 +20,6 @@ package lwjake2.game; public abstract class EntBlockedAdapter extends SuperAdapter { - // move to moveinfo? - public abstract void blocked(edict_t self, edict_t other); + // move to moveinfo? + public abstract void blocked(edict_t self, edict_t other); } \ No newline at end of file diff --git a/src/main/java/lwjake2/game/EntDieAdapter.java b/src/main/java/lwjake2/game/EntDieAdapter.java index b97dbbd..dc08057 100644 --- a/src/main/java/lwjake2/game/EntDieAdapter.java +++ b/src/main/java/lwjake2/game/EntDieAdapter.java @@ -20,5 +20,5 @@ package lwjake2.game; public abstract class EntDieAdapter extends SuperAdapter { - public abstract void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point); + public abstract void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point); } \ No newline at end of file diff --git a/src/main/java/lwjake2/game/EntDodgeAdapter.java b/src/main/java/lwjake2/game/EntDodgeAdapter.java index a83bbc9..415a5df 100644 --- a/src/main/java/lwjake2/game/EntDodgeAdapter.java +++ b/src/main/java/lwjake2/game/EntDodgeAdapter.java @@ -20,5 +20,5 @@ package lwjake2.game; public abstract class EntDodgeAdapter extends SuperAdapter { - public abstract void dodge(edict_t self, edict_t other, float eta); + public abstract void dodge(edict_t self, edict_t other, float eta); } diff --git a/src/main/java/lwjake2/game/EntInteractAdapter.java b/src/main/java/lwjake2/game/EntInteractAdapter.java index c91f5ce..48a6479 100644 --- a/src/main/java/lwjake2/game/EntInteractAdapter.java +++ b/src/main/java/lwjake2/game/EntInteractAdapter.java @@ -20,5 +20,5 @@ package lwjake2.game; public abstract class EntInteractAdapter extends SuperAdapter { - public abstract boolean interact(edict_t self, edict_t other); + public abstract boolean interact(edict_t self, edict_t other); } \ No newline at end of file diff --git a/src/main/java/lwjake2/game/EntPainAdapter.java b/src/main/java/lwjake2/game/EntPainAdapter.java index 2cfc75c..f27504e 100644 --- a/src/main/java/lwjake2/game/EntPainAdapter.java +++ b/src/main/java/lwjake2/game/EntPainAdapter.java @@ -20,5 +20,5 @@ package lwjake2.game; public abstract class EntPainAdapter extends SuperAdapter { - public abstract void pain(edict_t self, edict_t other, float kick, int damage); + public abstract void pain(edict_t self, edict_t other, float kick, int damage); } \ No newline at end of file diff --git a/src/main/java/lwjake2/game/EntThinkAdapter.java b/src/main/java/lwjake2/game/EntThinkAdapter.java index a3b6ad5..af91a89 100644 --- a/src/main/java/lwjake2/game/EntThinkAdapter.java +++ b/src/main/java/lwjake2/game/EntThinkAdapter.java @@ -20,5 +20,5 @@ package lwjake2.game; public abstract class EntThinkAdapter extends SuperAdapter { - public abstract boolean think(edict_t self); + public abstract boolean think(edict_t self); } \ No newline at end of file diff --git a/src/main/java/lwjake2/game/EntTouchAdapter.java b/src/main/java/lwjake2/game/EntTouchAdapter.java index 3963eab..57737e1 100644 --- a/src/main/java/lwjake2/game/EntTouchAdapter.java +++ b/src/main/java/lwjake2/game/EntTouchAdapter.java @@ -20,5 +20,5 @@ package lwjake2.game; public abstract class EntTouchAdapter extends SuperAdapter { - public abstract void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf); + public abstract void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf); } \ No newline at end of file diff --git a/src/main/java/lwjake2/game/EntUseAdapter.java b/src/main/java/lwjake2/game/EntUseAdapter.java index 5018eea..944d3ba 100644 --- a/src/main/java/lwjake2/game/EntUseAdapter.java +++ b/src/main/java/lwjake2/game/EntUseAdapter.java @@ -20,5 +20,5 @@ package lwjake2.game; public abstract class EntUseAdapter extends SuperAdapter { - public abstract void use(edict_t self, edict_t other, edict_t activator); + public abstract void use(edict_t self, edict_t other, edict_t activator); } \ No newline at end of file diff --git a/src/main/java/lwjake2/game/GameAI.java b/src/main/java/lwjake2/game/GameAI.java index e6cf9fa..27cbfcd 100644 --- a/src/main/java/lwjake2/game/GameAI.java +++ b/src/main/java/lwjake2/game/GameAI.java @@ -622,7 +622,7 @@ public class GameAI { // just lost sight of the player, decide where to go first // dprint("lost sight of player, last seen at "); // dprint(vtos(self.last_sighting)); - // dprint("\n"); + // dprint("\n"); self.monsterinfo.aiflags |= (Defines.AI_LOST_SIGHT | Defines.AI_PURSUIT_LAST_SEEN); self.monsterinfo.aiflags &= ~(Defines.AI_PURSUE_NEXT | Defines.AI_PURSUE_TEMP); new1 = true; diff --git a/src/main/java/lwjake2/game/GameBase.java b/src/main/java/lwjake2/game/GameBase.java index 9bcbab5..696e03a 100644 --- a/src/main/java/lwjake2/game/GameBase.java +++ b/src/main/java/lwjake2/game/GameBase.java @@ -456,16 +456,16 @@ public class GameBase { StringTokenizer tk = new StringTokenizer(s, seps); while (tk.hasMoreTokens()){ - t = tk.nextToken(); + t = tk.nextToken(); - // store first map - if (f == null) - f = t; - + // store first map + if (f == null) + f = t; + if (t.equalsIgnoreCase(level.mapname)) { // it's in the list, go to the next one - if (!tk.hasMoreTokens()) { - // end of list, go to first one + if (!tk.hasMoreTokens()) { + // end of list, go to first one if (f == null) // there isn't a first one, same level PlayerHud.BeginIntermission(CreateTargetChangeLevel(level.mapname)); else diff --git a/src/main/java/lwjake2/game/GameCombat.java b/src/main/java/lwjake2/game/GameCombat.java index e15de49..ad484df 100644 --- a/src/main/java/lwjake2/game/GameCombat.java +++ b/src/main/java/lwjake2/game/GameCombat.java @@ -102,7 +102,7 @@ public class GameCombat { if ((targ.svflags & Defines.SVF_MONSTER) != 0 && (targ.deadflag != Defines.DEAD_DEAD)) { - // targ.svflags |= SVF_DEADMONSTER; // now treat as a different + // targ.svflags |= SVF_DEADMONSTER; // now treat as a different // content type if (0 == (targ.monsterinfo.aiflags & Defines.AI_GOOD_GUY)) { GameBase.level.killed_monsters++; @@ -139,7 +139,7 @@ public class GameCombat { damage = 255; GameBase.gi.WriteByte(Defines.svc_temp_entity); GameBase.gi.WriteByte(type); - // gi.WriteByte (damage); + // gi.WriteByte (damage); GameBase.gi.WritePosition(origin); GameBase.gi.WriteDir(normal); GameBase.gi.multicast(origin, Defines.MULTICAST_PVS); diff --git a/src/main/java/lwjake2/game/GameFunc.java b/src/main/java/lwjake2/game/GameFunc.java index 875d6e4..9d07299 100644 --- a/src/main/java/lwjake2/game/GameFunc.java +++ b/src/main/java/lwjake2/game/GameFunc.java @@ -190,8 +190,8 @@ public class GameFunc { float[] tmin = { 0, 0, 0 }, tmax = { 0, 0, 0 }; // - // middle trigger - // + // middle trigger + // trigger = GameUtil.G_Spawn(); trigger.touch = Touch_Plat_Center; trigger.movetype = Defines.MOVETYPE_NONE; @@ -583,7 +583,7 @@ public class GameFunc { public final static int DOOR_Y_AXIS = 128; // - // Support routines for movement (changes in origin using velocity) + // Support routines for movement (changes in origin using velocity) // static EntThinkAdapter Move_Done = new EntThinkAdapter() { @@ -638,7 +638,7 @@ public class GameFunc { }; // - // Support routines for angular movement (changes in angle using avelocity) + // Support routines for angular movement (changes in angle using avelocity) // static EntThinkAdapter AngleMove_Done = new EntThinkAdapter() { @@ -925,7 +925,7 @@ public class GameFunc { if (0 == ent.dmg) ent.dmg = 2; - // ent.moveinfo.sound_middle = "doors/hydro1.wav"; + // ent.moveinfo.sound_middle = "doors/hydro1.wav"; ent.use = rotating_use; if (ent.dmg != 0) @@ -1725,7 +1725,7 @@ public class GameFunc { boolean dogoto = true; while (dogoto) { if (null == self.target) { - // gi.dprintf ("train_next: no next target\n"); + // gi.dprintf ("train_next: no next target\n"); return true; } @@ -1841,7 +1841,7 @@ public class GameFunc { edict_t target; if (0 != self.movetarget.nextthink) { - // gi.dprintf("elevator busy\n"); + // gi.dprintf("elevator busy\n"); return; } diff --git a/src/main/java/lwjake2/game/GameItemList.java b/src/main/java/lwjake2/game/GameItemList.java index df4538e..600df8a 100644 --- a/src/main/java/lwjake2/game/GameItemList.java +++ b/src/main/java/lwjake2/game/GameItemList.java @@ -22,732 +22,732 @@ import lwjake2.Defines; public class GameItemList { - // RST: this was separated in the java conversion from the g_item.c - // because all adapters have to be created in the other - // classes before this class can be loaded. + // RST: this was separated in the java conversion from the g_item.c + // because all adapters have to be created in the other + // classes before this class can be loaded. - public static gitem_t itemlist[] = { - //leave index 0 alone - new gitem_t(null, null, null, null, null, null, null, 0, null, - null, null, 0, 0, null, 0, 0, null, 0, null), - - // - // ARMOR - // - new gitem_t( - - /** - * QUAKED item_armor_body (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - - "item_armor_body", GameItems.Pickup_Armor, null, null, null, - "misc/ar1_pkup.wav", "models/items/armor/body/tris.md2", - Defines.EF_ROTATE, null, - /* icon */ - "i_bodyarmor", - /* pickup */ - "Body Armor", - /* width */ - 3, 0, null, Defines.IT_ARMOR, 0, GameItems.bodyarmor_info, - Defines.ARMOR_BODY, - /* precache */ - ""), - - /* - * QUAKED item_armor_combat (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("item_armor_combat", GameItems.Pickup_Armor, null, null, null, - "misc/ar1_pkup.wav", "models/items/armor/combat/tris.md2", - Defines.EF_ROTATE, null, - /* icon */ - "i_combatarmor", - /* pickup */ - "Combat Armor", - /* width */ - 3, 0, null, Defines.IT_ARMOR, 0, GameItems.combatarmor_info, - Defines.ARMOR_COMBAT, - /* precache */ - ""), - - /* - * QUAKED item_armor_jacket (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("item_armor_jacket", GameItems.Pickup_Armor, null, null, null, - "misc/ar1_pkup.wav", "models/items/armor/jacket/tris.md2", - Defines.EF_ROTATE, null, - /* icon */ - "i_jacketarmor", - /* pickup */ - "Jacket Armor", - /* width */ - 3, 0, null, Defines.IT_ARMOR, 0, GameItems.jacketarmor_info, - Defines.ARMOR_JACKET, - /* precache */ - ""), - - /* - * QUAKED item_armor_shard (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("item_armor_shard", GameItems.Pickup_Armor, null, null, null, - "misc/ar2_pkup.wav", "models/items/armor/shard/tris.md2", - Defines.EF_ROTATE, null, - /* icon */ - "i_jacketarmor", - /* pickup */ - "Armor Shard", - /* width */ - 3, 0, null, Defines.IT_ARMOR, 0, null, Defines.ARMOR_SHARD, - /* precache */ - ""), - - /* - * QUAKED item_power_screen (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("item_power_screen", GameItems.Pickup_PowerArmor, GameItems.Use_PowerArmor, - GameItems.Drop_PowerArmor, null, "misc/ar3_pkup.wav", - "models/items/armor/screen/tris.md2", Defines.EF_ROTATE, - null, - /* icon */ - "i_powerscreen", - /* pickup */ - "Power Screen", - /* width */ - 0, 60, null, Defines.IT_ARMOR, 0, null, 0, - /* precache */ - ""), - - /* - * QUAKED item_power_shield (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("item_power_shield", GameItems.Pickup_PowerArmor, GameItems.Use_PowerArmor, - GameItems.Drop_PowerArmor, null, "misc/ar3_pkup.wav", - "models/items/armor/shield/tris.md2", Defines.EF_ROTATE, - null, - /* icon */ - "i_powershield", - /* pickup */ - "Power Shield", - /* width */ - 0, 60, null, Defines.IT_ARMOR, 0, null, 0, - /* precache */ - "misc/power2.wav misc/power1.wav"), - - // - // WEAPONS - // - - /* - * weapon_blaster (.3 .3 1) (-16 -16 -16) (16 16 16) always owned, - * never in the world - */ - new gitem_t("weapon_blaster", null, PlayerWeapon.Use_Weapon, null, - PlayerWeapon.Weapon_Blaster, "misc/w_pkup.wav", null, 0, - "models/weapons/v_blast/tris.md2", - /* icon */ - "w_blaster", - /* pickup */ - "Blaster", 0, 0, null, Defines.IT_WEAPON - | Defines.IT_STAY_COOP, Defines.WEAP_BLASTER, null, - 0, - /* precache */ - "weapons/blastf1a.wav misc/lasfly.wav"), - - /* - * QUAKED weapon_shotgun (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("weapon_shotgun", PlayerWeapon.Pickup_Weapon, - PlayerWeapon.Use_Weapon, PlayerWeapon.Drop_Weapon, - PlayerWeapon.Weapon_Shotgun, "misc/w_pkup.wav", - "models/weapons/g_shotg/tris.md2", Defines.EF_ROTATE, - "models/weapons/v_shotg/tris.md2", - /* icon */ - "w_shotgun", - /* pickup */ - "Shotgun", 0, 1, "Shells", Defines.IT_WEAPON - | Defines.IT_STAY_COOP, Defines.WEAP_SHOTGUN, null, - 0, - /* precache */ - "weapons/shotgf1b.wav weapons/shotgr1b.wav"), - - /* - * QUAKED weapon_supershotgun (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("weapon_supershotgun", PlayerWeapon.Pickup_Weapon, - PlayerWeapon.Use_Weapon, PlayerWeapon.Drop_Weapon, - PlayerWeapon.Weapon_SuperShotgun, "misc/w_pkup.wav", - "models/weapons/g_shotg2/tris.md2", Defines.EF_ROTATE, - "models/weapons/v_shotg2/tris.md2", - /* icon */ - "w_sshotgun", - /* pickup */ - "Super Shotgun", 0, 2, "Shells", Defines.IT_WEAPON - | Defines.IT_STAY_COOP, Defines.WEAP_SUPERSHOTGUN, - null, 0, - /* precache */ - "weapons/sshotf1b.wav"), - - /* - * QUAKED weapon_machinegun (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t( - "weapon_machinegun", - PlayerWeapon.Pickup_Weapon, - PlayerWeapon.Use_Weapon, - PlayerWeapon.Drop_Weapon, - PlayerWeapon.Weapon_Machinegun, - "misc/w_pkup.wav", - "models/weapons/g_machn/tris.md2", - Defines.EF_ROTATE, - "models/weapons/v_machn/tris.md2", - /* icon */ - "w_machinegun", - /* pickup */ - "Machinegun", - 0, - 1, - "Bullets", - Defines.IT_WEAPON | Defines.IT_STAY_COOP, - Defines.WEAP_MACHINEGUN, - null, - 0, - /* precache */ - "weapons/machgf1b.wav weapons/machgf2b.wav weapons/machgf3b.wav weapons/machgf4b.wav weapons/machgf5b.wav"), - - /* - * QUAKED weapon_chaingun (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t( - "weapon_chaingun", - PlayerWeapon.Pickup_Weapon, - PlayerWeapon.Use_Weapon, - PlayerWeapon.Drop_Weapon, - PlayerWeapon.Weapon_Chaingun, - "misc/w_pkup.wav", - "models/weapons/g_chain/tris.md2", - Defines.EF_ROTATE, - "models/weapons/v_chain/tris.md2", - /* icon */ - "w_chaingun", - /* pickup */ - "Chaingun", - 0, - 1, - "Bullets", - Defines.IT_WEAPON | Defines.IT_STAY_COOP, - Defines.WEAP_CHAINGUN, - null, - 0, - /* precache */ - "weapons/chngnu1a.wav weapons/chngnl1a.wav weapons/machgf3b.wav` weapons/chngnd1a.wav"), - - /* - * QUAKED ammo_grenades (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t( - "ammo_grenades", - GameItems.Pickup_Ammo, - PlayerWeapon.Use_Weapon, - GameItems.Drop_Ammo, - PlayerWeapon.Weapon_Grenade, - "misc/am_pkup.wav", - "models/items/ammo/grenades/medium/tris.md2", - 0, - "models/weapons/v_handgr/tris.md2", - /* icon */ - "a_grenades", - /* pickup */ - "Grenades", - /* width */ - 3, - 5, - "grenades", - Defines.IT_AMMO | Defines.IT_WEAPON, - Defines.WEAP_GRENADES, - null, - Defines.AMMO_GRENADES, - /* precache */ - "weapons/hgrent1a.wav weapons/hgrena1b.wav weapons/hgrenc1b.wav weapons/hgrenb1a.wav weapons/hgrenb2a.wav "), - - /* - * QUAKED weapon_grenadelauncher (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t( - "weapon_grenadelauncher", - PlayerWeapon.Pickup_Weapon, - PlayerWeapon.Use_Weapon, - PlayerWeapon.Drop_Weapon, - PlayerWeapon.Weapon_GrenadeLauncher, - "misc/w_pkup.wav", - "models/weapons/g_launch/tris.md2", - Defines.EF_ROTATE, - "models/weapons/v_launch/tris.md2", - /* icon */ - "w_glauncher", - /* pickup */ - "Grenade Launcher", - 0, - 1, - "Grenades", - Defines.IT_WEAPON | Defines.IT_STAY_COOP, - Defines.WEAP_GRENADELAUNCHER, - null, - 0, - /* precache */ - "models/objects/grenade/tris.md2 weapons/grenlf1a.wav weapons/grenlr1b.wav weapons/grenlb1b.wav"), - - /* - * QUAKED weapon_rocketlauncher (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t( - "weapon_rocketlauncher", - PlayerWeapon.Pickup_Weapon, - PlayerWeapon.Use_Weapon, - PlayerWeapon.Drop_Weapon, - PlayerWeapon.Weapon_RocketLauncher, - "misc/w_pkup.wav", - "models/weapons/g_rocket/tris.md2", - Defines.EF_ROTATE, - "models/weapons/v_rocket/tris.md2", - /* icon */ - "w_rlauncher", - /* pickup */ - "Rocket Launcher", - 0, - 1, - "Rockets", - Defines.IT_WEAPON | Defines.IT_STAY_COOP, - Defines.WEAP_ROCKETLAUNCHER, - null, - 0, - /* precache */ - "models/objects/rocket/tris.md2 weapons/rockfly.wav weapons/rocklf1a.wav weapons/rocklr1b.wav models/objects/debris2/tris.md2"), - - /* - * QUAKED weapon_hyperblaster (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t( - "weapon_hyperblaster", - PlayerWeapon.Pickup_Weapon, - PlayerWeapon.Use_Weapon, - PlayerWeapon.Drop_Weapon, - PlayerWeapon.Weapon_HyperBlaster, - "misc/w_pkup.wav", - "models/weapons/g_hyperb/tris.md2", - Defines.EF_ROTATE, - "models/weapons/v_hyperb/tris.md2", - /* icon */ - "w_hyperblaster", - /* pickup */ - "HyperBlaster", - 0, - 1, - "Cells", - Defines.IT_WEAPON | Defines.IT_STAY_COOP, - Defines.WEAP_HYPERBLASTER, - null, - 0, - /* precache */ - "weapons/hyprbu1a.wav weapons/hyprbl1a.wav weapons/hyprbf1a.wav weapons/hyprbd1a.wav misc/lasfly.wav"), - - /* - * QUAKED weapon_railgun (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("weapon_railgun", PlayerWeapon.Pickup_Weapon, - PlayerWeapon.Use_Weapon, PlayerWeapon.Drop_Weapon, - PlayerWeapon.Weapon_Railgun, "misc/w_pkup.wav", - "models/weapons/g_rail/tris.md2", Defines.EF_ROTATE, - "models/weapons/v_rail/tris.md2", - /* icon */ - "w_railgun", - /* pickup */ - "Railgun", 0, 1, "Slugs", Defines.IT_WEAPON - | Defines.IT_STAY_COOP, Defines.WEAP_RAILGUN, null, - 0, - /* precache */ - "weapons/rg_hum.wav"), - - /* - * QUAKED weapon_bfg (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t( - "weapon_bfg", - PlayerWeapon.Pickup_Weapon, - PlayerWeapon.Use_Weapon, - PlayerWeapon.Drop_Weapon, - PlayerWeapon.Weapon_BFG, - "misc/w_pkup.wav", - "models/weapons/g_bfg/tris.md2", - Defines.EF_ROTATE, - "models/weapons/v_bfg/tris.md2", - /* icon */ - "w_bfg", - /* pickup */ - "BFG10K", - 0, - 50, - "Cells", - Defines.IT_WEAPON | Defines.IT_STAY_COOP, - Defines.WEAP_BFG, - null, - 0, - /* precache */ - "sprites/s_bfg1.sp2 sprites/s_bfg2.sp2 sprites/s_bfg3.sp2 weapons/bfg__f1y.wav weapons/bfg__l1a.wav weapons/bfg__x1b.wav weapons/bfg_hum.wav"), - - // - // AMMO ITEMS - // - - /* - * QUAKED ammo_shells (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("ammo_shells", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null, - "misc/am_pkup.wav", - "models/items/ammo/shells/medium/tris.md2", 0, null, - /* icon */ - "a_shells", - /* pickup */ - "Shells", - /* width */ - 3, 10, null, Defines.IT_AMMO, 0, null, Defines.AMMO_SHELLS, - /* precache */ - ""), - - /* - * QUAKED ammo_bullets (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("ammo_bullets", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null, - "misc/am_pkup.wav", - "models/items/ammo/bullets/medium/tris.md2", 0, null, - /* icon */ - "a_bullets", - /* pickup */ - "Bullets", - /* width */ - 3, 50, null, Defines.IT_AMMO, 0, null, - Defines.AMMO_BULLETS, - /* precache */ - ""), - - /* - * QUAKED ammo_cells (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("ammo_cells", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null, - "misc/am_pkup.wav", - "models/items/ammo/cells/medium/tris.md2", 0, null, - /* icon */ - "a_cells", - /* pickup */ - "Cells", - /* width */ - 3, 50, null, Defines.IT_AMMO, 0, null, Defines.AMMO_CELLS, - /* precache */ - ""), - - /* - * QUAKED ammo_rockets (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("ammo_rockets", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null, - "misc/am_pkup.wav", - "models/items/ammo/rockets/medium/tris.md2", 0, null, - /* icon */ - "a_rockets", - /* pickup */ - "Rockets", - /* width */ - 3, 5, null, Defines.IT_AMMO, 0, null, Defines.AMMO_ROCKETS, - /* precache */ - ""), - - /* - * QUAKED ammo_slugs (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("ammo_slugs", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null, - "misc/am_pkup.wav", - "models/items/ammo/slugs/medium/tris.md2", 0, null, - /* icon */ - "a_slugs", - /* pickup */ - "Slugs", - /* width */ - 3, 10, null, Defines.IT_AMMO, 0, null, Defines.AMMO_SLUGS, - /* precache */ - ""), - - // - // POWERUP ITEMS - // - /* - * QUAKED item_quad (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("item_quad", GameItems.Pickup_Powerup, GameItems.Use_Quad, - GameItems.Drop_General, null, "items/pkup.wav", - "models/items/quaddama/tris.md2", Defines.EF_ROTATE, null, - /* icon */ - "p_quad", - /* pickup */ - "Quad Damage", - /* width */ - 2, 60, null, Defines.IT_POWERUP, 0, null, 0, - /* precache */ - "items/damage.wav items/damage2.wav items/damage3.wav"), - - /* - * QUAKED item_invulnerability (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("item_invulnerability", GameItems.Pickup_Powerup, - GameItems.Use_Invulnerability, GameItems.Drop_General, null, - "items/pkup.wav", "models/items/invulner/tris.md2", - Defines.EF_ROTATE, null, - /* icon */ - "p_invulnerability", - /* pickup */ - "Invulnerability", - /* width */ - 2, 300, null, Defines.IT_POWERUP, 0, null, 0, - /* precache */ - "items/protect.wav items/protect2.wav items/protect4.wav"), - - /* - * QUAKED item_silencer (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("item_silencer", GameItems.Pickup_Powerup, GameItems.Use_Silencer, - GameItems.Drop_General, null, "items/pkup.wav", - "models/items/silencer/tris.md2", Defines.EF_ROTATE, null, - /* icon */ - "p_silencer", - /* pickup */ - "Silencer", - /* width */ - 2, 60, null, Defines.IT_POWERUP, 0, null, 0, - /* precache */ - ""), - - /* - * QUAKED item_breather (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("item_breather", GameItems.Pickup_Powerup, GameItems.Use_Breather, - GameItems.Drop_General, null, "items/pkup.wav", - "models/items/breather/tris.md2", Defines.EF_ROTATE, null, - /* icon */ - "p_rebreather", - /* pickup */ - "Rebreather", - /* width */ - 2, 60, null, Defines.IT_STAY_COOP | Defines.IT_POWERUP, 0, - null, 0, - /* precache */ - "items/airout.wav"), - - /* - * QUAKED item_enviro (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("item_enviro", GameItems.Pickup_Powerup, GameItems.Use_Envirosuit, - GameItems.Drop_General, null, "items/pkup.wav", - "models/items/enviro/tris.md2", Defines.EF_ROTATE, null, - /* icon */ - "p_envirosuit", - /* pickup */ - "Environment Suit", - /* width */ - 2, 60, null, Defines.IT_STAY_COOP | Defines.IT_POWERUP, 0, - null, 0, - /* precache */ - "items/airout.wav"), - - /* - * QUAKED item_ancient_head (.3 .3 1) (-16 -16 -16) (16 16 16) - * Special item that gives +2 to maximum health - */ - new gitem_t("item_ancient_head", GameItems.Pickup_AncientHead, null, null, - null, "items/pkup.wav", "models/items/c_head/tris.md2", - Defines.EF_ROTATE, null, - /* icon */ - "i_fixme", - /* pickup */ - "Ancient Head", - /* width */ - 2, 60, null, 0, 0, null, 0, - /* precache */ - ""), - - /* - * QUAKED item_adrenaline (.3 .3 1) (-16 -16 -16) (16 16 16) gives - * +1 to maximum health - */ - new gitem_t("item_adrenaline", GameItems.Pickup_Adrenaline, null, null, null, - "items/pkup.wav", "models/items/adrenal/tris.md2", - Defines.EF_ROTATE, null, - /* icon */ - "p_adrenaline", - /* pickup */ - "Adrenaline", - /* width */ - 2, 60, null, 0, 0, null, 0, - /* precache */ - ""), - - /* - * QUAKED item_bandolier (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("item_bandolier", GameItems.Pickup_Bandolier, null, null, null, - "items/pkup.wav", "models/items/band/tris.md2", - Defines.EF_ROTATE, null, - /* icon */ - "p_bandolier", - /* pickup */ - "Bandolier", - /* width */ - 2, 60, null, 0, 0, null, 0, - /* precache */ - ""), - - /* - * QUAKED item_pack (.3 .3 1) (-16 -16 -16) (16 16 16) - */ - new gitem_t("item_pack", GameItems.Pickup_Pack, null, null, null, - "items/pkup.wav", "models/items/pack/tris.md2", - Defines.EF_ROTATE, null, - /* icon */ - "i_pack", - /* pickup */ - "Ammo Pack", - /* width */ - 2, 180, null, 0, 0, null, 0, - /* precache */ - ""), - - // - // KEYS - // - /* - * QUAKED key_data_cd (0 .5 .8) (-16 -16 -16) (16 16 16) key for - * computer centers - */ - new gitem_t("key_data_cd", GameItems.Pickup_Key, null, GameItems.Drop_General, - null, "items/pkup.wav", - "models/items/keys/data_cd/tris.md2", Defines.EF_ROTATE, - null, "k_datacd", "Data CD", 2, 0, null, - Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0, - /* precache */ - ""), - - /* - * QUAKED key_power_cube (0 .5 .8) (-16 -16 -16) (16 16 16) - * TRIGGER_SPAWN NO_TOUCH warehouse circuits - */ - new gitem_t("key_power_cube", GameItems.Pickup_Key, null, - GameItems.Drop_General, null, "items/pkup.wav", - "models/items/keys/power/tris.md2", Defines.EF_ROTATE, - null, "k_powercube", "Power Cube", 2, 0, null, - Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0, - /* precache */ - ""), - - /* - * QUAKED key_pyramid (0 .5 .8) (-16 -16 -16) (16 16 16) key for the - * entrance of jail3 - */ - new gitem_t("key_pyramid", GameItems.Pickup_Key, null, GameItems.Drop_General, - null, "items/pkup.wav", - "models/items/keys/pyramid/tris.md2", Defines.EF_ROTATE, - null, "k_pyramid", "Pyramid Key", 2, 0, null, - Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0, - /* precache */ - ""), - - /* - * QUAKED key_data_spinner (0 .5 .8) (-16 -16 -16) (16 16 16) key - * for the city computer - */ - new gitem_t("key_data_spinner", GameItems.Pickup_Key, null, - GameItems.Drop_General, null, "items/pkup.wav", - "models/items/keys/spinner/tris.md2", Defines.EF_ROTATE, - null, "k_dataspin", "Data Spinner", 2, 0, null, - Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0, - /* precache */ - ""), - - /* - * QUAKED key_pass (0 .5 .8) (-16 -16 -16) (16 16 16) security pass - * for the security level - */ - new gitem_t("key_pass", GameItems.Pickup_Key, null, GameItems.Drop_General, - null, "items/pkup.wav", "models/items/keys/pass/tris.md2", - Defines.EF_ROTATE, null, "k_security", "Security Pass", 2, - 0, null, Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0, - /* precache */ - ""), - - /* - * QUAKED key_blue_key (0 .5 .8) (-16 -16 -16) (16 16 16) normal - * door key - blue - */ - new gitem_t("key_blue_key", GameItems.Pickup_Key, null, - GameItems.Drop_General, null, "items/pkup.wav", - "models/items/keys/key/tris.md2", Defines.EF_ROTATE, null, - "k_bluekey", "Blue Key", 2, 0, null, Defines.IT_STAY_COOP - | Defines.IT_KEY, 0, null, 0, - /* precache */ - ""), - - /* - * QUAKED key_red_key (0 .5 .8) (-16 -16 -16) (16 16 16) normal door - * key - red - */ - new gitem_t("key_red_key", GameItems.Pickup_Key, null, GameItems.Drop_General, - null, "items/pkup.wav", - "models/items/keys/red_key/tris.md2", Defines.EF_ROTATE, - null, "k_redkey", "Red Key", 2, 0, null, - Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0, - /* precache */ - ""), - - /* - * QUAKED key_commander_head (0 .5 .8) (-16 -16 -16) (16 16 16) tank - * commander's head - */ - new gitem_t("key_commander_head", GameItems.Pickup_Key, null, - GameItems.Drop_General, null, "items/pkup.wav", - "models/monsters/commandr/head/tris.md2", Defines.EF_GIB, - null, - /* icon */ - "k_comhead", - /* pickup */ - "Commander's Head", - /* width */ - 2, 0, null, Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, - 0, - /* precache */ - ""), - - /* - * QUAKED key_airstrike_target (0 .5 .8) (-16 -16 -16) (16 16 16) - * tank commander's head - */ - new gitem_t("key_airstrike_target", GameItems.Pickup_Key, null, - GameItems.Drop_General, null, "items/pkup.wav", - "models/items/keys/target/tris.md2", Defines.EF_ROTATE, - null, - /* icon */ - "i_airstrike", - /* pickup */ - "Airstrike Marker", - /* width */ - 2, 0, null, Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, - 0, - /* precache */ - ""), - new gitem_t(null, GameItems.Pickup_Health, null, null, null, - "items/pkup.wav", null, 0, null, - /* icon */ - "i_health", - /* pickup */ - "Health", - /* width */ - 3, 0, null, 0, 0, null, 0, - /* precache */ - "items/s_health.wav items/n_health.wav items/l_health.wav items/m_health.wav"), - - // end of list marker - null }; + public static gitem_t itemlist[] = { + //leave index 0 alone + new gitem_t(null, null, null, null, null, null, null, 0, null, + null, null, 0, 0, null, 0, 0, null, 0, null), + + // + // ARMOR + // + new gitem_t( + + /** + * QUAKED item_armor_body (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + + "item_armor_body", GameItems.Pickup_Armor, null, null, null, + "misc/ar1_pkup.wav", "models/items/armor/body/tris.md2", + Defines.EF_ROTATE, null, + /* icon */ + "i_bodyarmor", + /* pickup */ + "Body Armor", + /* width */ + 3, 0, null, Defines.IT_ARMOR, 0, GameItems.bodyarmor_info, + Defines.ARMOR_BODY, + /* precache */ + ""), + + /* + * QUAKED item_armor_combat (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("item_armor_combat", GameItems.Pickup_Armor, null, null, null, + "misc/ar1_pkup.wav", "models/items/armor/combat/tris.md2", + Defines.EF_ROTATE, null, + /* icon */ + "i_combatarmor", + /* pickup */ + "Combat Armor", + /* width */ + 3, 0, null, Defines.IT_ARMOR, 0, GameItems.combatarmor_info, + Defines.ARMOR_COMBAT, + /* precache */ + ""), + + /* + * QUAKED item_armor_jacket (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("item_armor_jacket", GameItems.Pickup_Armor, null, null, null, + "misc/ar1_pkup.wav", "models/items/armor/jacket/tris.md2", + Defines.EF_ROTATE, null, + /* icon */ + "i_jacketarmor", + /* pickup */ + "Jacket Armor", + /* width */ + 3, 0, null, Defines.IT_ARMOR, 0, GameItems.jacketarmor_info, + Defines.ARMOR_JACKET, + /* precache */ + ""), + + /* + * QUAKED item_armor_shard (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("item_armor_shard", GameItems.Pickup_Armor, null, null, null, + "misc/ar2_pkup.wav", "models/items/armor/shard/tris.md2", + Defines.EF_ROTATE, null, + /* icon */ + "i_jacketarmor", + /* pickup */ + "Armor Shard", + /* width */ + 3, 0, null, Defines.IT_ARMOR, 0, null, Defines.ARMOR_SHARD, + /* precache */ + ""), + + /* + * QUAKED item_power_screen (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("item_power_screen", GameItems.Pickup_PowerArmor, GameItems.Use_PowerArmor, + GameItems.Drop_PowerArmor, null, "misc/ar3_pkup.wav", + "models/items/armor/screen/tris.md2", Defines.EF_ROTATE, + null, + /* icon */ + "i_powerscreen", + /* pickup */ + "Power Screen", + /* width */ + 0, 60, null, Defines.IT_ARMOR, 0, null, 0, + /* precache */ + ""), + + /* + * QUAKED item_power_shield (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("item_power_shield", GameItems.Pickup_PowerArmor, GameItems.Use_PowerArmor, + GameItems.Drop_PowerArmor, null, "misc/ar3_pkup.wav", + "models/items/armor/shield/tris.md2", Defines.EF_ROTATE, + null, + /* icon */ + "i_powershield", + /* pickup */ + "Power Shield", + /* width */ + 0, 60, null, Defines.IT_ARMOR, 0, null, 0, + /* precache */ + "misc/power2.wav misc/power1.wav"), + + // + // WEAPONS + // + + /* + * weapon_blaster (.3 .3 1) (-16 -16 -16) (16 16 16) always owned, + * never in the world + */ + new gitem_t("weapon_blaster", null, PlayerWeapon.Use_Weapon, null, + PlayerWeapon.Weapon_Blaster, "misc/w_pkup.wav", null, 0, + "models/weapons/v_blast/tris.md2", + /* icon */ + "w_blaster", + /* pickup */ + "Blaster", 0, 0, null, Defines.IT_WEAPON + | Defines.IT_STAY_COOP, Defines.WEAP_BLASTER, null, + 0, + /* precache */ + "weapons/blastf1a.wav misc/lasfly.wav"), + + /* + * QUAKED weapon_shotgun (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("weapon_shotgun", PlayerWeapon.Pickup_Weapon, + PlayerWeapon.Use_Weapon, PlayerWeapon.Drop_Weapon, + PlayerWeapon.Weapon_Shotgun, "misc/w_pkup.wav", + "models/weapons/g_shotg/tris.md2", Defines.EF_ROTATE, + "models/weapons/v_shotg/tris.md2", + /* icon */ + "w_shotgun", + /* pickup */ + "Shotgun", 0, 1, "Shells", Defines.IT_WEAPON + | Defines.IT_STAY_COOP, Defines.WEAP_SHOTGUN, null, + 0, + /* precache */ + "weapons/shotgf1b.wav weapons/shotgr1b.wav"), + + /* + * QUAKED weapon_supershotgun (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("weapon_supershotgun", PlayerWeapon.Pickup_Weapon, + PlayerWeapon.Use_Weapon, PlayerWeapon.Drop_Weapon, + PlayerWeapon.Weapon_SuperShotgun, "misc/w_pkup.wav", + "models/weapons/g_shotg2/tris.md2", Defines.EF_ROTATE, + "models/weapons/v_shotg2/tris.md2", + /* icon */ + "w_sshotgun", + /* pickup */ + "Super Shotgun", 0, 2, "Shells", Defines.IT_WEAPON + | Defines.IT_STAY_COOP, Defines.WEAP_SUPERSHOTGUN, + null, 0, + /* precache */ + "weapons/sshotf1b.wav"), + + /* + * QUAKED weapon_machinegun (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t( + "weapon_machinegun", + PlayerWeapon.Pickup_Weapon, + PlayerWeapon.Use_Weapon, + PlayerWeapon.Drop_Weapon, + PlayerWeapon.Weapon_Machinegun, + "misc/w_pkup.wav", + "models/weapons/g_machn/tris.md2", + Defines.EF_ROTATE, + "models/weapons/v_machn/tris.md2", + /* icon */ + "w_machinegun", + /* pickup */ + "Machinegun", + 0, + 1, + "Bullets", + Defines.IT_WEAPON | Defines.IT_STAY_COOP, + Defines.WEAP_MACHINEGUN, + null, + 0, + /* precache */ + "weapons/machgf1b.wav weapons/machgf2b.wav weapons/machgf3b.wav weapons/machgf4b.wav weapons/machgf5b.wav"), + + /* + * QUAKED weapon_chaingun (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t( + "weapon_chaingun", + PlayerWeapon.Pickup_Weapon, + PlayerWeapon.Use_Weapon, + PlayerWeapon.Drop_Weapon, + PlayerWeapon.Weapon_Chaingun, + "misc/w_pkup.wav", + "models/weapons/g_chain/tris.md2", + Defines.EF_ROTATE, + "models/weapons/v_chain/tris.md2", + /* icon */ + "w_chaingun", + /* pickup */ + "Chaingun", + 0, + 1, + "Bullets", + Defines.IT_WEAPON | Defines.IT_STAY_COOP, + Defines.WEAP_CHAINGUN, + null, + 0, + /* precache */ + "weapons/chngnu1a.wav weapons/chngnl1a.wav weapons/machgf3b.wav` weapons/chngnd1a.wav"), + + /* + * QUAKED ammo_grenades (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t( + "ammo_grenades", + GameItems.Pickup_Ammo, + PlayerWeapon.Use_Weapon, + GameItems.Drop_Ammo, + PlayerWeapon.Weapon_Grenade, + "misc/am_pkup.wav", + "models/items/ammo/grenades/medium/tris.md2", + 0, + "models/weapons/v_handgr/tris.md2", + /* icon */ + "a_grenades", + /* pickup */ + "Grenades", + /* width */ + 3, + 5, + "grenades", + Defines.IT_AMMO | Defines.IT_WEAPON, + Defines.WEAP_GRENADES, + null, + Defines.AMMO_GRENADES, + /* precache */ + "weapons/hgrent1a.wav weapons/hgrena1b.wav weapons/hgrenc1b.wav weapons/hgrenb1a.wav weapons/hgrenb2a.wav "), + + /* + * QUAKED weapon_grenadelauncher (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t( + "weapon_grenadelauncher", + PlayerWeapon.Pickup_Weapon, + PlayerWeapon.Use_Weapon, + PlayerWeapon.Drop_Weapon, + PlayerWeapon.Weapon_GrenadeLauncher, + "misc/w_pkup.wav", + "models/weapons/g_launch/tris.md2", + Defines.EF_ROTATE, + "models/weapons/v_launch/tris.md2", + /* icon */ + "w_glauncher", + /* pickup */ + "Grenade Launcher", + 0, + 1, + "Grenades", + Defines.IT_WEAPON | Defines.IT_STAY_COOP, + Defines.WEAP_GRENADELAUNCHER, + null, + 0, + /* precache */ + "models/objects/grenade/tris.md2 weapons/grenlf1a.wav weapons/grenlr1b.wav weapons/grenlb1b.wav"), + + /* + * QUAKED weapon_rocketlauncher (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t( + "weapon_rocketlauncher", + PlayerWeapon.Pickup_Weapon, + PlayerWeapon.Use_Weapon, + PlayerWeapon.Drop_Weapon, + PlayerWeapon.Weapon_RocketLauncher, + "misc/w_pkup.wav", + "models/weapons/g_rocket/tris.md2", + Defines.EF_ROTATE, + "models/weapons/v_rocket/tris.md2", + /* icon */ + "w_rlauncher", + /* pickup */ + "Rocket Launcher", + 0, + 1, + "Rockets", + Defines.IT_WEAPON | Defines.IT_STAY_COOP, + Defines.WEAP_ROCKETLAUNCHER, + null, + 0, + /* precache */ + "models/objects/rocket/tris.md2 weapons/rockfly.wav weapons/rocklf1a.wav weapons/rocklr1b.wav models/objects/debris2/tris.md2"), + + /* + * QUAKED weapon_hyperblaster (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t( + "weapon_hyperblaster", + PlayerWeapon.Pickup_Weapon, + PlayerWeapon.Use_Weapon, + PlayerWeapon.Drop_Weapon, + PlayerWeapon.Weapon_HyperBlaster, + "misc/w_pkup.wav", + "models/weapons/g_hyperb/tris.md2", + Defines.EF_ROTATE, + "models/weapons/v_hyperb/tris.md2", + /* icon */ + "w_hyperblaster", + /* pickup */ + "HyperBlaster", + 0, + 1, + "Cells", + Defines.IT_WEAPON | Defines.IT_STAY_COOP, + Defines.WEAP_HYPERBLASTER, + null, + 0, + /* precache */ + "weapons/hyprbu1a.wav weapons/hyprbl1a.wav weapons/hyprbf1a.wav weapons/hyprbd1a.wav misc/lasfly.wav"), + + /* + * QUAKED weapon_railgun (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("weapon_railgun", PlayerWeapon.Pickup_Weapon, + PlayerWeapon.Use_Weapon, PlayerWeapon.Drop_Weapon, + PlayerWeapon.Weapon_Railgun, "misc/w_pkup.wav", + "models/weapons/g_rail/tris.md2", Defines.EF_ROTATE, + "models/weapons/v_rail/tris.md2", + /* icon */ + "w_railgun", + /* pickup */ + "Railgun", 0, 1, "Slugs", Defines.IT_WEAPON + | Defines.IT_STAY_COOP, Defines.WEAP_RAILGUN, null, + 0, + /* precache */ + "weapons/rg_hum.wav"), + + /* + * QUAKED weapon_bfg (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t( + "weapon_bfg", + PlayerWeapon.Pickup_Weapon, + PlayerWeapon.Use_Weapon, + PlayerWeapon.Drop_Weapon, + PlayerWeapon.Weapon_BFG, + "misc/w_pkup.wav", + "models/weapons/g_bfg/tris.md2", + Defines.EF_ROTATE, + "models/weapons/v_bfg/tris.md2", + /* icon */ + "w_bfg", + /* pickup */ + "BFG10K", + 0, + 50, + "Cells", + Defines.IT_WEAPON | Defines.IT_STAY_COOP, + Defines.WEAP_BFG, + null, + 0, + /* precache */ + "sprites/s_bfg1.sp2 sprites/s_bfg2.sp2 sprites/s_bfg3.sp2 weapons/bfg__f1y.wav weapons/bfg__l1a.wav weapons/bfg__x1b.wav weapons/bfg_hum.wav"), + + // + // AMMO ITEMS + // + + /* + * QUAKED ammo_shells (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("ammo_shells", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null, + "misc/am_pkup.wav", + "models/items/ammo/shells/medium/tris.md2", 0, null, + /* icon */ + "a_shells", + /* pickup */ + "Shells", + /* width */ + 3, 10, null, Defines.IT_AMMO, 0, null, Defines.AMMO_SHELLS, + /* precache */ + ""), + + /* + * QUAKED ammo_bullets (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("ammo_bullets", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null, + "misc/am_pkup.wav", + "models/items/ammo/bullets/medium/tris.md2", 0, null, + /* icon */ + "a_bullets", + /* pickup */ + "Bullets", + /* width */ + 3, 50, null, Defines.IT_AMMO, 0, null, + Defines.AMMO_BULLETS, + /* precache */ + ""), + + /* + * QUAKED ammo_cells (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("ammo_cells", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null, + "misc/am_pkup.wav", + "models/items/ammo/cells/medium/tris.md2", 0, null, + /* icon */ + "a_cells", + /* pickup */ + "Cells", + /* width */ + 3, 50, null, Defines.IT_AMMO, 0, null, Defines.AMMO_CELLS, + /* precache */ + ""), + + /* + * QUAKED ammo_rockets (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("ammo_rockets", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null, + "misc/am_pkup.wav", + "models/items/ammo/rockets/medium/tris.md2", 0, null, + /* icon */ + "a_rockets", + /* pickup */ + "Rockets", + /* width */ + 3, 5, null, Defines.IT_AMMO, 0, null, Defines.AMMO_ROCKETS, + /* precache */ + ""), + + /* + * QUAKED ammo_slugs (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("ammo_slugs", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null, + "misc/am_pkup.wav", + "models/items/ammo/slugs/medium/tris.md2", 0, null, + /* icon */ + "a_slugs", + /* pickup */ + "Slugs", + /* width */ + 3, 10, null, Defines.IT_AMMO, 0, null, Defines.AMMO_SLUGS, + /* precache */ + ""), + + // + // POWERUP ITEMS + // + /* + * QUAKED item_quad (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("item_quad", GameItems.Pickup_Powerup, GameItems.Use_Quad, + GameItems.Drop_General, null, "items/pkup.wav", + "models/items/quaddama/tris.md2", Defines.EF_ROTATE, null, + /* icon */ + "p_quad", + /* pickup */ + "Quad Damage", + /* width */ + 2, 60, null, Defines.IT_POWERUP, 0, null, 0, + /* precache */ + "items/damage.wav items/damage2.wav items/damage3.wav"), + + /* + * QUAKED item_invulnerability (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("item_invulnerability", GameItems.Pickup_Powerup, + GameItems.Use_Invulnerability, GameItems.Drop_General, null, + "items/pkup.wav", "models/items/invulner/tris.md2", + Defines.EF_ROTATE, null, + /* icon */ + "p_invulnerability", + /* pickup */ + "Invulnerability", + /* width */ + 2, 300, null, Defines.IT_POWERUP, 0, null, 0, + /* precache */ + "items/protect.wav items/protect2.wav items/protect4.wav"), + + /* + * QUAKED item_silencer (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("item_silencer", GameItems.Pickup_Powerup, GameItems.Use_Silencer, + GameItems.Drop_General, null, "items/pkup.wav", + "models/items/silencer/tris.md2", Defines.EF_ROTATE, null, + /* icon */ + "p_silencer", + /* pickup */ + "Silencer", + /* width */ + 2, 60, null, Defines.IT_POWERUP, 0, null, 0, + /* precache */ + ""), + + /* + * QUAKED item_breather (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("item_breather", GameItems.Pickup_Powerup, GameItems.Use_Breather, + GameItems.Drop_General, null, "items/pkup.wav", + "models/items/breather/tris.md2", Defines.EF_ROTATE, null, + /* icon */ + "p_rebreather", + /* pickup */ + "Rebreather", + /* width */ + 2, 60, null, Defines.IT_STAY_COOP | Defines.IT_POWERUP, 0, + null, 0, + /* precache */ + "items/airout.wav"), + + /* + * QUAKED item_enviro (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("item_enviro", GameItems.Pickup_Powerup, GameItems.Use_Envirosuit, + GameItems.Drop_General, null, "items/pkup.wav", + "models/items/enviro/tris.md2", Defines.EF_ROTATE, null, + /* icon */ + "p_envirosuit", + /* pickup */ + "Environment Suit", + /* width */ + 2, 60, null, Defines.IT_STAY_COOP | Defines.IT_POWERUP, 0, + null, 0, + /* precache */ + "items/airout.wav"), + + /* + * QUAKED item_ancient_head (.3 .3 1) (-16 -16 -16) (16 16 16) + * Special item that gives +2 to maximum health + */ + new gitem_t("item_ancient_head", GameItems.Pickup_AncientHead, null, null, + null, "items/pkup.wav", "models/items/c_head/tris.md2", + Defines.EF_ROTATE, null, + /* icon */ + "i_fixme", + /* pickup */ + "Ancient Head", + /* width */ + 2, 60, null, 0, 0, null, 0, + /* precache */ + ""), + + /* + * QUAKED item_adrenaline (.3 .3 1) (-16 -16 -16) (16 16 16) gives + * +1 to maximum health + */ + new gitem_t("item_adrenaline", GameItems.Pickup_Adrenaline, null, null, null, + "items/pkup.wav", "models/items/adrenal/tris.md2", + Defines.EF_ROTATE, null, + /* icon */ + "p_adrenaline", + /* pickup */ + "Adrenaline", + /* width */ + 2, 60, null, 0, 0, null, 0, + /* precache */ + ""), + + /* + * QUAKED item_bandolier (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("item_bandolier", GameItems.Pickup_Bandolier, null, null, null, + "items/pkup.wav", "models/items/band/tris.md2", + Defines.EF_ROTATE, null, + /* icon */ + "p_bandolier", + /* pickup */ + "Bandolier", + /* width */ + 2, 60, null, 0, 0, null, 0, + /* precache */ + ""), + + /* + * QUAKED item_pack (.3 .3 1) (-16 -16 -16) (16 16 16) + */ + new gitem_t("item_pack", GameItems.Pickup_Pack, null, null, null, + "items/pkup.wav", "models/items/pack/tris.md2", + Defines.EF_ROTATE, null, + /* icon */ + "i_pack", + /* pickup */ + "Ammo Pack", + /* width */ + 2, 180, null, 0, 0, null, 0, + /* precache */ + ""), + + // + // KEYS + // + /* + * QUAKED key_data_cd (0 .5 .8) (-16 -16 -16) (16 16 16) key for + * computer centers + */ + new gitem_t("key_data_cd", GameItems.Pickup_Key, null, GameItems.Drop_General, + null, "items/pkup.wav", + "models/items/keys/data_cd/tris.md2", Defines.EF_ROTATE, + null, "k_datacd", "Data CD", 2, 0, null, + Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0, + /* precache */ + ""), + + /* + * QUAKED key_power_cube (0 .5 .8) (-16 -16 -16) (16 16 16) + * TRIGGER_SPAWN NO_TOUCH warehouse circuits + */ + new gitem_t("key_power_cube", GameItems.Pickup_Key, null, + GameItems.Drop_General, null, "items/pkup.wav", + "models/items/keys/power/tris.md2", Defines.EF_ROTATE, + null, "k_powercube", "Power Cube", 2, 0, null, + Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0, + /* precache */ + ""), + + /* + * QUAKED key_pyramid (0 .5 .8) (-16 -16 -16) (16 16 16) key for the + * entrance of jail3 + */ + new gitem_t("key_pyramid", GameItems.Pickup_Key, null, GameItems.Drop_General, + null, "items/pkup.wav", + "models/items/keys/pyramid/tris.md2", Defines.EF_ROTATE, + null, "k_pyramid", "Pyramid Key", 2, 0, null, + Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0, + /* precache */ + ""), + + /* + * QUAKED key_data_spinner (0 .5 .8) (-16 -16 -16) (16 16 16) key + * for the city computer + */ + new gitem_t("key_data_spinner", GameItems.Pickup_Key, null, + GameItems.Drop_General, null, "items/pkup.wav", + "models/items/keys/spinner/tris.md2", Defines.EF_ROTATE, + null, "k_dataspin", "Data Spinner", 2, 0, null, + Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0, + /* precache */ + ""), + + /* + * QUAKED key_pass (0 .5 .8) (-16 -16 -16) (16 16 16) security pass + * for the security level + */ + new gitem_t("key_pass", GameItems.Pickup_Key, null, GameItems.Drop_General, + null, "items/pkup.wav", "models/items/keys/pass/tris.md2", + Defines.EF_ROTATE, null, "k_security", "Security Pass", 2, + 0, null, Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0, + /* precache */ + ""), + + /* + * QUAKED key_blue_key (0 .5 .8) (-16 -16 -16) (16 16 16) normal + * door key - blue + */ + new gitem_t("key_blue_key", GameItems.Pickup_Key, null, + GameItems.Drop_General, null, "items/pkup.wav", + "models/items/keys/key/tris.md2", Defines.EF_ROTATE, null, + "k_bluekey", "Blue Key", 2, 0, null, Defines.IT_STAY_COOP + | Defines.IT_KEY, 0, null, 0, + /* precache */ + ""), + + /* + * QUAKED key_red_key (0 .5 .8) (-16 -16 -16) (16 16 16) normal door + * key - red + */ + new gitem_t("key_red_key", GameItems.Pickup_Key, null, GameItems.Drop_General, + null, "items/pkup.wav", + "models/items/keys/red_key/tris.md2", Defines.EF_ROTATE, + null, "k_redkey", "Red Key", 2, 0, null, + Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0, + /* precache */ + ""), + + /* + * QUAKED key_commander_head (0 .5 .8) (-16 -16 -16) (16 16 16) tank + * commander's head + */ + new gitem_t("key_commander_head", GameItems.Pickup_Key, null, + GameItems.Drop_General, null, "items/pkup.wav", + "models/monsters/commandr/head/tris.md2", Defines.EF_GIB, + null, + /* icon */ + "k_comhead", + /* pickup */ + "Commander's Head", + /* width */ + 2, 0, null, Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, + 0, + /* precache */ + ""), + + /* + * QUAKED key_airstrike_target (0 .5 .8) (-16 -16 -16) (16 16 16) + * tank commander's head + */ + new gitem_t("key_airstrike_target", GameItems.Pickup_Key, null, + GameItems.Drop_General, null, "items/pkup.wav", + "models/items/keys/target/tris.md2", Defines.EF_ROTATE, + null, + /* icon */ + "i_airstrike", + /* pickup */ + "Airstrike Marker", + /* width */ + 2, 0, null, Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, + 0, + /* precache */ + ""), + new gitem_t(null, GameItems.Pickup_Health, null, null, null, + "items/pkup.wav", null, 0, null, + /* icon */ + "i_health", + /* pickup */ + "Health", + /* width */ + 3, 0, null, 0, 0, null, 0, + /* precache */ + "items/s_health.wav items/n_health.wav items/l_health.wav items/m_health.wav"), + + // end of list marker + null }; } diff --git a/src/main/java/lwjake2/game/GameMisc.java b/src/main/java/lwjake2/game/GameMisc.java index 8cebdae..0fa31f6 100644 --- a/src/main/java/lwjake2/game/GameMisc.java +++ b/src/main/java/lwjake2/game/GameMisc.java @@ -902,7 +902,7 @@ public class GameMisc { public String getID() { return "use_areaportal";} public void use(edict_t ent, edict_t other, edict_t activator) { ent.count ^= 1; // toggle state - // gi.dprintf ("portalstate: %i = %i\n", ent.style, ent.count); + // gi.dprintf ("portalstate: %i = %i\n", ent.style, ent.count); GameBase.gi.SetAreaPortalState(ent.style, ent.count != 0); } }; @@ -1871,7 +1871,7 @@ public class GameMisc { GameBase.gi.setmodel(ent, "models/objects/dmspot/tris.md2"); ent.s.skinnum = 0; ent.solid = Defines.SOLID_BBOX; - // ent.s.effects |= EF_FLIES; + // ent.s.effects |= EF_FLIES; Math3D.VectorSet(ent.mins, -32, -32, -24); Math3D.VectorSet(ent.maxs, 32, 32, -16); GameBase.gi.linkentity(ent); diff --git a/src/main/java/lwjake2/game/GameSVCmds.java b/src/main/java/lwjake2/game/GameSVCmds.java index c1d56ed..000c7cd 100644 --- a/src/main/java/lwjake2/game/GameSVCmds.java +++ b/src/main/java/lwjake2/game/GameSVCmds.java @@ -87,7 +87,7 @@ public class GameSVCmds { */ static boolean StringToFilter(String s, GameSVCmds.ipfilter_t f) { - byte b[] = { 0, 0, 0, 0 }; + byte b[] = { 0, 0, 0, 0 }; byte m[] = { 0, 0, 0, 0 }; try { diff --git a/src/main/java/lwjake2/game/GameSave.java b/src/main/java/lwjake2/game/GameSave.java index 117b69a..4ed35c7 100644 --- a/src/main/java/lwjake2/game/GameSave.java +++ b/src/main/java/lwjake2/game/GameSave.java @@ -41,71 +41,71 @@ public class GameSave { } private static String preloadclasslist [] = - { - "jake2.game.PlayerWeapon", - "jake2.game.AIAdapter", - "jake2.game.Cmd", - "jake2.game.EdictFindFilter", - "jake2.game.EdictIterator", - "jake2.game.EndianHandler", - "jake2.game.EntBlockedAdapter", - "jake2.game.EntDieAdapter", - "jake2.game.EntDodgeAdapter", - "jake2.game.EntInteractAdapter", - "jake2.game.EntPainAdapter", - "jake2.game.EntThinkAdapter", - "jake2.game.EntTouchAdapter", - "jake2.game.EntUseAdapter", - "jake2.game.GameAI", - "jake2.game.GameBase", - "jake2.game.GameChase", - "jake2.game.GameCombat", - "jake2.game.GameFunc", - "jake2.game.GameMisc", - "jake2.game.GameSVCmds", - "jake2.game.GameSave", - "jake2.game.GameSpawn", - "jake2.game.GameTarget", - "jake2.game.GameTrigger", - "jake2.game.GameTurret", - "jake2.game.GameUtil", - "jake2.game.GameWeapon", - "jake2.game.Info", - "jake2.game.ItemDropAdapter", - "jake2.game.ItemUseAdapter", - "jake2.game.Monster", - "jake2.game.PlayerClient", - "jake2.game.PlayerHud", - "jake2.game.PlayerTrail", - "jake2.game.PlayerView", - "jake2.game.SuperAdapter", - "jake2.game.monsters.M_Actor", - "jake2.game.monsters.M_Berserk", - "jake2.game.monsters.M_Boss2", - "jake2.game.monsters.M_Boss3", - "jake2.game.monsters.M_Boss31", - "jake2.game.monsters.M_Boss32", - "jake2.game.monsters.M_Brain", - "jake2.game.monsters.M_Chick", - "jake2.game.monsters.M_Flash", - "jake2.game.monsters.M_Flipper", - "jake2.game.monsters.M_Float", - "jake2.game.monsters.M_Flyer", - "jake2.game.monsters.M_Gladiator", - "jake2.game.monsters.M_Gunner", - "jake2.game.monsters.M_Hover", - "jake2.game.monsters.M_Infantry", - "jake2.game.monsters.M_Insane", - "jake2.game.monsters.M_Medic", - "jake2.game.monsters.M_Mutant", - "jake2.game.monsters.M_Parasite", - "jake2.game.monsters.M_Player", - "jake2.game.monsters.M_Soldier", - "jake2.game.monsters.M_Supertank", - "jake2.game.monsters.M_Tank", - "jake2.game.GameItems", - // DANGER! init as last, when all adatpers are != null - "jake2.game.GameItemList" + { + "jake2.game.PlayerWeapon", + "jake2.game.AIAdapter", + "jake2.game.Cmd", + "jake2.game.EdictFindFilter", + "jake2.game.EdictIterator", + "jake2.game.EndianHandler", + "jake2.game.EntBlockedAdapter", + "jake2.game.EntDieAdapter", + "jake2.game.EntDodgeAdapter", + "jake2.game.EntInteractAdapter", + "jake2.game.EntPainAdapter", + "jake2.game.EntThinkAdapter", + "jake2.game.EntTouchAdapter", + "jake2.game.EntUseAdapter", + "jake2.game.GameAI", + "jake2.game.GameBase", + "jake2.game.GameChase", + "jake2.game.GameCombat", + "jake2.game.GameFunc", + "jake2.game.GameMisc", + "jake2.game.GameSVCmds", + "jake2.game.GameSave", + "jake2.game.GameSpawn", + "jake2.game.GameTarget", + "jake2.game.GameTrigger", + "jake2.game.GameTurret", + "jake2.game.GameUtil", + "jake2.game.GameWeapon", + "jake2.game.Info", + "jake2.game.ItemDropAdapter", + "jake2.game.ItemUseAdapter", + "jake2.game.Monster", + "jake2.game.PlayerClient", + "jake2.game.PlayerHud", + "jake2.game.PlayerTrail", + "jake2.game.PlayerView", + "jake2.game.SuperAdapter", + "jake2.game.monsters.M_Actor", + "jake2.game.monsters.M_Berserk", + "jake2.game.monsters.M_Boss2", + "jake2.game.monsters.M_Boss3", + "jake2.game.monsters.M_Boss31", + "jake2.game.monsters.M_Boss32", + "jake2.game.monsters.M_Brain", + "jake2.game.monsters.M_Chick", + "jake2.game.monsters.M_Flash", + "jake2.game.monsters.M_Flipper", + "jake2.game.monsters.M_Float", + "jake2.game.monsters.M_Flyer", + "jake2.game.monsters.M_Gladiator", + "jake2.game.monsters.M_Gunner", + "jake2.game.monsters.M_Hover", + "jake2.game.monsters.M_Infantry", + "jake2.game.monsters.M_Insane", + "jake2.game.monsters.M_Medic", + "jake2.game.monsters.M_Mutant", + "jake2.game.monsters.M_Parasite", + "jake2.game.monsters.M_Player", + "jake2.game.monsters.M_Soldier", + "jake2.game.monsters.M_Supertank", + "jake2.game.monsters.M_Tank", + "jake2.game.GameItems", + // DANGER! init as last, when all adatpers are != null + "jake2.game.GameItemList" }; /** @@ -120,14 +120,14 @@ public class GameSave { // preload all classes to register the adapters for ( int n=0; n < preloadclasslist.length; n++) { - try - { - Class.forName(preloadclasslist[n]); - } - catch(Exception e) - { - Com.DPrintf("error loading class: " + e.getMessage()); - } + try + { + Class.forName(preloadclasslist[n]); + } + catch(Exception e) + { + Com.DPrintf("error loading class: " + e.getMessage()); + } } diff --git a/src/main/java/lwjake2/game/GameSpawn.java b/src/main/java/lwjake2/game/GameSpawn.java index 2b5d0e6..ff293e5 100644 --- a/src/main/java/lwjake2/game/GameSpawn.java +++ b/src/main/java/lwjake2/game/GameSpawn.java @@ -569,42 +569,42 @@ public class GameSpawn { PlayerTrail.Init(); } - static String single_statusbar = "yb -24 " // health - + "xv 0 " + "hnum " + "xv 50 " + "pic 0 " // ammo - + "if 2 " + " xv 100 " + " anum " + " xv 150 " + " pic 2 " - + "endif " // armor - + "if 4 " + " xv 200 " + " rnum " + " xv 250 " + " pic 4 " - + "endif " // selected item - + "if 6 " + " xv 296 " + " pic 6 " + "endif " + "yb -50 " // picked + static String single_statusbar = "yb -24 " // health + + "xv 0 " + "hnum " + "xv 50 " + "pic 0 " // ammo + + "if 2 " + " xv 100 " + " anum " + " xv 150 " + " pic 2 " + + "endif " // armor + + "if 4 " + " xv 200 " + " rnum " + " xv 250 " + " pic 4 " + + "endif " // selected item + + "if 6 " + " xv 296 " + " pic 6 " + "endif " + "yb -50 " // picked // up // item - + "if 7 " + " xv 0 " + " pic 7 " + " xv 26 " + " yb -42 " - + " stat_string 8 " + " yb -50 " + "endif " - // timer - + "if 9 " + " xv 262 " + " num 2 10 " + " xv 296 " + " pic 9 " + + "if 7 " + " xv 0 " + " pic 7 " + " xv 26 " + " yb -42 " + + " stat_string 8 " + " yb -50 " + "endif " + // timer + + "if 9 " + " xv 262 " + " num 2 10 " + " xv 296 " + " pic 9 " + "endif " - // help / weapon icon - + "if 11 " + " xv 148 " + " pic 11 " + "endif "; + // help / weapon icon + + "if 11 " + " xv 148 " + " pic 11 " + "endif "; - static String dm_statusbar = "yb -24 " // health - + "xv 0 " + "hnum " + "xv 50 " + "pic 0 " // ammo - + "if 2 " + " xv 100 " + " anum " + " xv 150 " + " pic 2 " - + "endif " // armor - + "if 4 " + " xv 200 " + " rnum " + " xv 250 " + " pic 4 " - + "endif " // selected item - + "if 6 " + " xv 296 " + " pic 6 " + "endif " + "yb -50 " // picked + static String dm_statusbar = "yb -24 " // health + + "xv 0 " + "hnum " + "xv 50 " + "pic 0 " // ammo + + "if 2 " + " xv 100 " + " anum " + " xv 150 " + " pic 2 " + + "endif " // armor + + "if 4 " + " xv 200 " + " rnum " + " xv 250 " + " pic 4 " + + "endif " // selected item + + "if 6 " + " xv 296 " + " pic 6 " + "endif " + "yb -50 " // picked // up // item - + "if 7 " + " xv 0 " + " pic 7 " + " xv 26 " + " yb -42 " - + " stat_string 8 " + " yb -50 " + "endif " - // timer - + "if 9 " + " xv 246 " + " num 2 10 " + " xv 296 " + " pic 9 " + + "if 7 " + " xv 0 " + " pic 7 " + " xv 26 " + " yb -42 " + + " stat_string 8 " + " yb -50 " + "endif " + // timer + + "if 9 " + " xv 246 " + " num 2 10 " + " xv 296 " + " pic 9 " + "endif " - // help / weapon icon - + "if 11 " + " xv 148 " + " pic 11 " + "endif " // frags - + "xr -50 " + "yt 2 " + "num 3 14 " // spectator + // help / weapon icon + + "if 11 " + " xv 148 " + " pic 11 " + "endif " // frags + + "xr -50 " + "yt 2 " + "num 3 14 " // spectator + "if 17 " + "xv 0 " + "yb -58 " + "string2 \"SPECTATOR MODE\" " - + "endif " // chase camera + + "endif " // chase camera + "if 16 " + "xv 0 " + "yb -68 " + "string \"Chasing\" " + "xv 64 " + "stat_string 16 " + "endif "; diff --git a/src/main/java/lwjake2/game/GameTarget.java b/src/main/java/lwjake2/game/GameTarget.java index 182b776..86ea181 100644 --- a/src/main/java/lwjake2/game/GameTarget.java +++ b/src/main/java/lwjake2/game/GameTarget.java @@ -261,7 +261,7 @@ public class GameTarget { * temp entity event to the clients. "style" type byte */ public static EntUseAdapter Use_Target_Tent = new EntUseAdapter() { - public String getID() { return "Use_Target_Tent"; } + public String getID() { return "Use_Target_Tent"; } public void use(edict_t ent, edict_t other, edict_t activator) { GameBase.gi.WriteByte(Defines.svc_temp_entity); GameBase.gi.WriteByte(ent.style); @@ -284,7 +284,7 @@ public class GameTarget { * without any speed cost. */ public static EntUseAdapter Use_Target_Speaker = new EntUseAdapter() { - public String getID() { return "Use_Target_Speaker"; } + public String getID() { return "Use_Target_Speaker"; } public void use(edict_t ent, edict_t other, edict_t activator) { int chan; @@ -309,7 +309,7 @@ public class GameTarget { public static EntUseAdapter Use_Target_Help = new EntUseAdapter() { - public String getID() { return "Use_Target_Help"; } + public String getID() { return "Use_Target_Help"; } public void use(edict_t ent, edict_t other, edict_t activator) { if ((ent.spawnflags & 1) != 0) @@ -326,7 +326,7 @@ public class GameTarget { * These are single use targets. */ static EntUseAdapter use_target_secret = new EntUseAdapter() { - public String getID() { return "use_target_secret"; } + public String getID() { return "use_target_secret"; } public void use(edict_t ent, edict_t other, edict_t activator) { GameBase.gi.sound(ent, Defines.CHAN_VOICE, ent.noise_index, 1, Defines.ATTN_NORM, 0); @@ -343,7 +343,7 @@ public class GameTarget { * These are single use targets. */ static EntUseAdapter use_target_goal = new EntUseAdapter() { - public String getID() { return "use_target_goal"; } + public String getID() { return "use_target_goal"; } public void use(edict_t ent, edict_t other, edict_t activator) { GameBase.gi.sound(ent, Defines.CHAN_VOICE, ent.noise_index, 1, Defines.ATTN_NORM, 0); @@ -367,7 +367,7 @@ public class GameTarget { * should be done, defaults to 0 */ static EntThinkAdapter target_explosion_explode = new EntThinkAdapter() { - public String getID() { return "target_explosion_explode"; } + public String getID() { return "target_explosion_explode"; } public boolean think(edict_t self) { float save; @@ -389,7 +389,7 @@ public class GameTarget { }; static EntUseAdapter use_target_explosion = new EntUseAdapter() { - public String getID() { return "use_target_explosion"; } + public String getID() { return "use_target_explosion"; } public void use(edict_t self, edict_t other, edict_t activator) { self.activator = activator; @@ -408,7 +408,7 @@ public class GameTarget { * "map" when fired */ static EntUseAdapter use_target_changelevel = new EntUseAdapter() { - public String getID() { return "use_target_changelevel"; } + public String getID() { return "use_target_changelevel"; } public void use(edict_t self, edict_t other, edict_t activator) { if (GameBase.level.intermissiontime != 0) return; // already activated @@ -456,7 +456,7 @@ public class GameTarget { * at this location when it splashes useful for lava/sparks */ static EntUseAdapter use_target_splash = new EntUseAdapter() { - public String getID() { return "use_target_splash"; } + public String getID() { return "use_target_splash"; } public void use(edict_t self, edict_t other, edict_t activator) { GameBase.gi.WriteByte(Defines.svc_temp_entity); GameBase.gi.WriteByte(Defines.TE_SPLASH); @@ -484,7 +484,7 @@ public class GameTarget { */ static EntUseAdapter use_target_spawner = new EntUseAdapter() { - public String getID() { return "use_target_spawner"; } + public String getID() { return "use_target_spawner"; } public void use(edict_t self, edict_t other, edict_t activator) { edict_t ent; @@ -508,10 +508,10 @@ public class GameTarget { * dmg default is 15 speed default is 1000 */ public static EntUseAdapter use_target_blaster = new EntUseAdapter() { - public String getID() { return "use_target_blaster"; } + public String getID() { return "use_target_blaster"; } public void use(edict_t self, edict_t other, edict_t activator) { - - /* Wait what - flibit + + /* Wait what - flibit int effect; if ((self.spawnflags & 2) != 0) @@ -520,7 +520,7 @@ public class GameTarget { effect = Defines.EF_HYPERBLASTER; else effect = Defines.EF_BLASTER; - */ + */ GameWeapon.fire_blaster(self, self.s.origin, self.movedir, self.dmg, (int) self.speed, Defines.EF_BLASTER, @@ -541,7 +541,7 @@ public class GameTarget { * and killtarget also work. */ public static EntUseAdapter trigger_crosslevel_trigger_use = new EntUseAdapter() { - public String getID() { return "trigger_crosslevel_trigger_use"; } + public String getID() { return "trigger_crosslevel_trigger_use"; } public void use(edict_t self, edict_t other, edict_t activator) { GameBase.game.serverflags |= self.spawnflags; GameUtil.G_FreeEdict(self); @@ -558,7 +558,7 @@ public class GameTarget { * (default 1) */ static EntThinkAdapter target_crosslevel_target_think = new EntThinkAdapter() { - public String getID() { return "target_crosslevel_target_think"; } + public String getID() { return "target_crosslevel_target_think"; } public boolean think(edict_t self) { if (self.spawnflags == (GameBase.game.serverflags & Defines.SFL_CROSS_TRIGGER_MASK & self.spawnflags)) { @@ -575,7 +575,7 @@ public class GameTarget { * target or a direction. */ public static EntThinkAdapter target_laser_think = new EntThinkAdapter() { - public String getID() { return "target_laser_think"; } + public String getID() { return "target_laser_think"; } public boolean think(edict_t self) { edict_t ignore; @@ -648,7 +648,7 @@ public class GameTarget { }; public static EntUseAdapter target_laser_use = new EntUseAdapter() { - public String getID() { return "target_laser_use"; } + public String getID() { return "target_laser_use"; } public void use(edict_t self, edict_t other, edict_t activator) { self.activator = activator; @@ -660,7 +660,7 @@ public class GameTarget { }; static EntThinkAdapter target_laser_start = new EntThinkAdapter() { - public String getID() { return "target_laser_start"; } + public String getID() { return "target_laser_start"; } public boolean think(edict_t self) { self.movetype = Defines.MOVETYPE_NONE; @@ -724,7 +724,7 @@ public class GameTarget { */ static EntThinkAdapter target_lightramp_think = new EntThinkAdapter() { - public String getID() { return "target_lightramp_think"; } + public String getID() { return "target_lightramp_think"; } public boolean think(edict_t self) { char tmp[] = {(char) ('a' + (int) (self.movedir[0] + (GameBase.level.time - self.timestamp) @@ -749,7 +749,7 @@ public class GameTarget { }; static EntUseAdapter target_lightramp_use = new EntUseAdapter() { - public String getID() { return "target_lightramp_use"; } + public String getID() { return "target_lightramp_use"; } public void use(edict_t self, edict_t other, edict_t activator) { if (self.enemy == null) { edict_t e; @@ -800,7 +800,7 @@ public class GameTarget { */ static EntThinkAdapter target_earthquake_think = new EntThinkAdapter() { - public String getID() { return "target_earthquake_think"; } + public String getID() { return "target_earthquake_think"; } public boolean think(edict_t self) { int i; @@ -837,7 +837,7 @@ public class GameTarget { }; static EntUseAdapter target_earthquake_use = new EntUseAdapter() { - public String getID() { return "target_earthquake_use"; } + public String getID() { return "target_earthquake_use"; } public void use(edict_t self, edict_t other, edict_t activator) { self.timestamp = GameBase.level.time + self.count; self.nextthink = GameBase.level.time + Defines.FRAMETIME; diff --git a/src/main/java/lwjake2/game/GameTrigger.java b/src/main/java/lwjake2/game/GameTrigger.java index 5376762..b63ea46 100644 --- a/src/main/java/lwjake2/game/GameTrigger.java +++ b/src/main/java/lwjake2/game/GameTrigger.java @@ -233,7 +233,7 @@ public class GameTrigger { // the wait time has passed, so set back up for another activation public static EntThinkAdapter multi_wait = new EntThinkAdapter() { - public String getID(){ return "multi_wait"; } + public String getID(){ return "multi_wait"; } public boolean think(edict_t ent) { ent.nextthink = 0; @@ -242,7 +242,7 @@ public class GameTrigger { }; static EntUseAdapter Use_Multi = new EntUseAdapter() { - public String getID(){ return "Use_Multi"; } + public String getID(){ return "Use_Multi"; } public void use(edict_t ent, edict_t other, edict_t activator) { ent.activator = activator; multi_trigger(ent); @@ -250,7 +250,7 @@ public class GameTrigger { }; static EntTouchAdapter Touch_Multi = new EntTouchAdapter() { - public String getID(){ return "Touch_Multi"; } + public String getID(){ return "Touch_Multi"; } public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { if (other.client != null) { @@ -283,7 +283,7 @@ public class GameTrigger { * 1) secret 2) beep beep 3) large switch 4) set "message" to text string */ static EntUseAdapter trigger_enable = new EntUseAdapter() { - public String getID(){ return "trigger_enable"; } + public String getID(){ return "trigger_enable"; } public void use(edict_t self, edict_t other, edict_t activator) { self.solid = Defines.SOLID_TRIGGER; self.use = Use_Multi; @@ -296,7 +296,7 @@ public class GameTrigger { * trigger cannot be touched, it can only be fired by other events. */ public static EntUseAdapter trigger_relay_use = new EntUseAdapter() { - public String getID(){ return "trigger_relay_use"; } + public String getID(){ return "trigger_relay_use"; } public void use(edict_t self, edict_t other, edict_t activator) { GameUtil.G_UseTargets(self, activator); } @@ -317,7 +317,7 @@ public class GameTrigger { */ static EntUseAdapter trigger_key_use = new EntUseAdapter() { - public String getID(){ return "trigger_key_use"; } + public String getID(){ return "trigger_key_use"; } public void use(edict_t self, edict_t other, edict_t activator) { int index; @@ -334,7 +334,7 @@ public class GameTrigger { GameBase.gi.centerprintf(activator, "You need the " + self.item.pickup_name); GameBase.gi.sound(activator, Defines.CHAN_AUTO, - GameBase.gi.soundindex("misc/keytry.wav"), 1, + GameBase.gi.soundindex("misc/keytry.wav"), 1, Defines.ATTN_NORM, 0); return; } @@ -393,7 +393,7 @@ public class GameTrigger { * fire all of it's targets and remove itself. */ static EntUseAdapter trigger_counter_use = new EntUseAdapter() { - public String getID(){ return "trigger_counter_use"; } + public String getID(){ return "trigger_counter_use"; } public void use(edict_t self, edict_t other, edict_t activator) { if (self.count == 0) @@ -435,7 +435,7 @@ public class GameTrigger { public static int windsound; static EntTouchAdapter trigger_push_touch = new EntTouchAdapter() { - public String getID(){ return "trigger_push_touch"; } + public String getID(){ return "trigger_push_touch"; } public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { if (Lib.strcmp(other.classname, "grenade") == 0) { @@ -474,7 +474,7 @@ public class GameTrigger { * */ static EntUseAdapter hurt_use = new EntUseAdapter() { - public String getID(){ return "hurt_use"; } + public String getID(){ return "hurt_use"; } public void use(edict_t self, edict_t other, edict_t activator) { if (self.solid == Defines.SOLID_NOT) @@ -489,7 +489,7 @@ public class GameTrigger { }; static EntTouchAdapter hurt_touch = new EntTouchAdapter() { - public String getID(){ return "hurt_touch"; } + public String getID(){ return "hurt_touch"; } public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { int dflags; @@ -535,7 +535,7 @@ public class GameTrigger { */ static EntTouchAdapter trigger_gravity_touch = new EntTouchAdapter() { - public String getID(){ return "trigger_gravity_touch"; } + public String getID(){ return "trigger_gravity_touch"; } public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { @@ -559,7 +559,7 @@ public class GameTrigger { */ static EntTouchAdapter trigger_monsterjump_touch = new EntTouchAdapter() { - public String getID(){ return "trigger_monsterjump_touch"; } + public String getID(){ return "trigger_monsterjump_touch"; } public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { if ((other.flags & (Defines.FL_FLY | Defines.FL_SWIM)) != 0) diff --git a/src/main/java/lwjake2/game/GameTurret.java b/src/main/java/lwjake2/game/GameTurret.java index 19754d6..39cf070 100644 --- a/src/main/java/lwjake2/game/GameTurret.java +++ b/src/main/java/lwjake2/game/GameTurret.java @@ -172,7 +172,7 @@ public class GameTurret { } static EntBlockedAdapter turret_blocked = new EntBlockedAdapter() { - public String getID() { return "turret_blocked"; } + public String getID() { return "turret_blocked"; } public void blocked(edict_t self, edict_t other) { edict_t attacker; @@ -189,7 +189,7 @@ public class GameTurret { }; static EntThinkAdapter turret_breach_think = new EntThinkAdapter() { - public String getID() { return "turret_breach_think"; } + public String getID() { return "turret_breach_think"; } public boolean think(edict_t self) { edict_t ent; @@ -274,9 +274,9 @@ public class GameTurret { angle = self.s.angles[1] + self.owner.move_origin[1]; angle *= (Math.PI * 2 / 360); target[0] = GameTurret.SnapToEights((float) (self.s.origin[0] + - Math.cos(angle) * self.owner.move_origin[0])); + Math.cos(angle) * self.owner.move_origin[0])); target[1] = GameTurret.SnapToEights((float) (self.s.origin[1] + - Math.sin(angle) * self.owner.move_origin[0])); + Math.sin(angle) * self.owner.move_origin[0])); target[2] = self.owner.s.origin[2]; Math3D.VectorSubtract(target, self.owner.s.origin, dir); @@ -301,7 +301,7 @@ public class GameTurret { }; static EntThinkAdapter turret_breach_finish_init = new EntThinkAdapter() { - public String getID() { return "turret_breach_finish_init"; } + public String getID() { return "turret_breach_finish_init"; } public boolean think(edict_t self) { // get and save info for muzzle location @@ -328,7 +328,7 @@ public class GameTurret { * turret_breach. */ static EntDieAdapter turret_driver_die = new EntDieAdapter() { - public String getID() { return "turret_driver_die"; } + public String getID() { return "turret_driver_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { @@ -352,7 +352,7 @@ public class GameTurret { }; static EntThinkAdapter turret_driver_think = new EntThinkAdapter() { - public String getID() { return "turret_driver_think"; } + public String getID() { return "turret_driver_think"; } public boolean think(edict_t self) { float[] target = { 0, 0, 0 }; @@ -405,7 +405,7 @@ public class GameTurret { }; public static EntThinkAdapter turret_driver_link = new EntThinkAdapter() { - public String getID() { return "turret_driver_link"; } + public String getID() { return "turret_driver_link"; } public boolean think(edict_t self) { float[] vec = { 0, 0, 0 }; diff --git a/src/main/java/lwjake2/game/GameUtil.java b/src/main/java/lwjake2/game/GameUtil.java index 242f2cb..5180552 100644 --- a/src/main/java/lwjake2/game/GameUtil.java +++ b/src/main/java/lwjake2/game/GameUtil.java @@ -542,7 +542,7 @@ public class GameUtil { } public static EntThinkAdapter Think_Delay = new EntThinkAdapter() { - public String getID() { return "Think_Delay"; } + public String getID() { return "Think_Delay"; } public boolean think(edict_t ent) { G_UseTargets(ent, ent.activator); G_FreeEdict(ent); @@ -551,7 +551,7 @@ public class GameUtil { }; public static EntThinkAdapter G_FreeEdictA = new EntThinkAdapter() { - public String getID() { return "G_FreeEdictA"; } + public String getID() { return "G_FreeEdictA"; } public boolean think(edict_t ent) { G_FreeEdict(ent); return false; @@ -559,7 +559,7 @@ public class GameUtil { }; static EntThinkAdapter MegaHealth_think = new EntThinkAdapter() { - public String getID() { return "MegaHealth_think"; } + public String getID() { return "MegaHealth_think"; } public boolean think(edict_t self) { if (self.owner.health > self.owner.max_health) { self.nextthink = GameBase.level.time + 1; @@ -579,7 +579,7 @@ public class GameUtil { public static EntThinkAdapter M_CheckAttack = new EntThinkAdapter() { - public String getID() { return "M_CheckAttack"; } + public String getID() { return "M_CheckAttack"; } public boolean think(edict_t self) { float[] spot1 = { 0, 0, 0 }; @@ -665,7 +665,7 @@ public class GameUtil { }; static EntUseAdapter monster_use = new EntUseAdapter() { - public String getID() { return "monster_use"; } + public String getID() { return "monster_use"; } public void use(edict_t self, edict_t other, edict_t activator) { if (self.enemy != null) return; diff --git a/src/main/java/lwjake2/game/GameWeapon.java b/src/main/java/lwjake2/game/GameWeapon.java index b65af81..41bc7eb 100644 --- a/src/main/java/lwjake2/game/GameWeapon.java +++ b/src/main/java/lwjake2/game/GameWeapon.java @@ -26,7 +26,7 @@ import lwjake2.util.Math3D; public class GameWeapon { static EntTouchAdapter blaster_touch = new EntTouchAdapter() { - public String getID() { return "blaster_touch"; } + public String getID() { return "blaster_touch"; } public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { @@ -77,7 +77,7 @@ public class GameWeapon { }; static EntThinkAdapter Grenade_Explode = new EntThinkAdapter() { - public String getID() { return "Grenade_Explode"; } + public String getID() { return "Grenade_Explode"; } public boolean think(edict_t ent) { float[] origin = { 0, 0, 0 }; int mod; @@ -137,7 +137,7 @@ public class GameWeapon { } }; static EntTouchAdapter Grenade_Touch = new EntTouchAdapter() { - public String getID() { return "Grenade_Touch"; } + public String getID() { return "Grenade_Touch"; } public void touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf) { if (other == ent.owner) @@ -177,7 +177,7 @@ public class GameWeapon { * ================= */ static EntTouchAdapter rocket_touch = new EntTouchAdapter() { - public String getID() { return "rocket_touch"; } + public String getID() { return "rocket_touch"; } public void touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf) { float[] origin = { 0, 0, 0 }; @@ -238,7 +238,7 @@ public class GameWeapon { * ================= */ static EntThinkAdapter bfg_explode = new EntThinkAdapter() { - public String getID() { return "bfg_explode"; } + public String getID() { return "bfg_explode"; } public boolean think(edict_t self) { edict_t ent; float points; @@ -291,7 +291,7 @@ public class GameWeapon { }; static EntTouchAdapter bfg_touch = new EntTouchAdapter() { - public String getID() { return "bfg_touch"; } + public String getID() { return "bfg_touch"; } public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { if (other == self.owner) @@ -338,7 +338,7 @@ public class GameWeapon { }; static EntThinkAdapter bfg_think = new EntThinkAdapter() { - public String getID() { return "bfg_think"; } + public String getID() { return "bfg_think"; } public boolean think(edict_t self) { edict_t ent; edict_t ignore; diff --git a/src/main/java/lwjake2/game/Info.java b/src/main/java/lwjake2/game/Info.java index 3de39d3..4960523 100644 --- a/src/main/java/lwjake2/game/Info.java +++ b/src/main/java/lwjake2/game/Info.java @@ -25,9 +25,9 @@ import java.util.StringTokenizer; public class Info { - /** - * Returns a value for a key from an info string. - */ + /** + * Returns a value for a key from an info string. + */ public static String Info_ValueForKey(String s, String key) { StringTokenizer tk = new StringTokenizer(s, "\\"); diff --git a/src/main/java/lwjake2/game/ItemDropAdapter.java b/src/main/java/lwjake2/game/ItemDropAdapter.java index 24a30bb..342e726 100644 --- a/src/main/java/lwjake2/game/ItemDropAdapter.java +++ b/src/main/java/lwjake2/game/ItemDropAdapter.java @@ -19,6 +19,6 @@ package lwjake2.game; public abstract class ItemDropAdapter extends SuperAdapter { - public void drop(edict_t ent, gitem_t item) { - } + public void drop(edict_t ent, gitem_t item) { + } } diff --git a/src/main/java/lwjake2/game/ItemUseAdapter.java b/src/main/java/lwjake2/game/ItemUseAdapter.java index 15e5f8f..0fd3b83 100644 --- a/src/main/java/lwjake2/game/ItemUseAdapter.java +++ b/src/main/java/lwjake2/game/ItemUseAdapter.java @@ -19,6 +19,6 @@ package lwjake2.game; public abstract class ItemUseAdapter extends SuperAdapter { - public void use(edict_t ent, gitem_t item) { - } + public void use(edict_t ent, gitem_t item) { + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/game/Monster.java b/src/main/java/lwjake2/game/Monster.java index 426c458..fe7e11b 100644 --- a/src/main/java/lwjake2/game/Monster.java +++ b/src/main/java/lwjake2/game/Monster.java @@ -27,9 +27,9 @@ import lwjake2.util.Math3D; public class Monster { // FIXME monsters should call these with a totally accurate direction - // and we can mess it up based on skill. Spread should be for normal - // and we can tighten or loosen based on skill. We could muck with - // the damages too, but I'm not sure that's such a good idea. + // and we can mess it up based on skill. Spread should be for normal + // and we can tighten or loosen based on skill. We could muck with + // the damages too, but I'm not sure that's such a good idea. public static void monster_fire_bullet(edict_t self, float[] start, float[] dir, int damage, int kick, int hspread, int vspread, int flashtype) { @@ -148,7 +148,7 @@ public class Monster { && 0 == (self.monsterinfo.aiflags & Defines.AI_GOOD_GUY)) { self.spawnflags &= ~4; self.spawnflags |= 1; - // gi.dprintf("fixed spawnflags on %s at %s\n", self.classname, + // gi.dprintf("fixed spawnflags on %s at %s\n", self.classname, // vtos(self.s.origin)); } @@ -328,7 +328,7 @@ public class Monster { } }; - // we have a one frame delay here so we don't telefrag the guy who activated + // we have a one frame delay here so we don't telefrag the guy who activated // us public static EntUseAdapter monster_triggered_spawn_use = new EntUseAdapter() { public String getID() { return "monster_trigger_spawn_use";} diff --git a/src/main/java/lwjake2/game/PlayerClient.java b/src/main/java/lwjake2/game/PlayerClient.java index 87321e1..a106b11 100644 --- a/src/main/java/lwjake2/game/PlayerClient.java +++ b/src/main/java/lwjake2/game/PlayerClient.java @@ -31,7 +31,7 @@ public class PlayerClient { * player_die. */ static EntDieAdapter player_die = new EntDieAdapter() { - public String getID() { return "player_die"; } + public String getID() { return "player_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { int n; @@ -129,7 +129,7 @@ public class PlayerClient { } }; static EntThinkAdapter SP_FixCoopSpots = new EntThinkAdapter() { - public String getID() { return "SP_FixCoopSpots"; } + public String getID() { return "SP_FixCoopSpots"; } public boolean think(edict_t self) { edict_t spot; @@ -165,7 +165,7 @@ public class PlayerClient { } }; static EntThinkAdapter SP_CreateCoopSpots = new EntThinkAdapter() { - public String getID() { return "SP_CreateCoopSpots"; } + public String getID() { return "SP_CreateCoopSpots"; } public boolean think(edict_t self) { edict_t spot; @@ -200,12 +200,12 @@ public class PlayerClient { }; // player pain is handled at the end of the frame in P_DamageFeedback static EntPainAdapter player_pain = new EntPainAdapter() { - public String getID() { return "player_pain"; } + public String getID() { return "player_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { } }; static EntDieAdapter body_die = new EntDieAdapter() { - public String getID() { return "body_die"; } + public String getID() { return "body_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { @@ -213,7 +213,7 @@ public class PlayerClient { if (self.health < -40) { GameBase.gi.sound(self, Defines.CHAN_BODY, - GameBase.gi.soundindex("misc/udeath.wav"), 1, Defines.ATTN_NORM, 0); + GameBase.gi.soundindex("misc/udeath.wav"), 1, Defines.ATTN_NORM, 0); for (n = 0; n < 4; n++) GameMisc.ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", damage, Defines.GIB_ORGANIC); @@ -658,7 +658,7 @@ public class PlayerClient { } /** - * If turned on in the dmflags, select a spawn point far away from other players. + * If turned on in the dmflags, select a spawn point far away from other players. */ static edict_t SelectFarthestDeathmatchSpawnPoint() { edict_t bestspot; @@ -1370,19 +1370,19 @@ public class PlayerClient { /* * static int CheckBlock(int c) * { - * int v, i; - * v = 0; - * for (i = 0; i < c; i++) - * v += ((byte *) b)[i]; - * return v; + * int v, i; + * v = 0; + * for (i = 0; i < c; i++) + * v += ((byte *) b)[i]; + * return v; * } * * public static void PrintPmove(pmove_t * pm) * { - * unsigned c1, c2; + * unsigned c1, c2; * - * c1 = CheckBlock(&pm.s, sizeof(pm.s)); - * c2 = CheckBlock(&pm.cmd, sizeof(pm.cmd)); + * c1 = CheckBlock(&pm.s, sizeof(pm.s)); + * c2 = CheckBlock(&pm.cmd, sizeof(pm.cmd)); * Com_Printf("sv %3i:%i %i\n", pm.cmd.impulse, c1, c2); * } */ diff --git a/src/main/java/lwjake2/game/PlayerView.java b/src/main/java/lwjake2/game/PlayerView.java index 51bf224..fe6dee7 100644 --- a/src/main/java/lwjake2/game/PlayerView.java +++ b/src/main/java/lwjake2/game/PlayerView.java @@ -232,7 +232,7 @@ public class PlayerView { ent.client.ps.viewangles[Defines.PITCH] = -15; ent.client.ps.viewangles[Defines.YAW] = ent.client.killer_yaw; } else { - + // add angles based on weapon kick Math3D.VectorCopy(ent.client.kick_angles, angles); @@ -353,7 +353,7 @@ public class PlayerView { // gun height Math3D.VectorClear(ent.client.ps.gunoffset); - // ent.ps.gunorigin[2] += bob; + // ent.ps.gunorigin[2] += bob; // gun_x / gun_y / gun_z are development tools for (i = 0; i < 3; i++) { @@ -411,14 +411,14 @@ public class PlayerView { remaining = (int) (ent.client.quad_framenum - GameBase.level.framenum); if (remaining == 30) // beginning to fade GameBase.gi.sound(ent, Defines.CHAN_ITEM, - GameBase.gi.soundindex("items/damage2.wav"), 1, Defines.ATTN_NORM, 0); + GameBase.gi.soundindex("items/damage2.wav"), 1, Defines.ATTN_NORM, 0); if (remaining > 30 || (remaining & 4) != 0) SV_AddBlend(0, 0, 1, 0.08f, ent.client.ps.blend); } else if (ent.client.invincible_framenum > GameBase.level.framenum) { remaining = (int) ent.client.invincible_framenum - GameBase.level.framenum; if (remaining == 30) // beginning to fade GameBase.gi.sound(ent, Defines.CHAN_ITEM, - GameBase.gi.soundindex("items/protect2.wav"), 1, Defines.ATTN_NORM, 0); + GameBase.gi.soundindex("items/protect2.wav"), 1, Defines.ATTN_NORM, 0); if (remaining > 30 || (remaining & 4) != 0) SV_AddBlend(1, 1, 0, 0.08f, ent.client.ps.blend); } else if (ent.client.enviro_framenum > GameBase.level.framenum) { @@ -426,7 +426,7 @@ public class PlayerView { - GameBase.level.framenum; if (remaining == 30) // beginning to fade GameBase.gi.sound(ent, Defines.CHAN_ITEM, - GameBase.gi.soundindex("items/airout.wav"), 1, Defines.ATTN_NORM, 0); + GameBase.gi.soundindex("items/airout.wav"), 1, Defines.ATTN_NORM, 0); if (remaining > 30 || (remaining & 4) != 0) SV_AddBlend(0, 1, 0, 0.08f, ent.client.ps.blend); } else if (ent.client.breather_framenum > GameBase.level.framenum) { diff --git a/src/main/java/lwjake2/game/PlayerWeapon.java b/src/main/java/lwjake2/game/PlayerWeapon.java index 325137f..4978306 100644 --- a/src/main/java/lwjake2/game/PlayerWeapon.java +++ b/src/main/java/lwjake2/game/PlayerWeapon.java @@ -27,7 +27,7 @@ import lwjake2.util.Math3D; public class PlayerWeapon { public static EntThinkAdapter Weapon_Grenade = new EntThinkAdapter() { - public String getID() { return "Weapon_Grenade"; } + public String getID() { return "Weapon_Grenade"; } public boolean think(edict_t ent) { if ((ent.client.newweapon != null) @@ -139,7 +139,7 @@ public class PlayerWeapon { */ public static EntThinkAdapter weapon_grenadelauncher_fire = new EntThinkAdapter() { - public String getID() { return "weapon_grenadelauncher_fire"; } + public String getID() { return "weapon_grenadelauncher_fire"; } public boolean think(edict_t ent) { float[] offset = { 0, 0, 0 }; @@ -179,7 +179,7 @@ public class PlayerWeapon { }; public static EntThinkAdapter Weapon_GrenadeLauncher = new EntThinkAdapter() { - public String getID() { return "Weapon_GrenadeLauncher"; } + public String getID() { return "Weapon_GrenadeLauncher"; } public boolean think(edict_t ent) { @@ -201,7 +201,7 @@ public class PlayerWeapon { */ public static EntThinkAdapter Weapon_RocketLauncher_Fire = new EntThinkAdapter() { - public String getID() { return "Weapon_RocketLauncher_Fire"; } + public String getID() { return "Weapon_RocketLauncher_Fire"; } public boolean think(edict_t ent) { @@ -249,7 +249,7 @@ public class PlayerWeapon { }; public static EntThinkAdapter Weapon_RocketLauncher = new EntThinkAdapter() { - public String getID() { return "Weapon_RocketLauncher"; } + public String getID() { return "Weapon_RocketLauncher"; } public boolean think(edict_t ent) { @@ -263,7 +263,7 @@ public class PlayerWeapon { }; public static EntThinkAdapter Weapon_Blaster_Fire = new EntThinkAdapter() { - public String getID() { return "Weapon_Blaster_Fire"; } + public String getID() { return "Weapon_Blaster_Fire"; } public boolean think(edict_t ent) { @@ -281,7 +281,7 @@ public class PlayerWeapon { }; public static EntThinkAdapter Weapon_Blaster = new EntThinkAdapter() { - public String getID() { return "Weapon_Blaster"; } + public String getID() { return "Weapon_Blaster"; } public boolean think(edict_t ent) { @@ -295,7 +295,7 @@ public class PlayerWeapon { }; public static EntThinkAdapter Weapon_HyperBlaster_Fire = new EntThinkAdapter() { - public String getID() { return "Weapon_HyperBlaster_Fire"; } + public String getID() { return "Weapon_HyperBlaster_Fire"; } public boolean think(edict_t ent) { float rotation; @@ -366,7 +366,7 @@ public class PlayerWeapon { }; public static EntThinkAdapter Weapon_HyperBlaster = new EntThinkAdapter() { - public String getID() { return "Weapon_HyperBlaster"; } + public String getID() { return "Weapon_HyperBlaster"; } public boolean think(edict_t ent) { int pause_frames[] = { 0 }; @@ -379,7 +379,7 @@ public class PlayerWeapon { }; public static EntThinkAdapter Weapon_Machinegun = new EntThinkAdapter() { - public String getID() { return "Weapon_Machinegun"; } + public String getID() { return "Weapon_Machinegun"; } public boolean think(edict_t ent) { int pause_frames[] = { 23, 45, 0 }; @@ -392,7 +392,7 @@ public class PlayerWeapon { }; public static EntThinkAdapter Weapon_Chaingun = new EntThinkAdapter() { - public String getID() { return "Weapon_Chaingun"; } + public String getID() { return "Weapon_Chaingun"; } public boolean think(edict_t ent) { int pause_frames[] = { 38, 43, 51, 61, 0 }; @@ -414,7 +414,7 @@ public class PlayerWeapon { */ public static EntThinkAdapter weapon_shotgun_fire = new EntThinkAdapter() { - public String getID() { return "weapon_shotgun_fire"; } + public String getID() { return "weapon_shotgun_fire"; } public boolean think(edict_t ent) { @@ -469,7 +469,7 @@ public class PlayerWeapon { }; public static EntThinkAdapter Weapon_Shotgun = new EntThinkAdapter() { - public String getID() { return "Weapon_Shotgun"; } + public String getID() { return "Weapon_Shotgun"; } public boolean think(edict_t ent) { int pause_frames[] = { 22, 28, 34, 0 }; int fire_frames[] = { 8, 9, 0 }; @@ -481,7 +481,7 @@ public class PlayerWeapon { }; public static EntThinkAdapter weapon_supershotgun_fire = new EntThinkAdapter() { - public String getID() { return "weapon_supershotgun_fire"; } + public String getID() { return "weapon_supershotgun_fire"; } public boolean think(edict_t ent) { @@ -539,7 +539,7 @@ public class PlayerWeapon { }; public static EntThinkAdapter Weapon_SuperShotgun = new EntThinkAdapter() { - public String getID() { return "Weapon_SuperShotgun"; } + public String getID() { return "Weapon_SuperShotgun"; } public boolean think(edict_t ent) { int pause_frames[] = { 29, 42, 57, 0 }; @@ -559,7 +559,7 @@ public class PlayerWeapon { * ====================================================================== */ public static EntThinkAdapter weapon_railgun_fire = new EntThinkAdapter() { - public String getID() { return "weapon_railgun_fire"; } + public String getID() { return "weapon_railgun_fire"; } public boolean think(edict_t ent) { @@ -611,7 +611,7 @@ public class PlayerWeapon { }; public static EntThinkAdapter Weapon_Railgun = new EntThinkAdapter() { - public String getID() { return "Weapon_Railgun"; } + public String getID() { return "Weapon_Railgun"; } public boolean think(edict_t ent) { @@ -632,7 +632,7 @@ public class PlayerWeapon { */ public static EntThinkAdapter weapon_bfg_fire = new EntThinkAdapter() { - public String getID() { return "weapon_bfg_fire"; } + public String getID() { return "weapon_bfg_fire"; } public boolean think(edict_t ent) { @@ -696,7 +696,7 @@ public class PlayerWeapon { }; public static EntThinkAdapter Weapon_BFG = new EntThinkAdapter() { - public String getID() { return "Weapon_BFG"; } + public String getID() { return "Weapon_BFG"; } public boolean think(edict_t ent) { Weapon_Generic(ent, 8, 32, 55, 58, pause_frames, fire_frames, @@ -718,7 +718,7 @@ public class PlayerWeapon { * ================ */ public static ItemUseAdapter Use_Weapon = new ItemUseAdapter() { - public String getID() { return "Use_Weapon"; } + public String getID() { return "Use_Weapon"; } public void use(edict_t ent, gitem_t item) { int ammo_index; @@ -761,7 +761,7 @@ public class PlayerWeapon { */ public static ItemDropAdapter Drop_Weapon = new ItemDropAdapter() { - public String getID() { return "Drop_Weapon"; } + public String getID() { return "Drop_Weapon"; } public void drop(edict_t ent, gitem_t item) { int index; @@ -791,7 +791,7 @@ public class PlayerWeapon { */ public static EntThinkAdapter Machinegun_Fire = new EntThinkAdapter() { - public String getID() { return "Machinegun_Fire"; } + public String getID() { return "Machinegun_Fire"; } public boolean think(edict_t ent) { @@ -883,7 +883,7 @@ public class PlayerWeapon { }; public static EntThinkAdapter Chaingun_Fire = new EntThinkAdapter() { - public String getID() { return "Chaingun_Fire"; } + public String getID() { return "Chaingun_Fire"; } public boolean think(edict_t ent) { @@ -1010,7 +1010,7 @@ public class PlayerWeapon { public static int fire_frames[] = { 9, 17, 0 }; public static EntInteractAdapter Pickup_Weapon = new EntInteractAdapter() { - public String getID() { return "Pickup_Weapon"; } + public String getID() { return "Pickup_Weapon"; } public boolean interact(edict_t ent, edict_t other) { int index; gitem_t ammo; diff --git a/src/main/java/lwjake2/game/SuperAdapter.java b/src/main/java/lwjake2/game/SuperAdapter.java index 7e781ac..2788712 100644 --- a/src/main/java/lwjake2/game/SuperAdapter.java +++ b/src/main/java/lwjake2/game/SuperAdapter.java @@ -24,31 +24,31 @@ import java.util.Hashtable; public abstract class SuperAdapter { - /** Constructor, does the adapter registration. */ - public SuperAdapter() { - register(this, getID()); - } + /** Constructor, does the adapter registration. */ + public SuperAdapter() { + register(this, getID()); + } - /** Adapter registration. */ - private static void register(SuperAdapter sa, String id) { - adapters.put(id, sa); - } + /** Adapter registration. */ + private static void register(SuperAdapter sa, String id) { + adapters.put(id, sa); + } - /** Adapter repository. */ - private static Hashtable adapters= new Hashtable(); + /** Adapter repository. */ + private static Hashtable adapters= new Hashtable(); - /** Returns the adapter from the repository given by its ID. */ - public static SuperAdapter getFromID(String key) { - SuperAdapter sa= (SuperAdapter) adapters.get(key); + /** Returns the adapter from the repository given by its ID. */ + public static SuperAdapter getFromID(String key) { + SuperAdapter sa= (SuperAdapter) adapters.get(key); - // try to create the adapter - if (sa == null) { - Com.DPrintf("SuperAdapter.getFromID():adapter not found->" + key + "\n"); - } + // try to create the adapter + if (sa == null) { + Com.DPrintf("SuperAdapter.getFromID():adapter not found->" + key + "\n"); + } - return sa; - } + return sa; + } - /** Returns the Adapter-ID. */ - public abstract String getID(); + /** Returns the Adapter-ID. */ + public abstract String getID(); } diff --git a/src/main/java/lwjake2/game/client_persistant_t.java b/src/main/java/lwjake2/game/client_persistant_t.java index a7a7f17..d60b31c 100644 --- a/src/main/java/lwjake2/game/client_persistant_t.java +++ b/src/main/java/lwjake2/game/client_persistant_t.java @@ -25,132 +25,132 @@ import java.io.IOException; public class client_persistant_t { - public void set(client_persistant_t from) { - - userinfo= from.userinfo; - netname= from.netname; - hand= from.hand; - connected= from.connected; - health= from.health; - max_health= from.max_health; - savedFlags= from.savedFlags; - selected_item= from.selected_item; - System.arraycopy(from.inventory, 0, inventory, 0, inventory.length); - max_bullets= from.max_bullets; - max_shells= from.max_shells; - max_rockets= from.max_rockets; - max_grenades= from.max_grenades; - max_cells= from.max_cells; - max_slugs= from.max_slugs; - weapon= from.weapon; - lastweapon= from.lastweapon; - power_cubes= from.power_cubes; - score= from.score; - game_helpchanged= from.game_helpchanged; - helpchanged= from.helpchanged; - spectator= from.spectator; - } + public void set(client_persistant_t from) { + + userinfo= from.userinfo; + netname= from.netname; + hand= from.hand; + connected= from.connected; + health= from.health; + max_health= from.max_health; + savedFlags= from.savedFlags; + selected_item= from.selected_item; + System.arraycopy(from.inventory, 0, inventory, 0, inventory.length); + max_bullets= from.max_bullets; + max_shells= from.max_shells; + max_rockets= from.max_rockets; + max_grenades= from.max_grenades; + max_cells= from.max_cells; + max_slugs= from.max_slugs; + weapon= from.weapon; + lastweapon= from.lastweapon; + power_cubes= from.power_cubes; + score= from.score; + game_helpchanged= from.game_helpchanged; + helpchanged= from.helpchanged; + spectator= from.spectator; + } - // client data that stays across multiple level loads - String userinfo= ""; - String netname= ""; - int hand; + // client data that stays across multiple level loads + String userinfo= ""; + String netname= ""; + int hand; - boolean connected; // a loadgame will leave valid entities that - // just don't have a connection yet + boolean connected; // a loadgame will leave valid entities that + // just don't have a connection yet - // values saved and restored from edicts when changing levels - int health; - int max_health; - int savedFlags; + // values saved and restored from edicts when changing levels + int health; + int max_health; + int savedFlags; - int selected_item; - int inventory[]= new int[Defines.MAX_ITEMS]; + int selected_item; + int inventory[]= new int[Defines.MAX_ITEMS]; - // ammo capacities - public int max_bullets; - public int max_shells; - public int max_rockets; - public int max_grenades; - public int max_cells; - public int max_slugs; - //pointer - gitem_t weapon; - //pointer - gitem_t lastweapon; - int power_cubes; // used for tracking the cubes in coop games - int score; // for calculating total unit score in coop games - int game_helpchanged; - int helpchanged; - boolean spectator; // client is a spectator + // ammo capacities + public int max_bullets; + public int max_shells; + public int max_rockets; + public int max_grenades; + public int max_cells; + public int max_slugs; + //pointer + gitem_t weapon; + //pointer + gitem_t lastweapon; + int power_cubes; // used for tracking the cubes in coop games + int score; // for calculating total unit score in coop games + int game_helpchanged; + int helpchanged; + boolean spectator; // client is a spectator - /** Reads a client_persistant structure from a file. */ - public void read(QuakeFile f) throws IOException { + /** Reads a client_persistant structure from a file. */ + public void read(QuakeFile f) throws IOException { - userinfo= f.readString(); - netname= f.readString(); + userinfo= f.readString(); + netname= f.readString(); - hand= f.readInt(); + hand= f.readInt(); - connected= f.readInt() != 0; - health= f.readInt(); + connected= f.readInt() != 0; + health= f.readInt(); - max_health= f.readInt(); - savedFlags= f.readInt(); - selected_item= f.readInt(); + max_health= f.readInt(); + savedFlags= f.readInt(); + selected_item= f.readInt(); - for (int n= 0; n < Defines.MAX_ITEMS; n++) - inventory[n]= f.readInt(); + for (int n= 0; n < Defines.MAX_ITEMS; n++) + inventory[n]= f.readInt(); - max_bullets= f.readInt(); - max_shells= f.readInt(); - max_rockets= f.readInt(); - max_grenades= f.readInt(); - max_cells= f.readInt(); - max_slugs= f.readInt(); + max_bullets= f.readInt(); + max_shells= f.readInt(); + max_rockets= f.readInt(); + max_grenades= f.readInt(); + max_cells= f.readInt(); + max_slugs= f.readInt(); - weapon= f.readItem(); - lastweapon= f.readItem(); - power_cubes= f.readInt(); - score= f.readInt(); + weapon= f.readItem(); + lastweapon= f.readItem(); + power_cubes= f.readInt(); + score= f.readInt(); - game_helpchanged= f.readInt(); - helpchanged= f.readInt(); - spectator= f.readInt() != 0; - } + game_helpchanged= f.readInt(); + helpchanged= f.readInt(); + spectator= f.readInt() != 0; + } - /** Writes a client_persistant structure to a file. */ - public void write(QuakeFile f) throws IOException { - // client persistant_t - f.writeString(userinfo); - f.writeString(netname); + /** Writes a client_persistant structure to a file. */ + public void write(QuakeFile f) throws IOException { + // client persistant_t + f.writeString(userinfo); + f.writeString(netname); - f.writeInt(hand); + f.writeInt(hand); - f.writeInt(connected ? 1 : 0); - f.writeInt(health); + f.writeInt(connected ? 1 : 0); + f.writeInt(health); - f.writeInt(max_health); - f.writeInt(savedFlags); - f.writeInt(selected_item); + f.writeInt(max_health); + f.writeInt(savedFlags); + f.writeInt(selected_item); - for (int n= 0; n < Defines.MAX_ITEMS; n++) - f.writeInt(inventory[n]); + for (int n= 0; n < Defines.MAX_ITEMS; n++) + f.writeInt(inventory[n]); - f.writeInt(max_bullets); - f.writeInt(max_shells); - f.writeInt(max_rockets); - f.writeInt(max_grenades); - f.writeInt(max_cells); - f.writeInt(max_slugs); + f.writeInt(max_bullets); + f.writeInt(max_shells); + f.writeInt(max_rockets); + f.writeInt(max_grenades); + f.writeInt(max_cells); + f.writeInt(max_slugs); - f.writeItem(weapon); - f.writeItem(lastweapon); - f.writeInt(power_cubes); - f.writeInt(score); + f.writeItem(weapon); + f.writeItem(lastweapon); + f.writeInt(power_cubes); + f.writeInt(score); - f.writeInt(game_helpchanged); - f.writeInt(helpchanged); - f.writeInt(spectator ? 1 : 0); - } + f.writeInt(game_helpchanged); + f.writeInt(helpchanged); + f.writeInt(spectator ? 1 : 0); + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/game/client_respawn_t.java b/src/main/java/lwjake2/game/client_respawn_t.java index 49b86f9..7d62955 100644 --- a/src/main/java/lwjake2/game/client_respawn_t.java +++ b/src/main/java/lwjake2/game/client_respawn_t.java @@ -26,63 +26,63 @@ import java.io.IOException; /** Client data that stays across deathmatch respawns. */ public class client_respawn_t { - /** What to set client->pers to on a respawn */ - protected client_persistant_t coop_respawn = new client_persistant_t(); - - /** Level.framenum the client entered the game. */ - protected int enterframe; - - /** frags, etc. */ - protected int score; - - /** angles sent over in the last command. */ - protected float cmd_angles[] = { 0, 0, 0 }; - - /** client is a spectator. */ - protected boolean spectator; + /** What to set client->pers to on a respawn */ + protected client_persistant_t coop_respawn = new client_persistant_t(); + + /** Level.framenum the client entered the game. */ + protected int enterframe; + + /** frags, etc. */ + protected int score; + + /** angles sent over in the last command. */ + protected float cmd_angles[] = { 0, 0, 0 }; + + /** client is a spectator. */ + protected boolean spectator; - - /** Copies the client respawn data. */ - public void set(client_respawn_t from) - { - coop_respawn.set(from.coop_respawn); - enterframe = from.enterframe; - score = from.score; - Math3D.VectorCopy(from.cmd_angles, cmd_angles); - spectator = from.spectator; - } + + /** Copies the client respawn data. */ + public void set(client_respawn_t from) + { + coop_respawn.set(from.coop_respawn); + enterframe = from.enterframe; + score = from.score; + Math3D.VectorCopy(from.cmd_angles, cmd_angles); + spectator = from.spectator; + } - /** Clears the client reaspawn informations. */ - public void clear() - { - coop_respawn = new client_persistant_t(); - enterframe = 0; - score = 0; - Math3D.VectorClear(cmd_angles); - spectator = false; - } + /** Clears the client reaspawn informations. */ + public void clear() + { + coop_respawn = new client_persistant_t(); + enterframe = 0; + score = 0; + Math3D.VectorClear(cmd_angles); + spectator = false; + } - /** Reads a client_respawn from a file. */ - public void read(QuakeFile f) throws IOException - { - coop_respawn.read(f); - enterframe = f.readInt(); - score = f.readInt(); - cmd_angles[0] = f.readFloat(); - cmd_angles[1] = f.readFloat(); - cmd_angles[2] = f.readFloat(); - spectator = f.readInt() != 0; - } - - /** Writes a client_respawn to a file. */ - public void write(QuakeFile f) throws IOException - { - coop_respawn.write(f); - f.writeInt(enterframe); - f.writeInt(score); - f.writeFloat(cmd_angles[0]); - f.writeFloat(cmd_angles[1]); - f.writeFloat(cmd_angles[2]); - f.writeInt(spectator?1:0); - } + /** Reads a client_respawn from a file. */ + public void read(QuakeFile f) throws IOException + { + coop_respawn.read(f); + enterframe = f.readInt(); + score = f.readInt(); + cmd_angles[0] = f.readFloat(); + cmd_angles[1] = f.readFloat(); + cmd_angles[2] = f.readFloat(); + spectator = f.readInt() != 0; + } + + /** Writes a client_respawn to a file. */ + public void write(QuakeFile f) throws IOException + { + coop_respawn.write(f); + f.writeInt(enterframe); + f.writeInt(score); + f.writeFloat(cmd_angles[0]); + f.writeFloat(cmd_angles[1]); + f.writeFloat(cmd_angles[2]); + f.writeInt(spectator?1:0); + } } diff --git a/src/main/java/lwjake2/game/cmdalias_t.java b/src/main/java/lwjake2/game/cmdalias_t.java index 7898cd2..71b63e3 100644 --- a/src/main/java/lwjake2/game/cmdalias_t.java +++ b/src/main/java/lwjake2/game/cmdalias_t.java @@ -20,7 +20,7 @@ package lwjake2.game; public final class cmdalias_t { - public cmdalias_t next; - public String name = ""; - public String value; + public cmdalias_t next; + public String name = ""; + public String value; } diff --git a/src/main/java/lwjake2/game/cmodel_t.java b/src/main/java/lwjake2/game/cmodel_t.java index 47e986e..873bb78 100644 --- a/src/main/java/lwjake2/game/cmodel_t.java +++ b/src/main/java/lwjake2/game/cmodel_t.java @@ -20,8 +20,8 @@ package lwjake2.game; public class cmodel_t { - public float[] mins = { 0, 0, 0 }; - public float[] maxs = { 0, 0, 0 }; - public float[] origin = { 0, 0, 0 }; // for sounds or lights - public int headnode; + public float[] mins = { 0, 0, 0 }; + public float[] maxs = { 0, 0, 0 }; + public float[] origin = { 0, 0, 0 }; // for sounds or lights + public int headnode; } diff --git a/src/main/java/lwjake2/game/cplane_t.java b/src/main/java/lwjake2/game/cplane_t.java index ed04370..ec2d5c0 100644 --- a/src/main/java/lwjake2/game/cplane_t.java +++ b/src/main/java/lwjake2/game/cplane_t.java @@ -22,29 +22,29 @@ import lwjake2.util.Math3D; public class cplane_t { - public float normal[] = new float[3]; - public float dist; - /** This is for fast side tests, 0=xplane, 1=yplane, 2=zplane and 3=arbitrary. */ - public byte type; - /** This represents signx + (signy<<1) + (signz << 1). */ - public byte signbits; // signx + (signy<<1) + (signz<<1) - public byte pad[] = { 0, 0 }; - - public void set(cplane_t c) { - Math3D.set(normal, c.normal); - dist = c.dist; - type = c.type; - signbits = c.signbits; - pad[0] = c.pad[0]; - pad[1] = c.pad[1]; - } + public float normal[] = new float[3]; + public float dist; + /** This is for fast side tests, 0=xplane, 1=yplane, 2=zplane and 3=arbitrary. */ + public byte type; + /** This represents signx + (signy<<1) + (signz << 1). */ + public byte signbits; // signx + (signy<<1) + (signz<<1) + public byte pad[] = { 0, 0 }; + + public void set(cplane_t c) { + Math3D.set(normal, c.normal); + dist = c.dist; + type = c.type; + signbits = c.signbits; + pad[0] = c.pad[0]; + pad[1] = c.pad[1]; + } - public void clear() { - Math3D.VectorClear(normal); - dist = 0; - type = 0; - signbits = 0; - pad[0] = 0; - pad[1] = 0; - } + public void clear() { + Math3D.VectorClear(normal); + dist = 0; + type = 0; + signbits = 0; + pad[0] = 0; + pad[1] = 0; + } } diff --git a/src/main/java/lwjake2/game/csurface_t.java b/src/main/java/lwjake2/game/csurface_t.java index c4027f8..62f31ca 100644 --- a/src/main/java/lwjake2/game/csurface_t.java +++ b/src/main/java/lwjake2/game/csurface_t.java @@ -20,7 +20,7 @@ package lwjake2.game; public class csurface_t { - public String name = ""; - public int flags; - public int value; + public String name = ""; + public int flags; + public int value; } diff --git a/src/main/java/lwjake2/game/cvar_t.java b/src/main/java/lwjake2/game/cvar_t.java index 1772313..7bdde71 100644 --- a/src/main/java/lwjake2/game/cvar_t.java +++ b/src/main/java/lwjake2/game/cvar_t.java @@ -23,11 +23,11 @@ package lwjake2.game; */ public final class cvar_t { - public String name; - public String string; - public String latched_string; - public int flags = 0; - public boolean modified = false; - public float value = 0.0f; - public cvar_t next = null; + public String name; + public String string; + public String latched_string; + public int flags = 0; + public boolean modified = false; + public float value = 0.0f; + public cvar_t next = null; } diff --git a/src/main/java/lwjake2/game/entity_state_t.java b/src/main/java/lwjake2/game/entity_state_t.java index 99c0358..53746cd 100644 --- a/src/main/java/lwjake2/game/entity_state_t.java +++ b/src/main/java/lwjake2/game/entity_state_t.java @@ -25,140 +25,140 @@ import lwjake2.util.QuakeFile; public class entity_state_t implements Cloneable { - /** entity_state_t is the information conveyed from the server - in an update message about entities that the client will - need to render in some way. */ - public entity_state_t(edict_t ent) - { - this.surrounding_ent = ent; - if (ent != null) - number = ent.index; - } + /** entity_state_t is the information conveyed from the server + in an update message about entities that the client will + need to render in some way. */ + public entity_state_t(edict_t ent) + { + this.surrounding_ent = ent; + if (ent != null) + number = ent.index; + } - /** edict index. TODO: this is critical. The index has to be proper managed. */ - public int number = 0; - // TODO: why was this introduced? - public edict_t surrounding_ent = null; - public float[] origin = { 0, 0, 0 }; - public float[] angles = { 0, 0, 0 }; - - /** for lerping. */ - public float[] old_origin = { 0, 0, 0 }; - public int modelindex; - /** weapons, CTF flags, etc. */ - public int modelindex2, modelindex3, modelindex4; - public int frame; - public int skinnum; - /** PGM - we're filling it, so it needs to be unsigned. */ - public int effects; - public int renderfx; - public int solid; - // for client side prediction, 8*(bits 0-4) is x/y radius - // 8*(bits 5-9) is z down distance, 8(bits10-15) is z up - // gi.linkentity sets this properly - public int sound; // for looping sounds, to guarantee shutoff - public int event; // impulse events -- muzzle flashes, footsteps, etc - // events only go out for a single frame, they - // are automatically cleared each frame + /** edict index. TODO: this is critical. The index has to be proper managed. */ + public int number = 0; + // TODO: why was this introduced? + public edict_t surrounding_ent = null; + public float[] origin = { 0, 0, 0 }; + public float[] angles = { 0, 0, 0 }; + + /** for lerping. */ + public float[] old_origin = { 0, 0, 0 }; + public int modelindex; + /** weapons, CTF flags, etc. */ + public int modelindex2, modelindex3, modelindex4; + public int frame; + public int skinnum; + /** PGM - we're filling it, so it needs to be unsigned. */ + public int effects; + public int renderfx; + public int solid; + // for client side prediction, 8*(bits 0-4) is x/y radius + // 8*(bits 5-9) is z down distance, 8(bits10-15) is z up + // gi.linkentity sets this properly + public int sound; // for looping sounds, to guarantee shutoff + public int event; // impulse events -- muzzle flashes, footsteps, etc + // events only go out for a single frame, they + // are automatically cleared each frame - /** Writes the entity state to the file. */ - public void write(QuakeFile f) throws IOException - { - f.writeEdictRef(surrounding_ent); - f.writeVector(origin); - f.writeVector(angles); - f.writeVector(old_origin); - - f.writeInt(modelindex); - - f.writeInt(modelindex2); - f.writeInt(modelindex3); - f.writeInt(modelindex4); - - f.writeInt(frame); - f.writeInt(skinnum); - - f.writeInt(effects); - f.writeInt(renderfx); - f.writeInt(solid); - - f.writeInt(sound); - f.writeInt(event); - - } + /** Writes the entity state to the file. */ + public void write(QuakeFile f) throws IOException + { + f.writeEdictRef(surrounding_ent); + f.writeVector(origin); + f.writeVector(angles); + f.writeVector(old_origin); + + f.writeInt(modelindex); + + f.writeInt(modelindex2); + f.writeInt(modelindex3); + f.writeInt(modelindex4); + + f.writeInt(frame); + f.writeInt(skinnum); + + f.writeInt(effects); + f.writeInt(renderfx); + f.writeInt(solid); + + f.writeInt(sound); + f.writeInt(event); + + } - /** Reads the entity state from the file. */ - public void read(QuakeFile f) throws IOException - { - surrounding_ent = f.readEdictRef(); - origin = f.readVector(); - angles = f.readVector(); - old_origin = f.readVector(); - - modelindex = f.readInt(); - - modelindex2= f.readInt(); - modelindex3= f.readInt(); - modelindex4= f.readInt(); - - frame = f.readInt(); - skinnum = f.readInt(); - - effects = f.readInt(); - renderfx = f.readInt(); - solid = f.readInt(); - - sound = f.readInt(); - event = f.readInt(); - + /** Reads the entity state from the file. */ + public void read(QuakeFile f) throws IOException + { + surrounding_ent = f.readEdictRef(); + origin = f.readVector(); + angles = f.readVector(); + old_origin = f.readVector(); + + modelindex = f.readInt(); + + modelindex2= f.readInt(); + modelindex3= f.readInt(); + modelindex4= f.readInt(); + + frame = f.readInt(); + skinnum = f.readInt(); + + effects = f.readInt(); + renderfx = f.readInt(); + solid = f.readInt(); + + sound = f.readInt(); + event = f.readInt(); + - } + } - public entity_state_t getClone() - { - entity_state_t out = new entity_state_t(this.surrounding_ent); - out.set(this); - return out; - } + public entity_state_t getClone() + { + entity_state_t out = new entity_state_t(this.surrounding_ent); + out.set(this); + return out; + } - public void set(entity_state_t from) - { - number = from.number; - Math3D.VectorCopy(from.origin, origin); - Math3D.VectorCopy(from.angles, angles); - Math3D.VectorCopy(from.old_origin, old_origin); + public void set(entity_state_t from) + { + number = from.number; + Math3D.VectorCopy(from.origin, origin); + Math3D.VectorCopy(from.angles, angles); + Math3D.VectorCopy(from.old_origin, old_origin); - modelindex = from.modelindex; - modelindex2 = from.modelindex2; - modelindex3 = from.modelindex3; - modelindex4 = from.modelindex4; + modelindex = from.modelindex; + modelindex2 = from.modelindex2; + modelindex3 = from.modelindex3; + modelindex4 = from.modelindex4; - frame = from.frame; - skinnum = from.skinnum; - effects = from.effects; - renderfx = from.renderfx; - solid = from.solid; - sound = from.sound; - event = from.event; - } + frame = from.frame; + skinnum = from.skinnum; + effects = from.effects; + renderfx = from.renderfx; + solid = from.solid; + sound = from.sound; + event = from.event; + } - public void clear() - { - //TODO: this is critical. The index has to be proper managed. - number = 0; - surrounding_ent = null; - Math3D.VectorClear(origin); - Math3D.VectorClear(angles); - Math3D.VectorClear(old_origin); - modelindex = 0; - modelindex2 = modelindex3 = modelindex4 = 0; - frame = 0; - skinnum = 0; - effects = 0; - renderfx = 0; - solid = 0; - sound = 0; - event = 0; - } + public void clear() + { + //TODO: this is critical. The index has to be proper managed. + number = 0; + surrounding_ent = null; + Math3D.VectorClear(origin); + Math3D.VectorClear(angles); + Math3D.VectorClear(old_origin); + modelindex = 0; + modelindex2 = modelindex3 = modelindex4 = 0; + frame = 0; + skinnum = 0; + effects = 0; + renderfx = 0; + solid = 0; + sound = 0; + event = 0; + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/game/game_import_t.java b/src/main/java/lwjake2/game/game_import_t.java index d226f5a..819fc25 100644 --- a/src/main/java/lwjake2/game/game_import_t.java +++ b/src/main/java/lwjake2/game/game_import_t.java @@ -30,7 +30,7 @@ import lwjake2.server.SV_SEND; import lwjake2.server.SV_WORLD; // -// collection of functions provided by the main engine +// collection of functions provided by the main engine // public class game_import_t { // special messages diff --git a/src/main/java/lwjake2/game/game_locals_t.java b/src/main/java/lwjake2/game/game_locals_t.java index 33c9a14..f6a94b7 100644 --- a/src/main/java/lwjake2/game/game_locals_t.java +++ b/src/main/java/lwjake2/game/game_locals_t.java @@ -27,9 +27,9 @@ import java.util.Date; public class game_locals_t { // - // this structure is left intact through an entire game - // it should be initialized at dll load time, and read/written to - // the server.ssv file for savegames + // this structure is left intact through an entire game + // it should be initialized at dll load time, and read/written to + // the server.ssv file for savegames // public String helpmessage1 = ""; diff --git a/src/main/java/lwjake2/game/gclient_t.java b/src/main/java/lwjake2/game/gclient_t.java index 004e48e..701e9ed 100644 --- a/src/main/java/lwjake2/game/gclient_t.java +++ b/src/main/java/lwjake2/game/gclient_t.java @@ -25,396 +25,396 @@ import java.io.IOException; @Slf4j public class gclient_t { - public gclient_t(int index) - { - this.index = index; - } - // this structure is cleared on each PutClientInServer(), - // except for 'client->pers' - - // known to server - public player_state_t ps = new player_state_t(); // communicated by server to clients - public int ping; - - // private to game - public client_persistant_t pers = new client_persistant_t(); - public client_respawn_t resp = new client_respawn_t(); - public pmove_state_t old_pmove = new pmove_state_t(); // for detecting out-of-pmove changes - - public boolean showscores; // set layout stat - public boolean showinventory; // set layout stat - public boolean showhelp; - public boolean showhelpicon; - - public int ammo_index; - - public int buttons; - public int oldbuttons; - public int latched_buttons; - - public boolean weapon_thunk; - - public gitem_t newweapon; - - // sum up damage over an entire frame, so - // shotgun blasts give a single big kick - public int damage_armor; // damage absorbed by armor - public int damage_parmor; // damage absorbed by power armor - public int damage_blood; // damage taken out of health - public int damage_knockback; // impact damage - public float[] damage_from = { 0, 0, 0 }; // origin for vector calculation - - public float killer_yaw; // when dead, look at killer - - public int weaponstate; - public float[] kick_angles = { 0, 0, 0 }; // weapon kicks - public float[] kick_origin = { 0, 0, 0 }; - public float v_dmg_roll, v_dmg_pitch, v_dmg_time; // damage kicks - public float fall_time, fall_value; // for view drop on fall - public float damage_alpha; - public float bonus_alpha; - public float[] damage_blend = { 0, 0, 0 }; - public float[] v_angle = { 0, 0, 0 }; // aiming direction - public float bobtime; // so off-ground doesn't change it - public float[] oldviewangles = { 0, 0, 0 }; - public float[] oldvelocity = { 0, 0, 0 }; - - public float next_drown_time; - public int old_waterlevel; - public int breather_sound; - - public int machinegun_shots; // for weapon raising - - // animation vars - public int anim_end; - public int anim_priority; - public boolean anim_duck; - public boolean anim_run; - - // powerup timers - public float quad_framenum; - public float invincible_framenum; - public float breather_framenum; - public float enviro_framenum; - - public boolean grenade_blew_up; - public float grenade_time; - public int silencer_shots; - public int weapon_sound; - - public float pickup_msg_time; - - public float flood_locktill; // locked from talking - public float flood_when[] = new float[10]; // when messages were said - public int flood_whenhead; // head pointer for when said - - public float respawn_time; // can respawn when time > this - - public edict_t chase_target; // player we are chasing - public boolean update_chase; // need to update chase info? - - public int index; - - /** Clears the game client structure. */ - public void clear() - { - ping =0; - - pers = new client_persistant_t(); - resp = new client_respawn_t(); - old_pmove = new pmove_state_t(); - - showscores = false; // set layout stat - showinventory = false; // set layout stat - showhelp = false; - showhelpicon = false; - - ammo_index = 0; - - buttons = oldbuttons = latched_buttons = 0; - weapon_thunk = false; - newweapon = null; - damage_armor = 0; - damage_parmor = 0; - damage_blood = 0; - damage_knockback = 0; - - killer_yaw = 0; - damage_from = new float[3]; - weaponstate = 0; - kick_angles = new float[3]; - kick_origin = new float[3]; - v_dmg_roll = v_dmg_pitch = v_dmg_time = 0; - fall_time = fall_value = 0; - damage_alpha = 0; - bonus_alpha = 0; - damage_blend = new float[3]; - v_angle = new float[3]; - bobtime = 0; - - oldviewangles = new float[3]; - - oldvelocity = new float[3]; - - next_drown_time = 0; - - old_waterlevel = 0; - - breather_sound = 0; - machinegun_shots = 0; - - anim_end = 0; - anim_priority = 0; - anim_duck = false; - anim_run = false; - - // powerup timers - quad_framenum = 0; - invincible_framenum = 0; - breather_framenum = 0; - enviro_framenum = 0; - - grenade_blew_up = false; - grenade_time = 0; - silencer_shots = 0; - weapon_sound = 0; - - pickup_msg_time = 0; - - flood_locktill = 0; // locked from talking - flood_when = new float[10]; // when messages were said - flood_whenhead = 0; // head pointer for when said - - respawn_time = 0; // can respawn when time > this - - chase_target = null; // player we are chasing - update_chase = false; // need to update chase info? - } - - /** Reads a game client from the file. */ - public void read(QuakeFile f) throws IOException - { - - ps.load(f); - - ping = f.readInt(); - - pers.read(f); - resp.read(f); - - old_pmove.load(f); - - showscores = f.readInt() != 0; - showinventory = f.readInt() != 0; - showhelp = f.readInt() != 0; - showhelpicon = f.readInt() != 0; - ammo_index = f.readInt(); - - buttons = f.readInt(); - oldbuttons = f.readInt(); - latched_buttons = f.readInt(); - - weapon_thunk=f.readInt()!=0; - - newweapon=f.readItem(); - - - damage_armor = f.readInt(); - damage_parmor = f.readInt(); - damage_blood = f.readInt(); - damage_knockback = f.readInt(); - - damage_from[0] = f.readFloat(); - damage_from[1] = f.readFloat(); - damage_from[2] = f.readFloat(); - - killer_yaw = f.readFloat(); - - weaponstate = f.readInt(); - - kick_angles[0] = f.readFloat(); - kick_angles[1] = f.readFloat(); - kick_angles[2] = f.readFloat(); - - kick_origin[0] = f.readFloat(); - kick_origin[1] = f.readFloat(); - kick_origin[2] = f.readFloat(); - - v_dmg_roll = f.readFloat(); - v_dmg_pitch = f.readFloat(); - v_dmg_time = f.readFloat(); - fall_time = f.readFloat(); - fall_value = f.readFloat(); - damage_alpha = f.readFloat(); - bonus_alpha = f.readFloat(); - - damage_blend[0] = f.readFloat(); - damage_blend[1] = f.readFloat(); - damage_blend[2] = f.readFloat(); - - v_angle[0] = f.readFloat(); - v_angle[1] = f.readFloat(); - v_angle[2] = f.readFloat(); - - bobtime = f.readFloat(); - - oldviewangles[0] = f.readFloat(); - oldviewangles[1] = f.readFloat(); - oldviewangles[2] = f.readFloat(); - - oldvelocity[0] = f.readFloat(); - oldvelocity[1] = f.readFloat(); - oldvelocity[2] = f.readFloat(); - - next_drown_time = f.readFloat(); - - old_waterlevel = f.readInt(); - breather_sound = f.readInt(); - machinegun_shots = f.readInt(); - anim_end = f.readInt(); - anim_priority = f.readInt(); - anim_duck = f.readInt() != 0; - anim_run = f.readInt() != 0; - - quad_framenum = f.readFloat(); - invincible_framenum = f.readFloat(); - breather_framenum = f.readFloat(); - enviro_framenum = f.readFloat(); - - grenade_blew_up = f.readInt() != 0; - grenade_time = f.readFloat(); - silencer_shots = f.readInt(); - weapon_sound = f.readInt(); - pickup_msg_time = f.readFloat(); - flood_locktill = f.readFloat(); - flood_when[0] = f.readFloat(); - flood_when[1] = f.readFloat(); - flood_when[2] = f.readFloat(); - flood_when[3] = f.readFloat(); - flood_when[4] = f.readFloat(); - flood_when[5] = f.readFloat(); - flood_when[6] = f.readFloat(); - flood_when[7] = f.readFloat(); - flood_when[8] = f.readFloat(); - flood_when[9] = f.readFloat(); - flood_whenhead = f.readInt(); - respawn_time = f.readFloat(); - chase_target = f.readEdictRef(); - update_chase = f.readInt() != 0; - - if (f.readInt() != 8765) - log.error("game client load failed for num={}", index); - } - - /** Writes a game_client_t (a player) to a file. */ - public void write(QuakeFile f) throws IOException - { - ps.write(f); - - f.writeInt(ping); - - pers.write(f); - resp.write(f); - - old_pmove.write(f); - - f.writeInt(showscores?1:0); - f.writeInt(showinventory?1:0); - f.writeInt(showhelp?1:0); - f.writeInt(showhelpicon?1:0); - f.writeInt(ammo_index); - - f.writeInt(buttons); - f.writeInt(oldbuttons); - f.writeInt(latched_buttons); - - f.writeInt(weapon_thunk?1:0); - f.writeItem(newweapon); - - - f.writeInt(damage_armor); - f.writeInt(damage_parmor); - f.writeInt(damage_blood); - f.writeInt(damage_knockback); - - f.writeFloat(damage_from[0]); - f.writeFloat(damage_from[1]); - f.writeFloat(damage_from[2]); - - f.writeFloat(killer_yaw); - - f.writeInt(weaponstate); - - f.writeFloat(kick_angles[0]); - f.writeFloat(kick_angles[1]); - f.writeFloat(kick_angles[2]); - - f.writeFloat(kick_origin[0]); - f.writeFloat(kick_origin[1]); - f.writeFloat(kick_origin[2]); - - f.writeFloat(v_dmg_roll); - f.writeFloat(v_dmg_pitch); - f.writeFloat(v_dmg_time); - f.writeFloat(fall_time); - f.writeFloat(fall_value); - f.writeFloat(damage_alpha); - f.writeFloat(bonus_alpha); - - f.writeFloat(damage_blend[0]); - f.writeFloat(damage_blend[1]); - f.writeFloat(damage_blend[2]); - - f.writeFloat(v_angle[0]); - f.writeFloat(v_angle[1]); - f.writeFloat(v_angle[2]); - - f.writeFloat(bobtime); - - f.writeFloat(oldviewangles[0]); - f.writeFloat(oldviewangles[1]); - f.writeFloat(oldviewangles[2]); - - f.writeFloat(oldvelocity[0]); - f.writeFloat(oldvelocity[1]); - f.writeFloat(oldvelocity[2]); - - f.writeFloat(next_drown_time); - - f.writeInt(old_waterlevel); - f.writeInt(breather_sound); - f.writeInt(machinegun_shots); - f.writeInt(anim_end); - f.writeInt(anim_priority); - f.writeInt(anim_duck?1:0); - f.writeInt(anim_run?1:0); - - f.writeFloat(quad_framenum); - f.writeFloat(invincible_framenum); - f.writeFloat(breather_framenum); - f.writeFloat(enviro_framenum); - - f.writeInt(grenade_blew_up?1:0); - f.writeFloat(grenade_time); - f.writeInt(silencer_shots); - f.writeInt(weapon_sound); - f.writeFloat(pickup_msg_time); - f.writeFloat(flood_locktill); - f.writeFloat(flood_when[0]); - f.writeFloat(flood_when[1]); - f.writeFloat(flood_when[2]); - f.writeFloat(flood_when[3]); - f.writeFloat(flood_when[4]); - f.writeFloat(flood_when[5]); - f.writeFloat(flood_when[6]); - f.writeFloat(flood_when[7]); - f.writeFloat(flood_when[8]); - f.writeFloat(flood_when[9]); - f.writeInt(flood_whenhead); - f.writeFloat(respawn_time); - f.writeEdictRef(chase_target); - f.writeInt(update_chase?1:0); - - f.writeInt(8765); - } + public gclient_t(int index) + { + this.index = index; + } + // this structure is cleared on each PutClientInServer(), + // except for 'client->pers' + + // known to server + public player_state_t ps = new player_state_t(); // communicated by server to clients + public int ping; + + // private to game + public client_persistant_t pers = new client_persistant_t(); + public client_respawn_t resp = new client_respawn_t(); + public pmove_state_t old_pmove = new pmove_state_t(); // for detecting out-of-pmove changes + + public boolean showscores; // set layout stat + public boolean showinventory; // set layout stat + public boolean showhelp; + public boolean showhelpicon; + + public int ammo_index; + + public int buttons; + public int oldbuttons; + public int latched_buttons; + + public boolean weapon_thunk; + + public gitem_t newweapon; + + // sum up damage over an entire frame, so + // shotgun blasts give a single big kick + public int damage_armor; // damage absorbed by armor + public int damage_parmor; // damage absorbed by power armor + public int damage_blood; // damage taken out of health + public int damage_knockback; // impact damage + public float[] damage_from = { 0, 0, 0 }; // origin for vector calculation + + public float killer_yaw; // when dead, look at killer + + public int weaponstate; + public float[] kick_angles = { 0, 0, 0 }; // weapon kicks + public float[] kick_origin = { 0, 0, 0 }; + public float v_dmg_roll, v_dmg_pitch, v_dmg_time; // damage kicks + public float fall_time, fall_value; // for view drop on fall + public float damage_alpha; + public float bonus_alpha; + public float[] damage_blend = { 0, 0, 0 }; + public float[] v_angle = { 0, 0, 0 }; // aiming direction + public float bobtime; // so off-ground doesn't change it + public float[] oldviewangles = { 0, 0, 0 }; + public float[] oldvelocity = { 0, 0, 0 }; + + public float next_drown_time; + public int old_waterlevel; + public int breather_sound; + + public int machinegun_shots; // for weapon raising + + // animation vars + public int anim_end; + public int anim_priority; + public boolean anim_duck; + public boolean anim_run; + + // powerup timers + public float quad_framenum; + public float invincible_framenum; + public float breather_framenum; + public float enviro_framenum; + + public boolean grenade_blew_up; + public float grenade_time; + public int silencer_shots; + public int weapon_sound; + + public float pickup_msg_time; + + public float flood_locktill; // locked from talking + public float flood_when[] = new float[10]; // when messages were said + public int flood_whenhead; // head pointer for when said + + public float respawn_time; // can respawn when time > this + + public edict_t chase_target; // player we are chasing + public boolean update_chase; // need to update chase info? + + public int index; + + /** Clears the game client structure. */ + public void clear() + { + ping =0; + + pers = new client_persistant_t(); + resp = new client_respawn_t(); + old_pmove = new pmove_state_t(); + + showscores = false; // set layout stat + showinventory = false; // set layout stat + showhelp = false; + showhelpicon = false; + + ammo_index = 0; + + buttons = oldbuttons = latched_buttons = 0; + weapon_thunk = false; + newweapon = null; + damage_armor = 0; + damage_parmor = 0; + damage_blood = 0; + damage_knockback = 0; + + killer_yaw = 0; + damage_from = new float[3]; + weaponstate = 0; + kick_angles = new float[3]; + kick_origin = new float[3]; + v_dmg_roll = v_dmg_pitch = v_dmg_time = 0; + fall_time = fall_value = 0; + damage_alpha = 0; + bonus_alpha = 0; + damage_blend = new float[3]; + v_angle = new float[3]; + bobtime = 0; + + oldviewangles = new float[3]; + + oldvelocity = new float[3]; + + next_drown_time = 0; + + old_waterlevel = 0; + + breather_sound = 0; + machinegun_shots = 0; + + anim_end = 0; + anim_priority = 0; + anim_duck = false; + anim_run = false; + + // powerup timers + quad_framenum = 0; + invincible_framenum = 0; + breather_framenum = 0; + enviro_framenum = 0; + + grenade_blew_up = false; + grenade_time = 0; + silencer_shots = 0; + weapon_sound = 0; + + pickup_msg_time = 0; + + flood_locktill = 0; // locked from talking + flood_when = new float[10]; // when messages were said + flood_whenhead = 0; // head pointer for when said + + respawn_time = 0; // can respawn when time > this + + chase_target = null; // player we are chasing + update_chase = false; // need to update chase info? + } + + /** Reads a game client from the file. */ + public void read(QuakeFile f) throws IOException + { + + ps.load(f); + + ping = f.readInt(); + + pers.read(f); + resp.read(f); + + old_pmove.load(f); + + showscores = f.readInt() != 0; + showinventory = f.readInt() != 0; + showhelp = f.readInt() != 0; + showhelpicon = f.readInt() != 0; + ammo_index = f.readInt(); + + buttons = f.readInt(); + oldbuttons = f.readInt(); + latched_buttons = f.readInt(); + + weapon_thunk=f.readInt()!=0; + + newweapon=f.readItem(); + + + damage_armor = f.readInt(); + damage_parmor = f.readInt(); + damage_blood = f.readInt(); + damage_knockback = f.readInt(); + + damage_from[0] = f.readFloat(); + damage_from[1] = f.readFloat(); + damage_from[2] = f.readFloat(); + + killer_yaw = f.readFloat(); + + weaponstate = f.readInt(); + + kick_angles[0] = f.readFloat(); + kick_angles[1] = f.readFloat(); + kick_angles[2] = f.readFloat(); + + kick_origin[0] = f.readFloat(); + kick_origin[1] = f.readFloat(); + kick_origin[2] = f.readFloat(); + + v_dmg_roll = f.readFloat(); + v_dmg_pitch = f.readFloat(); + v_dmg_time = f.readFloat(); + fall_time = f.readFloat(); + fall_value = f.readFloat(); + damage_alpha = f.readFloat(); + bonus_alpha = f.readFloat(); + + damage_blend[0] = f.readFloat(); + damage_blend[1] = f.readFloat(); + damage_blend[2] = f.readFloat(); + + v_angle[0] = f.readFloat(); + v_angle[1] = f.readFloat(); + v_angle[2] = f.readFloat(); + + bobtime = f.readFloat(); + + oldviewangles[0] = f.readFloat(); + oldviewangles[1] = f.readFloat(); + oldviewangles[2] = f.readFloat(); + + oldvelocity[0] = f.readFloat(); + oldvelocity[1] = f.readFloat(); + oldvelocity[2] = f.readFloat(); + + next_drown_time = f.readFloat(); + + old_waterlevel = f.readInt(); + breather_sound = f.readInt(); + machinegun_shots = f.readInt(); + anim_end = f.readInt(); + anim_priority = f.readInt(); + anim_duck = f.readInt() != 0; + anim_run = f.readInt() != 0; + + quad_framenum = f.readFloat(); + invincible_framenum = f.readFloat(); + breather_framenum = f.readFloat(); + enviro_framenum = f.readFloat(); + + grenade_blew_up = f.readInt() != 0; + grenade_time = f.readFloat(); + silencer_shots = f.readInt(); + weapon_sound = f.readInt(); + pickup_msg_time = f.readFloat(); + flood_locktill = f.readFloat(); + flood_when[0] = f.readFloat(); + flood_when[1] = f.readFloat(); + flood_when[2] = f.readFloat(); + flood_when[3] = f.readFloat(); + flood_when[4] = f.readFloat(); + flood_when[5] = f.readFloat(); + flood_when[6] = f.readFloat(); + flood_when[7] = f.readFloat(); + flood_when[8] = f.readFloat(); + flood_when[9] = f.readFloat(); + flood_whenhead = f.readInt(); + respawn_time = f.readFloat(); + chase_target = f.readEdictRef(); + update_chase = f.readInt() != 0; + + if (f.readInt() != 8765) + log.error("game client load failed for num={}", index); + } + + /** Writes a game_client_t (a player) to a file. */ + public void write(QuakeFile f) throws IOException + { + ps.write(f); + + f.writeInt(ping); + + pers.write(f); + resp.write(f); + + old_pmove.write(f); + + f.writeInt(showscores?1:0); + f.writeInt(showinventory?1:0); + f.writeInt(showhelp?1:0); + f.writeInt(showhelpicon?1:0); + f.writeInt(ammo_index); + + f.writeInt(buttons); + f.writeInt(oldbuttons); + f.writeInt(latched_buttons); + + f.writeInt(weapon_thunk?1:0); + f.writeItem(newweapon); + + + f.writeInt(damage_armor); + f.writeInt(damage_parmor); + f.writeInt(damage_blood); + f.writeInt(damage_knockback); + + f.writeFloat(damage_from[0]); + f.writeFloat(damage_from[1]); + f.writeFloat(damage_from[2]); + + f.writeFloat(killer_yaw); + + f.writeInt(weaponstate); + + f.writeFloat(kick_angles[0]); + f.writeFloat(kick_angles[1]); + f.writeFloat(kick_angles[2]); + + f.writeFloat(kick_origin[0]); + f.writeFloat(kick_origin[1]); + f.writeFloat(kick_origin[2]); + + f.writeFloat(v_dmg_roll); + f.writeFloat(v_dmg_pitch); + f.writeFloat(v_dmg_time); + f.writeFloat(fall_time); + f.writeFloat(fall_value); + f.writeFloat(damage_alpha); + f.writeFloat(bonus_alpha); + + f.writeFloat(damage_blend[0]); + f.writeFloat(damage_blend[1]); + f.writeFloat(damage_blend[2]); + + f.writeFloat(v_angle[0]); + f.writeFloat(v_angle[1]); + f.writeFloat(v_angle[2]); + + f.writeFloat(bobtime); + + f.writeFloat(oldviewangles[0]); + f.writeFloat(oldviewangles[1]); + f.writeFloat(oldviewangles[2]); + + f.writeFloat(oldvelocity[0]); + f.writeFloat(oldvelocity[1]); + f.writeFloat(oldvelocity[2]); + + f.writeFloat(next_drown_time); + + f.writeInt(old_waterlevel); + f.writeInt(breather_sound); + f.writeInt(machinegun_shots); + f.writeInt(anim_end); + f.writeInt(anim_priority); + f.writeInt(anim_duck?1:0); + f.writeInt(anim_run?1:0); + + f.writeFloat(quad_framenum); + f.writeFloat(invincible_framenum); + f.writeFloat(breather_framenum); + f.writeFloat(enviro_framenum); + + f.writeInt(grenade_blew_up?1:0); + f.writeFloat(grenade_time); + f.writeInt(silencer_shots); + f.writeInt(weapon_sound); + f.writeFloat(pickup_msg_time); + f.writeFloat(flood_locktill); + f.writeFloat(flood_when[0]); + f.writeFloat(flood_when[1]); + f.writeFloat(flood_when[2]); + f.writeFloat(flood_when[3]); + f.writeFloat(flood_when[4]); + f.writeFloat(flood_when[5]); + f.writeFloat(flood_when[6]); + f.writeFloat(flood_when[7]); + f.writeFloat(flood_when[8]); + f.writeFloat(flood_when[9]); + f.writeInt(flood_whenhead); + f.writeFloat(respawn_time); + f.writeEdictRef(chase_target); + f.writeInt(update_chase?1:0); + + f.writeInt(8765); + } } diff --git a/src/main/java/lwjake2/game/gitem_armor_t.java b/src/main/java/lwjake2/game/gitem_armor_t.java index 407b2bd..b48a2fb 100644 --- a/src/main/java/lwjake2/game/gitem_armor_t.java +++ b/src/main/java/lwjake2/game/gitem_armor_t.java @@ -19,23 +19,23 @@ package lwjake2.game; public class gitem_armor_t { - - public gitem_armor_t( - int base_count, - int max_count, - float normal_protection, - float energy_protection, - int armor) { - this.base_count= base_count; - this.max_count= max_count; - this.normal_protection= normal_protection; - this.energy_protection= energy_protection; - this.armor= armor; - } + + public gitem_armor_t( + int base_count, + int max_count, + float normal_protection, + float energy_protection, + int armor) { + this.base_count= base_count; + this.max_count= max_count; + this.normal_protection= normal_protection; + this.energy_protection= energy_protection; + this.armor= armor; + } - int base_count; - int max_count; - float normal_protection; - float energy_protection; - int armor; + int base_count; + int max_count; + float normal_protection; + float energy_protection; + int armor; } diff --git a/src/main/java/lwjake2/game/level_locals_t.java b/src/main/java/lwjake2/game/level_locals_t.java index d253f67..506b3d0 100644 --- a/src/main/java/lwjake2/game/level_locals_t.java +++ b/src/main/java/lwjake2/game/level_locals_t.java @@ -25,130 +25,130 @@ import java.io.IOException; @Slf4j public class level_locals_t { - // this structure is cleared as each map is entered - // it is read/written to the level.sav file for savegames - // - public int framenum; - public float time; + // this structure is cleared as each map is entered + // it is read/written to the level.sav file for savegames + // + public int framenum; + public float time; - public String level_name= ""; // the descriptive name (Outer Base, etc) - public String mapname= ""; // the server name (base1, etc) - public String nextmap= ""; // go here when fraglimit is hit + public String level_name= ""; // the descriptive name (Outer Base, etc) + public String mapname= ""; // the server name (base1, etc) + public String nextmap= ""; // go here when fraglimit is hit - // intermission state - public float intermissiontime; // time the intermission was started - public String changemap; - public boolean exitintermission; - public float[] intermission_origin= { 0, 0, 0 }; - public float[] intermission_angle= { 0, 0, 0 }; + // intermission state + public float intermissiontime; // time the intermission was started + public String changemap; + public boolean exitintermission; + public float[] intermission_origin= { 0, 0, 0 }; + public float[] intermission_angle= { 0, 0, 0 }; - public edict_t sight_client; // changed once each frame for coop games + public edict_t sight_client; // changed once each frame for coop games - public edict_t sight_entity; - public int sight_entity_framenum; - - public edict_t sound_entity; - public int sound_entity_framenum; - - public edict_t sound2_entity; - public int sound2_entity_framenum; + public edict_t sight_entity; + public int sight_entity_framenum; + + public edict_t sound_entity; + public int sound_entity_framenum; + + public edict_t sound2_entity; + public int sound2_entity_framenum; - public int pic_health; + public int pic_health; - public int total_secrets; - public int found_secrets; + public int total_secrets; + public int found_secrets; - public int total_goals; - public int found_goals; + public int total_goals; + public int found_goals; - public int total_monsters; - public int killed_monsters; + public int total_monsters; + public int killed_monsters; - public edict_t current_entity; // entity running from G_RunFrame - public int body_que; // dead bodies + public edict_t current_entity; // entity running from G_RunFrame + public int body_que; // dead bodies - public int power_cubes; // ugly necessity for coop + public int power_cubes; // ugly necessity for coop - /** Writes the levellocales to the file. */ - public void write(QuakeFile f) throws IOException - { - f.writeInt(framenum); - f.writeFloat(time); - f.writeString(level_name); - f.writeString(mapname); - f.writeString(nextmap); - f.writeFloat(intermissiontime); - f.writeString(changemap); - f.writeBoolean(exitintermission); - f.writeVector(intermission_origin); - f.writeVector(intermission_angle); - f.writeEdictRef(sight_client); - - f.writeEdictRef(sight_entity); - f.writeInt(sight_entity_framenum); - - f.writeEdictRef(sound_entity); - f.writeInt(sound_entity_framenum); - f.writeEdictRef(sound2_entity); - f.writeInt(sound2_entity_framenum); + /** Writes the levellocales to the file. */ + public void write(QuakeFile f) throws IOException + { + f.writeInt(framenum); + f.writeFloat(time); + f.writeString(level_name); + f.writeString(mapname); + f.writeString(nextmap); + f.writeFloat(intermissiontime); + f.writeString(changemap); + f.writeBoolean(exitintermission); + f.writeVector(intermission_origin); + f.writeVector(intermission_angle); + f.writeEdictRef(sight_client); + + f.writeEdictRef(sight_entity); + f.writeInt(sight_entity_framenum); + + f.writeEdictRef(sound_entity); + f.writeInt(sound_entity_framenum); + f.writeEdictRef(sound2_entity); + f.writeInt(sound2_entity_framenum); - f.writeInt(pic_health); + f.writeInt(pic_health); - f.writeInt(total_secrets); - f.writeInt(found_secrets); - - f.writeInt(total_goals); - f.writeInt(found_goals); - f.writeInt(total_monsters); - f.writeInt(killed_monsters); - - f.writeEdictRef(current_entity); - f.writeInt(body_que); // dead bodies - f.writeInt(power_cubes); // ugly necessity for coop - - // rst's checker :-) - f.writeInt(4711); - } - - /** Reads the level locals from the file. */ - public void read(QuakeFile f) throws IOException - { - framenum = f.readInt(); - time = f.readFloat(); - level_name = f.readString(); - mapname = f.readString(); - nextmap = f.readString(); - intermissiontime = f.readFloat(); - changemap = f.readString(); - exitintermission = f.readBoolean(); - intermission_origin = f.readVector(); - intermission_angle = f.readVector(); - sight_client = f.readEdictRef(); - - sight_entity = f.readEdictRef(); - sight_entity_framenum = f.readInt(); - - sound_entity = f.readEdictRef(); - sound_entity_framenum = f.readInt(); - sound2_entity = f.readEdictRef(); - sound2_entity_framenum = f.readInt(); + f.writeInt(total_secrets); + f.writeInt(found_secrets); + + f.writeInt(total_goals); + f.writeInt(found_goals); + f.writeInt(total_monsters); + f.writeInt(killed_monsters); + + f.writeEdictRef(current_entity); + f.writeInt(body_que); // dead bodies + f.writeInt(power_cubes); // ugly necessity for coop + + // rst's checker :-) + f.writeInt(4711); + } + + /** Reads the level locals from the file. */ + public void read(QuakeFile f) throws IOException + { + framenum = f.readInt(); + time = f.readFloat(); + level_name = f.readString(); + mapname = f.readString(); + nextmap = f.readString(); + intermissiontime = f.readFloat(); + changemap = f.readString(); + exitintermission = f.readBoolean(); + intermission_origin = f.readVector(); + intermission_angle = f.readVector(); + sight_client = f.readEdictRef(); + + sight_entity = f.readEdictRef(); + sight_entity_framenum = f.readInt(); + + sound_entity = f.readEdictRef(); + sound_entity_framenum = f.readInt(); + sound2_entity = f.readEdictRef(); + sound2_entity_framenum = f.readInt(); - pic_health = f.readInt(); + pic_health = f.readInt(); - total_secrets = f.readInt(); - found_secrets = f.readInt(); - - total_goals = f.readInt(); - found_goals = f.readInt(); - total_monsters = f.readInt(); - killed_monsters = f.readInt(); - - current_entity = f.readEdictRef(); - body_que = f.readInt(); // dead bodies - power_cubes = f.readInt(); // ugly necessity for coop - - // rst's checker :-) - if (f.readInt()!= 4711) - log.error("error in reading level_locals."); - } + total_secrets = f.readInt(); + found_secrets = f.readInt(); + + total_goals = f.readInt(); + found_goals = f.readInt(); + total_monsters = f.readInt(); + killed_monsters = f.readInt(); + + current_entity = f.readEdictRef(); + body_que = f.readInt(); // dead bodies + power_cubes = f.readInt(); // ugly necessity for coop + + // rst's checker :-) + if (f.readInt()!= 4711) + log.error("error in reading level_locals."); + } } diff --git a/src/main/java/lwjake2/game/link_t.java b/src/main/java/lwjake2/game/link_t.java index f16cc9a..0584695 100644 --- a/src/main/java/lwjake2/game/link_t.java +++ b/src/main/java/lwjake2/game/link_t.java @@ -19,9 +19,9 @@ package lwjake2.game; public class link_t { - public link_t(Object o) { - this.o = o; - } - public link_t prev, next; - public Object o; + public link_t(Object o) { + this.o = o; + } + public link_t prev, next; + public Object o; } diff --git a/src/main/java/lwjake2/game/mapsurface_t.java b/src/main/java/lwjake2/game/mapsurface_t.java index 4095d80..a40e8d2 100644 --- a/src/main/java/lwjake2/game/mapsurface_t.java +++ b/src/main/java/lwjake2/game/mapsurface_t.java @@ -19,6 +19,6 @@ package lwjake2.game; public class mapsurface_t { - public csurface_t c = new csurface_t(); - public String rname; + public csurface_t c = new csurface_t(); + public String rname; } diff --git a/src/main/java/lwjake2/game/mframe_t.java b/src/main/java/lwjake2/game/mframe_t.java index 7cb52b1..6fbbdb7 100644 --- a/src/main/java/lwjake2/game/mframe_t.java +++ b/src/main/java/lwjake2/game/mframe_t.java @@ -24,32 +24,32 @@ import java.io.IOException; public class mframe_t { - public mframe_t(AIAdapter ai, float dist, EntThinkAdapter think) - { - this.ai= ai; - this.dist= dist; - this.think= think; - } - - /** Empty constructor. */ - public mframe_t() - {} + public mframe_t(AIAdapter ai, float dist, EntThinkAdapter think) + { + this.ai= ai; + this.dist= dist; + this.think= think; + } + + /** Empty constructor. */ + public mframe_t() + {} - public AIAdapter ai; - public float dist; - public EntThinkAdapter think; + public AIAdapter ai; + public float dist; + public EntThinkAdapter think; - public void write(QuakeFile f) throws IOException - { - f.writeAdapter(ai); - f.writeFloat(dist); - f.writeAdapter(think); - } + public void write(QuakeFile f) throws IOException + { + f.writeAdapter(ai); + f.writeFloat(dist); + f.writeAdapter(think); + } - public void read(QuakeFile f) throws IOException - { - ai= (AIAdapter) f.readAdapter(); - dist= f.readFloat(); - think= (EntThinkAdapter) f.readAdapter(); - } + public void read(QuakeFile f) throws IOException + { + ai= (AIAdapter) f.readAdapter(); + dist= f.readFloat(); + think= (EntThinkAdapter) f.readAdapter(); + } } diff --git a/src/main/java/lwjake2/game/mmove_t.java b/src/main/java/lwjake2/game/mmove_t.java index 2e5b244..768ba80 100644 --- a/src/main/java/lwjake2/game/mmove_t.java +++ b/src/main/java/lwjake2/game/mmove_t.java @@ -23,53 +23,53 @@ import lwjake2.util.QuakeFile; import java.io.IOException; public class mmove_t { - public mmove_t(int firstframe, int lastframe, mframe_t frame[], EntThinkAdapter endfunc) { - - this.firstframe= firstframe; - this.lastframe= lastframe; - this.frame= frame; - this.endfunc= endfunc; - } + public mmove_t(int firstframe, int lastframe, mframe_t frame[], EntThinkAdapter endfunc) { + + this.firstframe= firstframe; + this.lastframe= lastframe; + this.frame= frame; + this.endfunc= endfunc; + } - public mmove_t() - {} + public mmove_t() + {} - public int firstframe; - public int lastframe; - public mframe_t frame[]; //ptr - public EntThinkAdapter endfunc; - + public int firstframe; + public int lastframe; + public mframe_t frame[]; //ptr + public EntThinkAdapter endfunc; + - /** Writes the structure to a random acccess file. */ - public void write(QuakeFile f) throws IOException - { - f.writeInt(firstframe); - f.writeInt(lastframe); - if (frame == null) - f.writeInt(-1); - else - { - f. writeInt(frame.length); - for (int n=0; n < frame.length; n++) - frame[n].write(f); - } - f.writeAdapter(endfunc); - } - - /** Read the mmove_t from the RandomAccessFile. */ - public void read(QuakeFile f) throws IOException - { - firstframe = f.readInt(); - lastframe = f.readInt(); - - int len = f.readInt(); - - frame = new mframe_t[len]; - for (int n=0; n < len ; n++) - { - frame[n] = new mframe_t(); - frame[n].read(f); - } - endfunc = (EntThinkAdapter) f.readAdapter(); - } + /** Writes the structure to a random acccess file. */ + public void write(QuakeFile f) throws IOException + { + f.writeInt(firstframe); + f.writeInt(lastframe); + if (frame == null) + f.writeInt(-1); + else + { + f. writeInt(frame.length); + for (int n=0; n < frame.length; n++) + frame[n].write(f); + } + f.writeAdapter(endfunc); + } + + /** Read the mmove_t from the RandomAccessFile. */ + public void read(QuakeFile f) throws IOException + { + firstframe = f.readInt(); + lastframe = f.readInt(); + + int len = f.readInt(); + + frame = new mframe_t[len]; + for (int n=0; n < len ; n++) + { + frame[n] = new mframe_t(); + frame[n].read(f); + } + endfunc = (EntThinkAdapter) f.readAdapter(); + } } diff --git a/src/main/java/lwjake2/game/monsterinfo_t.java b/src/main/java/lwjake2/game/monsterinfo_t.java index 8a18f68..536df0d 100644 --- a/src/main/java/lwjake2/game/monsterinfo_t.java +++ b/src/main/java/lwjake2/game/monsterinfo_t.java @@ -24,133 +24,133 @@ import java.io.IOException; public class monsterinfo_t { - public mmove_t currentmove; - public int aiflags; - public int nextframe; - public float scale; + public mmove_t currentmove; + public int aiflags; + public int nextframe; + public float scale; - public EntThinkAdapter stand; - public EntThinkAdapter idle; - public EntThinkAdapter search; - public EntThinkAdapter walk; - public EntThinkAdapter run; + public EntThinkAdapter stand; + public EntThinkAdapter idle; + public EntThinkAdapter search; + public EntThinkAdapter walk; + public EntThinkAdapter run; - public EntDodgeAdapter dodge; + public EntDodgeAdapter dodge; - public EntThinkAdapter attack; - public EntThinkAdapter melee; + public EntThinkAdapter attack; + public EntThinkAdapter melee; - public EntInteractAdapter sight; + public EntInteractAdapter sight; - public EntThinkAdapter checkattack; + public EntThinkAdapter checkattack; - public float pausetime; - public float attack_finished; + public float pausetime; + public float attack_finished; - public float[] saved_goal= { 0, 0, 0 }; - public float search_time; - public float trail_time; - public float[] last_sighting= { 0, 0, 0 }; - public int attack_state; - public int lefty; - public float idle_time; - public int linkcount; + public float[] saved_goal= { 0, 0, 0 }; + public float search_time; + public float trail_time; + public float[] last_sighting= { 0, 0, 0 }; + public int attack_state; + public int lefty; + public float idle_time; + public int linkcount; - public int power_armor_type; - public int power_armor_power; + public int power_armor_type; + public int power_armor_power; - /** Writes the monsterinfo to the file. */ - public void write(QuakeFile f) throws IOException - { - f.writeBoolean(currentmove != null); - if (currentmove != null) - currentmove.write(f); - f.writeInt(aiflags); - f.writeInt(nextframe); - f.writeFloat(scale); - f.writeAdapter(stand); - f.writeAdapter(idle); - f.writeAdapter(search); - f.writeAdapter(walk); - f.writeAdapter(run); - - f.writeAdapter(dodge); - - f.writeAdapter(attack); - f.writeAdapter(melee); - - f.writeAdapter(sight); - - f.writeAdapter(checkattack); - - f.writeFloat(pausetime); - f.writeFloat(attack_finished); - - f.writeVector(saved_goal); - - f.writeFloat(search_time); - f.writeFloat(trail_time); - - f.writeVector(last_sighting); + /** Writes the monsterinfo to the file. */ + public void write(QuakeFile f) throws IOException + { + f.writeBoolean(currentmove != null); + if (currentmove != null) + currentmove.write(f); + f.writeInt(aiflags); + f.writeInt(nextframe); + f.writeFloat(scale); + f.writeAdapter(stand); + f.writeAdapter(idle); + f.writeAdapter(search); + f.writeAdapter(walk); + f.writeAdapter(run); + + f.writeAdapter(dodge); + + f.writeAdapter(attack); + f.writeAdapter(melee); + + f.writeAdapter(sight); + + f.writeAdapter(checkattack); + + f.writeFloat(pausetime); + f.writeFloat(attack_finished); + + f.writeVector(saved_goal); + + f.writeFloat(search_time); + f.writeFloat(trail_time); + + f.writeVector(last_sighting); - f.writeInt(attack_state); - f.writeInt(lefty); - - f.writeFloat(idle_time); - f.writeInt(linkcount); - - f.writeInt(power_armor_power); - f.writeInt(power_armor_type); - } + f.writeInt(attack_state); + f.writeInt(lefty); + + f.writeFloat(idle_time); + f.writeInt(linkcount); + + f.writeInt(power_armor_power); + f.writeInt(power_armor_type); + } - /** Writes the monsterinfo to the file. */ - public void read(QuakeFile f) throws IOException - { - if (f.readBoolean()) - { - currentmove= new mmove_t(); - currentmove.read(f); - } - else - currentmove= null; - aiflags = f.readInt(); - nextframe = f.readInt(); - scale = f.readFloat(); - stand = (EntThinkAdapter) f.readAdapter(); - idle = (EntThinkAdapter) f.readAdapter(); - search = (EntThinkAdapter) f.readAdapter(); - walk = (EntThinkAdapter) f.readAdapter(); - run = (EntThinkAdapter) f.readAdapter(); - - dodge = (EntDodgeAdapter) f.readAdapter(); - - attack = (EntThinkAdapter) f.readAdapter(); - melee = (EntThinkAdapter) f.readAdapter(); - - sight = (EntInteractAdapter) f.readAdapter(); - - checkattack = (EntThinkAdapter) f.readAdapter(); - - pausetime = f.readFloat(); - attack_finished = f.readFloat(); - - saved_goal = f.readVector(); - - search_time = f.readFloat(); - trail_time = f.readFloat(); - - last_sighting = f.readVector(); + /** Writes the monsterinfo to the file. */ + public void read(QuakeFile f) throws IOException + { + if (f.readBoolean()) + { + currentmove= new mmove_t(); + currentmove.read(f); + } + else + currentmove= null; + aiflags = f.readInt(); + nextframe = f.readInt(); + scale = f.readFloat(); + stand = (EntThinkAdapter) f.readAdapter(); + idle = (EntThinkAdapter) f.readAdapter(); + search = (EntThinkAdapter) f.readAdapter(); + walk = (EntThinkAdapter) f.readAdapter(); + run = (EntThinkAdapter) f.readAdapter(); + + dodge = (EntDodgeAdapter) f.readAdapter(); + + attack = (EntThinkAdapter) f.readAdapter(); + melee = (EntThinkAdapter) f.readAdapter(); + + sight = (EntInteractAdapter) f.readAdapter(); + + checkattack = (EntThinkAdapter) f.readAdapter(); + + pausetime = f.readFloat(); + attack_finished = f.readFloat(); + + saved_goal = f.readVector(); + + search_time = f.readFloat(); + trail_time = f.readFloat(); + + last_sighting = f.readVector(); - attack_state = f.readInt(); - lefty = f.readInt(); - - idle_time = f.readFloat(); - linkcount = f.readInt(); - - power_armor_power = f.readInt(); - power_armor_type = f.readInt(); + attack_state = f.readInt(); + lefty = f.readInt(); + + idle_time = f.readFloat(); + linkcount = f.readInt(); + + power_armor_power = f.readInt(); + power_armor_type = f.readInt(); - } + } } diff --git a/src/main/java/lwjake2/game/monsters/M_Actor.java b/src/main/java/lwjake2/game/monsters/M_Actor.java index 4e11467..b5d1104 100644 --- a/src/main/java/lwjake2/game/monsters/M_Actor.java +++ b/src/main/java/lwjake2/game/monsters/M_Actor.java @@ -38,7 +38,7 @@ import lwjake2.util.Lib; import lwjake2.util.Math3D; public class M_Actor { - // This file generated by ModelGen - Do NOT Modify + // This file generated by ModelGen - Do NOT Modify public final static int FRAME_attak01 = 0; @@ -1295,9 +1295,9 @@ public class M_Actor { int damage, float[] point) { int n; - // check for gib + // check for gib if (self.health <= -80) { - // gi.sound (self, CHAN_VOICE, actor.sound_gib, 1, ATTN_NORM, + // gi.sound (self, CHAN_VOICE, actor.sound_gib, 1, ATTN_NORM, // 0); for (n = 0; n < 2; n++) GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2", @@ -1315,8 +1315,8 @@ public class M_Actor { if (self.deadflag == Defines.DEAD_DEAD) return; - // regular death - // gi.sound (self, CHAN_VOICE, actor.sound_die, 1, ATTN_NORM, 0); + // regular death + // gi.sound (self, CHAN_VOICE, actor.sound_die, 1, ATTN_NORM, 0); self.deadflag = Defines.DEAD_DEAD; self.takedamage = Defines.DAMAGE_YES; diff --git a/src/main/java/lwjake2/game/monsters/M_Berserk.java b/src/main/java/lwjake2/game/monsters/M_Berserk.java index b1dd43d..c7c24be 100644 --- a/src/main/java/lwjake2/game/monsters/M_Berserk.java +++ b/src/main/java/lwjake2/game/monsters/M_Berserk.java @@ -690,7 +690,7 @@ public class M_Berserk { float[] aim = { Defines.MELEE_DISTANCE, 0f, -24f }; GameWeapon.fire_hit(self, aim, (15 + (Lib.rand() % 6)), 400); - // Faster attack -- upwards and backwards + // Faster attack -- upwards and backwards return true; } diff --git a/src/main/java/lwjake2/game/monsters/M_Boss2.java b/src/main/java/lwjake2/game/monsters/M_Boss2.java index e3bd833..c49fea5 100644 --- a/src/main/java/lwjake2/game/monsters/M_Boss2.java +++ b/src/main/java/lwjake2/game/monsters/M_Boss2.java @@ -410,7 +410,7 @@ public class M_Boss2 { static int sound_search1; static EntThinkAdapter boss2_stand = new EntThinkAdapter() { - public String getID() { return "boss2_stand"; } + public String getID() { return "boss2_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = boss2_move_stand; return true; @@ -418,7 +418,7 @@ public class M_Boss2 { }; static EntThinkAdapter boss2_run = new EntThinkAdapter() { - public String getID() { return "boss2_run"; } + public String getID() { return "boss2_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) self.monsterinfo.currentmove = boss2_move_stand; @@ -429,7 +429,7 @@ public class M_Boss2 { }; static EntThinkAdapter boss2_walk = new EntThinkAdapter() { - public String getID() { return "boss2_walk"; } + public String getID() { return "boss2_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = boss2_move_stand; @@ -439,7 +439,7 @@ public class M_Boss2 { }; static EntThinkAdapter boss2_attack = new EntThinkAdapter() { - public String getID() { return "boss2_attack"; } + public String getID() { return "boss2_attack"; } public boolean think(edict_t self) { float[] vec = { 0, 0, 0 }; @@ -461,7 +461,7 @@ public class M_Boss2 { }; static EntThinkAdapter boss2_attack_mg = new EntThinkAdapter() { - public String getID() { return "boss2_attack_mg"; } + public String getID() { return "boss2_attack_mg"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = boss2_move_attack_mg; return true; @@ -469,7 +469,7 @@ public class M_Boss2 { }; static EntThinkAdapter boss2_reattack_mg = new EntThinkAdapter() { - public String getID() { return "boss2_reattack_mg"; } + public String getID() { return "boss2_reattack_mg"; } public boolean think(edict_t self) { if (GameUtil.infront(self, self.enemy)) if (Lib.random() <= 0.7) @@ -483,7 +483,7 @@ public class M_Boss2 { }; static EntPainAdapter boss2_pain = new EntPainAdapter() { - public String getID() { return "boss2_pain"; } + public String getID() { return "boss2_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { if (self.health < (self.max_health / 2)) self.s.skinnum = 1; @@ -492,7 +492,7 @@ public class M_Boss2 { return; self.pain_debounce_time = GameBase.level.time + 3; - // American wanted these at no attenuation + // American wanted these at no attenuation if (damage < 10) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_pain3, 1, Defines.ATTN_NONE, 0); @@ -510,7 +510,7 @@ public class M_Boss2 { }; static EntThinkAdapter boss2_dead = new EntThinkAdapter() { - public String getID() { return "boss2_dead"; } + public String getID() { return "boss2_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -56, -56, 0); Math3D.VectorSet(self.maxs, 56, 56, 80); @@ -523,7 +523,7 @@ public class M_Boss2 { }; static EntDieAdapter boss2_die = new EntDieAdapter() { - public String getID() { return "boss2_die"; } + public String getID() { return "boss2_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_death, 1, @@ -537,7 +537,7 @@ public class M_Boss2 { }; static EntThinkAdapter Boss2_CheckAttack = new EntThinkAdapter() { - public String getID() { return "Boss2_CheckAttack"; } + public String getID() { return "Boss2_CheckAttack"; } public boolean think(edict_t self) { float[] spot1 = { 0, 0, 0 }, spot2 = { 0, 0, 0 }; float[] temp = { 0, 0, 0 }; @@ -578,7 +578,7 @@ public class M_Boss2 { return true; } - // missile attack + // missile attack if (self.monsterinfo.attack == null) return false; @@ -617,7 +617,7 @@ public class M_Boss2 { }; static EntThinkAdapter boss2_search = new EntThinkAdapter() { - public String getID() { return "boss2_search"; } + public String getID() { return "boss2_search"; } public boolean think(edict_t self) { if (Lib.random() < 0.5) GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search1, 1, @@ -627,7 +627,7 @@ public class M_Boss2 { }; static EntThinkAdapter Boss2Rocket = new EntThinkAdapter() { - public String getID() { return "Boss2Rocket"; } + public String getID() { return "Boss2Rocket"; } public boolean think(edict_t self) { float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; float[] start = { 0, 0, 0 }; @@ -636,7 +636,7 @@ public class M_Boss2 { Math3D.AngleVectors(self.s.angles, forward, right, null); - // 1 + // 1 Math3D.G_ProjectSource(self.s.origin, M_Flash.monster_flash_offset[Defines.MZ2_BOSS2_ROCKET_1], forward, right, start); @@ -647,7 +647,7 @@ public class M_Boss2 { Monster.monster_fire_rocket(self, start, dir, 50, 500, Defines.MZ2_BOSS2_ROCKET_1); - // 2 + // 2 Math3D.G_ProjectSource(self.s.origin, M_Flash.monster_flash_offset[Defines.MZ2_BOSS2_ROCKET_2], forward, right, start); @@ -658,7 +658,7 @@ public class M_Boss2 { Monster.monster_fire_rocket(self, start, dir, 50, 500, Defines.MZ2_BOSS2_ROCKET_2); - // 3 + // 3 Math3D.G_ProjectSource(self.s.origin, M_Flash.monster_flash_offset[Defines.MZ2_BOSS2_ROCKET_3], forward, right, start); @@ -669,7 +669,7 @@ public class M_Boss2 { Monster.monster_fire_rocket(self, start, dir, 50, 500, Defines.MZ2_BOSS2_ROCKET_3); - // 4 + // 4 Math3D.G_ProjectSource(self.s.origin, M_Flash.monster_flash_offset[Defines.MZ2_BOSS2_ROCKET_4], forward, right, start); @@ -684,7 +684,7 @@ public class M_Boss2 { }; static EntThinkAdapter boss2_firebullet_right = new EntThinkAdapter() { - public String getID() { return "boss2_firebullet_right"; } + public String getID() { return "boss2_firebullet_right"; } public boolean think(edict_t self) { float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, target = { 0, 0, 0 }; @@ -713,7 +713,7 @@ public class M_Boss2 { }; static EntThinkAdapter boss2_firebullet_left = new EntThinkAdapter() { - public String getID() { return "boss2_firebullet_left"; } + public String getID() { return "boss2_firebullet_left"; } public boolean think(edict_t self) { float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, target = { 0, 0, 0 }; @@ -743,7 +743,7 @@ public class M_Boss2 { }; static EntThinkAdapter Boss2MachineGun = new EntThinkAdapter() { - public String getID() { return "Boss2MachineGun"; } + public String getID() { return "Boss2MachineGun"; } public boolean think(edict_t self) { /* * RST: this was disabled ! float[] forward={0,0,0}, right={0,0,0}; @@ -892,7 +892,7 @@ public class M_Boss2 { static mmove_t boss2_move_attack_pre_mg = new mmove_t(FRAME_attack1, FRAME_attack9, boss2_frames_attack_pre_mg, null); - // Loop this + // Loop this static mframe_t boss2_frames_attack_mg[] = new mframe_t[] { new mframe_t(GameAI.ai_charge, 1, Boss2MachineGun), new mframe_t(GameAI.ai_charge, 1, Boss2MachineGun), diff --git a/src/main/java/lwjake2/game/monsters/M_Boss3.java b/src/main/java/lwjake2/game/monsters/M_Boss3.java index 4a1d580..29543a4 100644 --- a/src/main/java/lwjake2/game/monsters/M_Boss3.java +++ b/src/main/java/lwjake2/game/monsters/M_Boss3.java @@ -29,7 +29,7 @@ import lwjake2.util.Math3D; public class M_Boss3 { static EntUseAdapter Use_Boss3 = new EntUseAdapter() { - public String getID() { return "Use_Boss3"; } + public String getID() { return "Use_Boss3"; } public void use(edict_t ent, edict_t other, edict_t activator) { GameBase.gi.WriteByte(Defines.svc_temp_entity); GameBase.gi.WriteByte(Defines.TE_BOSSTPORT); @@ -40,7 +40,7 @@ public class M_Boss3 { }; static EntThinkAdapter Think_Boss3Stand = new EntThinkAdapter() { - public String getID() { return "Think_Boss3Stand"; } + public String getID() { return "Think_Boss3Stand"; } public boolean think(edict_t ent) { if (ent.s.frame == M_Boss32.FRAME_stand260) ent.s.frame = M_Boss32.FRAME_stand201; diff --git a/src/main/java/lwjake2/game/monsters/M_Boss31.java b/src/main/java/lwjake2/game/monsters/M_Boss31.java index bcb3ca0..428f909 100644 --- a/src/main/java/lwjake2/game/monsters/M_Boss31.java +++ b/src/main/java/lwjake2/game/monsters/M_Boss31.java @@ -455,7 +455,7 @@ public class M_Boss31 { */ static EntThinkAdapter jorg_search = new EntThinkAdapter() { - public String getID() { return "jorg_search"; } + public String getID() { return "jorg_search"; } public boolean think(edict_t self) { float r; @@ -475,7 +475,7 @@ public class M_Boss31 { }; static EntThinkAdapter jorg_idle = new EntThinkAdapter() { - public String getID() { return "jorg_idle"; } + public String getID() { return "jorg_idle"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1, Defines.ATTN_NORM, 0); @@ -484,7 +484,7 @@ public class M_Boss31 { }; static EntThinkAdapter jorg_death_hit = new EntThinkAdapter() { - public String getID() { return "jorg_death_hit"; } + public String getID() { return "jorg_death_hit"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_BODY, sound_death_hit, 1, Defines.ATTN_NORM, 0); @@ -493,7 +493,7 @@ public class M_Boss31 { }; static EntThinkAdapter jorg_step_left = new EntThinkAdapter() { - public String getID() { return "jorg_step_left"; } + public String getID() { return "jorg_step_left"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_BODY, sound_step_left, 1, Defines.ATTN_NORM, 0); @@ -502,7 +502,7 @@ public class M_Boss31 { }; static EntThinkAdapter jorg_step_right = new EntThinkAdapter() { - public String getID() { return "jorg_step_right"; } + public String getID() { return "jorg_step_right"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_BODY, sound_step_right, 1, Defines.ATTN_NORM, 0); @@ -511,7 +511,7 @@ public class M_Boss31 { }; static EntThinkAdapter jorg_stand = new EntThinkAdapter() { - public String getID() { return "jorg_stand"; } + public String getID() { return "jorg_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = jorg_move_stand; return true; @@ -519,7 +519,7 @@ public class M_Boss31 { }; static EntThinkAdapter jorg_reattack1 = new EntThinkAdapter() { - public String getID() { return "jorg_reattack1"; } + public String getID() { return "jorg_reattack1"; } public boolean think(edict_t self) { if (GameUtil.visible(self, self.enemy)) if (Lib.random() < 0.9) @@ -537,7 +537,7 @@ public class M_Boss31 { }; static EntThinkAdapter jorg_attack1 = new EntThinkAdapter() { - public String getID() { return "jorg_attack1"; } + public String getID() { return "jorg_attack1"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = jorg_move_attack1; return true; @@ -545,7 +545,7 @@ public class M_Boss31 { }; static EntPainAdapter jorg_pain = new EntPainAdapter() { - public String getID() { return "jorg_pain"; } + public String getID() { return "jorg_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { if (self.health < (self.max_health / 2)) self.s.skinnum = 1; @@ -605,7 +605,7 @@ public class M_Boss31 { }; static EntThinkAdapter jorgBFG = new EntThinkAdapter() { - public String getID() { return "jorgBFG"; } + public String getID() { return "jorgBFG"; } public boolean think(edict_t self) { float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; @@ -636,7 +636,7 @@ public class M_Boss31 { }; static EntThinkAdapter jorg_firebullet_right = new EntThinkAdapter() { - public String getID() { return "jorg_firebullet_right"; } + public String getID() { return "jorg_firebullet_right"; } public boolean think(edict_t self) { float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, target = { 0, 0, 0 }; @@ -664,7 +664,7 @@ public class M_Boss31 { }; static EntThinkAdapter jorg_firebullet_left = new EntThinkAdapter() { - public String getID() { return "jorg_firebullet_left"; } + public String getID() { return "jorg_firebullet_left"; } public boolean think(edict_t self) { float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, target = { 0, 0, 0 }; @@ -692,7 +692,7 @@ public class M_Boss31 { }; static EntThinkAdapter jorg_firebullet = new EntThinkAdapter() { - public String getID() { return "jorg_firebullet"; } + public String getID() { return "jorg_firebullet"; } public boolean think(edict_t self) { jorg_firebullet_left.think(self); jorg_firebullet_right.think(self); @@ -701,7 +701,7 @@ public class M_Boss31 { }; static EntThinkAdapter jorg_attack = new EntThinkAdapter() { - public String getID() { return "jorg_attack"; } + public String getID() { return "jorg_attack"; } public boolean think(edict_t self) { float[] vec = { 0, 0, 0 }; @@ -723,7 +723,7 @@ public class M_Boss31 { /** Was disabled. RST. */ static EntThinkAdapter jorg_dead = new EntThinkAdapter() { - public String getID() { return "jorg_dead"; } + public String getID() { return "jorg_dead"; } public boolean think(edict_t self) { /* * edict_t tempent; @@ -746,7 +746,7 @@ public class M_Boss31 { }; static EntDieAdapter jorg_die = new EntDieAdapter() { - public String getID() { return "jorg_die"; } + public String getID() { return "jorg_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_death, 1, @@ -761,7 +761,7 @@ public class M_Boss31 { }; static EntThinkAdapter Jorg_CheckAttack = new EntThinkAdapter() { - public String getID() { return "Jorg_CheckAttack"; } + public String getID() { return "Jorg_CheckAttack"; } public boolean think(edict_t self) { float[] spot1 = { 0, 0, 0 }, spot2 = { 0, 0, 0 }; float[] temp = { 0, 0, 0 }; @@ -802,7 +802,7 @@ public class M_Boss31 { return true; } - // missile attack ? + // missile attack ? if (self.monsterinfo.attack == null) return false; @@ -841,7 +841,7 @@ public class M_Boss31 { }; // - // stand + // stand // static mframe_t jorg_frames_stand[] = new mframe_t[] { @@ -926,7 +926,7 @@ public class M_Boss31 { jorg_frames_run, null); // - // walk + // walk // static mframe_t jorg_frames_start_walk[] = new mframe_t[] { @@ -970,7 +970,7 @@ public class M_Boss31 { jorg_frames_end_walk, null); static EntThinkAdapter jorg_walk = new EntThinkAdapter() { - public String getID() { return "jorg_walk"; } + public String getID() { return "jorg_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = jorg_move_walk; return true; @@ -978,7 +978,7 @@ public class M_Boss31 { }; static EntThinkAdapter jorg_run = new EntThinkAdapter() { - public String getID() { return "jorg_run"; } + public String getID() { return "jorg_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) self.monsterinfo.currentmove = jorg_move_stand; diff --git a/src/main/java/lwjake2/game/monsters/M_Boss32.java b/src/main/java/lwjake2/game/monsters/M_Boss32.java index 6386fce..a211a4d 100644 --- a/src/main/java/lwjake2/game/monsters/M_Boss32.java +++ b/src/main/java/lwjake2/game/monsters/M_Boss32.java @@ -1051,7 +1051,7 @@ public class M_Boss32 { static int sound_hit; static EntThinkAdapter makron_taunt = new EntThinkAdapter() { - public String getID() { return "makron_taunt"; } + public String getID() { return "makron_taunt"; } public boolean think(edict_t self) { float r; @@ -1070,10 +1070,10 @@ public class M_Boss32 { }; // - // stand + // stand // static EntThinkAdapter makron_stand = new EntThinkAdapter() { - public String getID() { return "makron_stand"; } + public String getID() { return "makron_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = makron_move_stand; return true; @@ -1086,7 +1086,7 @@ public class M_Boss32 { */ static EntThinkAdapter makron_hit = new EntThinkAdapter() { - public String getID() { return "makron_hit"; } + public String getID() { return "makron_hit"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_AUTO, sound_hit, 1, Defines.ATTN_NONE, 0); @@ -1095,7 +1095,7 @@ public class M_Boss32 { }; static EntThinkAdapter makron_popup = new EntThinkAdapter() { - public String getID() { return "makron_popup"; } + public String getID() { return "makron_popup"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_BODY, sound_popup, 1, Defines.ATTN_NONE, 0); @@ -1104,7 +1104,7 @@ public class M_Boss32 { }; static EntThinkAdapter makron_step_left = new EntThinkAdapter() { - public String getID() { return "makron_step_left"; } + public String getID() { return "makron_step_left"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_BODY, sound_step_left, 1, @@ -1114,7 +1114,7 @@ public class M_Boss32 { }; static EntThinkAdapter makron_step_right = new EntThinkAdapter() { - public String getID() { return "makron_step_right"; } + public String getID() { return "makron_step_right"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_BODY, sound_step_right, 1, Defines.ATTN_NORM, 0); @@ -1123,7 +1123,7 @@ public class M_Boss32 { }; static EntThinkAdapter makron_brainsplorch = new EntThinkAdapter() { - public String getID() { return "makron_brainsplorch"; } + public String getID() { return "makron_brainsplorch"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_brainsplorch, 1, Defines.ATTN_NORM, 0); @@ -1132,7 +1132,7 @@ public class M_Boss32 { }; static EntThinkAdapter makron_prerailgun = new EntThinkAdapter() { - public String getID() { return "makron_prerailgun"; } + public String getID() { return "makron_prerailgun"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_prerailgun, 1, Defines.ATTN_NORM, 0); @@ -1242,10 +1242,10 @@ public class M_Boss32 { makron_frames_run, null); // - // death + // death // static EntThinkAdapter makron_dead = new EntThinkAdapter() { - public String getID() { return "makron_dead"; } + public String getID() { return "makron_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -60, -60, 0); Math3D.VectorSet(self.maxs, 60, 60, 72); @@ -1258,7 +1258,7 @@ public class M_Boss32 { }; static EntThinkAdapter makron_walk = new EntThinkAdapter() { - public String getID() { return "makron_walk"; } + public String getID() { return "makron_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = makron_move_walk; return true; @@ -1266,7 +1266,7 @@ public class M_Boss32 { }; static EntThinkAdapter makron_run = new EntThinkAdapter() { - public String getID() { return "makron_run"; } + public String getID() { return "makron_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) self.monsterinfo.currentmove = makron_move_stand; @@ -1482,7 +1482,7 @@ public class M_Boss32 { FRAME_active13, makron_frames_sight, makron_run); static EntThinkAdapter makronBFG = new EntThinkAdapter() { - public String getID() { return "makronBFG"; } + public String getID() { return "makronBFG"; } public boolean think(edict_t self) { float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; @@ -1508,7 +1508,7 @@ public class M_Boss32 { }; static EntThinkAdapter MakronSaveloc = new EntThinkAdapter() { - public String getID() { return "MakronSaveloc"; } + public String getID() { return "MakronSaveloc"; } public boolean think(edict_t self) { Math3D.VectorCopy(self.enemy.s.origin, self.pos1); //save for // aiming the @@ -1518,10 +1518,10 @@ public class M_Boss32 { } }; - // FIXME: He's not firing from the proper Z + // FIXME: He's not firing from the proper Z static EntThinkAdapter MakronRailgun = new EntThinkAdapter() { - public String getID() { return "MakronRailgun"; } + public String getID() { return "MakronRailgun"; } public boolean think(edict_t self) { float[] start = { 0, 0, 0 }; float[] dir = { 0, 0, 0 }; @@ -1543,10 +1543,10 @@ public class M_Boss32 { } }; - // FIXME: This is all wrong. He's not firing at the proper angles. + // FIXME: This is all wrong. He's not firing at the proper angles. static EntThinkAdapter MakronHyperblaster = new EntThinkAdapter() { - public String getID() { return "MakronHyperblaster"; } + public String getID() { return "MakronHyperblaster"; } public boolean think(edict_t self) { float[] dir = { 0, 0, 0 }; float[] vec = { 0, 0, 0 }; @@ -1589,7 +1589,7 @@ public class M_Boss32 { }; static EntPainAdapter makron_pain = new EntPainAdapter() { - public String getID() { return "makron_pain"; } + public String getID() { return "makron_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { if (self.health < (self.max_health / 2)) @@ -1632,7 +1632,7 @@ public class M_Boss32 { }; static EntInteractAdapter makron_sight = new EntInteractAdapter() { - public String getID() { return "makron_sight"; } + public String getID() { return "makron_sight"; } public boolean interact(edict_t self, edict_t other) { self.monsterinfo.currentmove = makron_move_sight; return true; @@ -1640,7 +1640,7 @@ public class M_Boss32 { }; static EntThinkAdapter makron_attack = new EntThinkAdapter() { - public String getID() { return "makron_attack"; } + public String getID() { return "makron_attack"; } public boolean think(edict_t self) { float[] vec = { 0, 0, 0 }; float r; @@ -1665,7 +1665,7 @@ public class M_Boss32 { */ static EntThinkAdapter makron_torso_think = new EntThinkAdapter() { - public String getID() { return "makron_torso_think"; } + public String getID() { return "makron_torso_think"; } public boolean think(edict_t self) { if (++self.s.frame < 365) self.nextthink = GameBase.level.time + Defines.FRAMETIME; @@ -1678,7 +1678,7 @@ public class M_Boss32 { }; static EntThinkAdapter makron_torso = new EntThinkAdapter() { - public String getID() { return "makron_torso"; } + public String getID() { return "makron_torso"; } public boolean think(edict_t ent) { ent.movetype = Defines.MOVETYPE_NONE; ent.solid = Defines.SOLID_NOT; @@ -1696,7 +1696,7 @@ public class M_Boss32 { }; static EntDieAdapter makron_die = new EntDieAdapter() { - public String getID() { return "makron_die"; } + public String getID() { return "makron_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { edict_t tempent; @@ -1727,7 +1727,7 @@ public class M_Boss32 { if (self.deadflag == Defines.DEAD_DEAD) return; - // regular death + // regular death GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_death, 1, Defines.ATTN_NONE, 0); self.deadflag = Defines.DEAD_DEAD; @@ -1744,7 +1744,7 @@ public class M_Boss32 { }; static EntThinkAdapter Makron_CheckAttack = new EntThinkAdapter() { - public String getID() { return "Makron_CheckAttack"; } + public String getID() { return "Makron_CheckAttack"; } public boolean think(edict_t self) { float[] spot1 = { 0, 0, 0 }, spot2 = { 0, 0, 0 }; float[] temp = { 0, 0, 0 }; @@ -1785,7 +1785,7 @@ public class M_Boss32 { return true; } - // missile attack + // missile attack if (null != self.monsterinfo.attack) return false; @@ -1897,7 +1897,7 @@ public class M_Boss32 { * ================= */ static EntThinkAdapter MakronSpawn = new EntThinkAdapter() { - public String getID() { return "MakronSpawn"; } + public String getID() { return "MakronSpawn"; } public boolean think(edict_t self) { float[] vec = { 0, 0, 0 }; @@ -1922,7 +1922,7 @@ public class M_Boss32 { }; static EntThinkAdapter MakronToss = new EntThinkAdapter() { - public String getID() { return "MakronToss"; } + public String getID() { return "MakronToss"; } public boolean think(edict_t self) { edict_t ent; @@ -1936,7 +1936,7 @@ public class M_Boss32 { }; // - // monster_makron + // monster_makron // static void MakronPrecache() { @@ -1994,7 +1994,7 @@ public class M_Boss32 { GameBase.gi.linkentity(self); - // self.monsterinfo.currentmove = &makron_move_stand; + // self.monsterinfo.currentmove = &makron_move_stand; self.monsterinfo.currentmove = makron_move_sight; self.monsterinfo.scale = MODEL_SCALE; diff --git a/src/main/java/lwjake2/game/monsters/M_Brain.java b/src/main/java/lwjake2/game/monsters/M_Brain.java index 9d35942..5f333a5 100644 --- a/src/main/java/lwjake2/game/monsters/M_Brain.java +++ b/src/main/java/lwjake2/game/monsters/M_Brain.java @@ -512,7 +512,7 @@ public class M_Brain { static int sound_melee3; static EntInteractAdapter brain_sight = new EntInteractAdapter() { - public String getID() { return "brain_sight"; } + public String getID() { return "brain_sight"; } public boolean interact(edict_t self, edict_t other) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1, Defines.ATTN_NORM, 0); @@ -521,7 +521,7 @@ public class M_Brain { }; static EntThinkAdapter brain_search = new EntThinkAdapter() { - public String getID() { return "brain_search"; } + public String getID() { return "brain_search"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search, 1, Defines.ATTN_NORM, 0); @@ -530,7 +530,7 @@ public class M_Brain { }; // - // STAND + // STAND // static mframe_t brain_frames_stand[] = new mframe_t[] { @@ -569,7 +569,7 @@ public class M_Brain { brain_frames_stand, null); static EntThinkAdapter brain_stand = new EntThinkAdapter() { - public String getID() { return "brain_stand"; } + public String getID() { return "brain_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = brain_move_stand; return true; @@ -577,7 +577,7 @@ public class M_Brain { }; // - // IDLE + // IDLE // static mframe_t brain_frames_idle[] = new mframe_t[] { @@ -616,7 +616,7 @@ public class M_Brain { brain_frames_idle, brain_stand); static EntThinkAdapter brain_idle = new EntThinkAdapter() { - public String getID() { return "brain_idle"; } + public String getID() { return "brain_idle"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_AUTO, sound_idle3, 1, Defines.ATTN_IDLE, 0); @@ -626,7 +626,7 @@ public class M_Brain { }; // - // WALK + // WALK // static mframe_t brain_frames_walk1[] = new mframe_t[] { new mframe_t(GameAI.ai_walk, 7, null), @@ -644,7 +644,7 @@ public class M_Brain { static mmove_t brain_move_walk1 = new mmove_t(FRAME_walk101, FRAME_walk111, brain_frames_walk1, null); - // walk2 is FUBAR, do not use + // walk2 is FUBAR, do not use /* * # if 0 void brain_walk2_cycle(edict_t self) { if (random() > 0.1) * self.monsterinfo.nextframe= FRAME_walk220; } @@ -677,22 +677,22 @@ public class M_Brain { * # endif */ static EntThinkAdapter brain_walk = new EntThinkAdapter() { - public String getID() { return "brain_walk"; } + public String getID() { return "brain_walk"; } public boolean think(edict_t self) { - // if (random() <= 0.5) + // if (random() <= 0.5) self.monsterinfo.currentmove = brain_move_walk1; - // else - // self.monsterinfo.currentmove = &brain_move_walk2; + // else + // self.monsterinfo.currentmove = &brain_move_walk2; return true; } }; // - // DUCK + // DUCK // static EntThinkAdapter brain_duck_down = new EntThinkAdapter() { - public String getID() { return "brain_duck_down"; } + public String getID() { return "brain_duck_down"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_DUCKED) != 0) @@ -706,7 +706,7 @@ public class M_Brain { }; static EntThinkAdapter brain_duck_hold = new EntThinkAdapter() { - public String getID() { return "brain_duck_hold"; } + public String getID() { return "brain_duck_hold"; } public boolean think(edict_t self) { if (GameBase.level.time >= self.monsterinfo.pausetime) self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME; @@ -717,7 +717,7 @@ public class M_Brain { }; static EntThinkAdapter brain_duck_up = new EntThinkAdapter() { - public String getID() { return "brain_duck_up"; } + public String getID() { return "brain_duck_up"; } public boolean think(edict_t self) { self.monsterinfo.aiflags &= ~Defines.AI_DUCKED; self.maxs[2] += 32; @@ -728,7 +728,7 @@ public class M_Brain { }; static EntDodgeAdapter brain_dodge = new EntDodgeAdapter() { - public String getID() { return "brain_dodge"; } + public String getID() { return "brain_dodge"; } public void dodge(edict_t self, edict_t attacker, float eta) { if (Lib.random() > 0.25) return; @@ -750,7 +750,7 @@ public class M_Brain { new mframe_t(GameAI.ai_move, 0, null) }; static EntThinkAdapter brain_dead = new EntThinkAdapter() { - public String getID() { return "brain_dead"; } + public String getID() { return "brain_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -16, -16, -24); Math3D.VectorSet(self.maxs, 16, 16, -8); @@ -789,11 +789,11 @@ public class M_Brain { FRAME_death118, brain_frames_death1, brain_dead); // - // MELEE + // MELEE // static EntThinkAdapter brain_swing_right = new EntThinkAdapter() { - public String getID() { return "brain_swing_right"; } + public String getID() { return "brain_swing_right"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_BODY, sound_melee1, 1, Defines.ATTN_NORM, 0); @@ -802,7 +802,7 @@ public class M_Brain { }; static EntThinkAdapter brain_hit_right = new EntThinkAdapter() { - public String getID() { return "brain_hit_right"; } + public String getID() { return "brain_hit_right"; } public boolean think(edict_t self) { float[] aim = { 0, 0, 0 }; @@ -815,7 +815,7 @@ public class M_Brain { }; static EntThinkAdapter brain_swing_left = new EntThinkAdapter() { - public String getID() { return "brain_swing_left"; } + public String getID() { return "brain_swing_left"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_BODY, sound_melee2, 1, Defines.ATTN_NORM, 0); @@ -825,7 +825,7 @@ public class M_Brain { }; static EntThinkAdapter brain_hit_left = new EntThinkAdapter() { - public String getID() { return "brain_hit_left"; } + public String getID() { return "brain_hit_left"; } public boolean think(edict_t self) { float[] aim = { 0, 0, 0 }; @@ -839,7 +839,7 @@ public class M_Brain { }; static EntThinkAdapter brain_chest_open = new EntThinkAdapter() { - public String getID() { return "brain_chest_open"; } + public String getID() { return "brain_chest_open"; } public boolean think(edict_t self) { self.spawnflags &= ~65536; self.monsterinfo.power_armor_type = Defines.POWER_ARMOR_NONE; @@ -850,7 +850,7 @@ public class M_Brain { }; static EntThinkAdapter brain_tentacle_attack = new EntThinkAdapter() { - public String getID() { return "brain_tentacle_attack"; } + public String getID() { return "brain_tentacle_attack"; } public boolean think(edict_t self) { float[] aim = { 0, 0, 0 }; @@ -886,7 +886,7 @@ public class M_Brain { new mframe_t(GameAI.ai_charge, -11, null) }; static EntThinkAdapter brain_chest_closed = new EntThinkAdapter() { - public String getID() { return "brain_chest_closed"; } + public String getID() { return "brain_chest_closed"; } public boolean think(edict_t self) { self.monsterinfo.power_armor_type = Defines.POWER_ARMOR_SCREEN; @@ -918,7 +918,7 @@ public class M_Brain { new mframe_t(GameAI.ai_charge, -6, null) }; static EntThinkAdapter brain_melee = new EntThinkAdapter() { - public String getID() { return "brain_melee"; } + public String getID() { return "brain_melee"; } public boolean think(edict_t self) { if (Lib.random() <= 0.5) self.monsterinfo.currentmove = brain_move_attack1; @@ -930,7 +930,7 @@ public class M_Brain { }; // - // RUN + // RUN // static mframe_t brain_frames_run[] = new mframe_t[] { @@ -950,7 +950,7 @@ public class M_Brain { brain_frames_run, null); static EntThinkAdapter brain_run = new EntThinkAdapter() { - public String getID() { return "brain_run"; } + public String getID() { return "brain_run"; } public boolean think(edict_t self) { self.monsterinfo.power_armor_type = Defines.POWER_ARMOR_SCREEN; if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) @@ -1039,7 +1039,7 @@ public class M_Brain { brain_frames_duck, brain_run); static EntPainAdapter brain_pain = new EntPainAdapter() { - public String getID() { return "brain_pain"; } + public String getID() { return "brain_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { float r; @@ -1072,7 +1072,7 @@ public class M_Brain { }; static EntDieAdapter brain_die = new EntDieAdapter() { - public String getID() { return "brain_die"; } + public String getID() { return "brain_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { int n; @@ -1080,7 +1080,7 @@ public class M_Brain { self.s.effects = 0; self.monsterinfo.power_armor_type = Defines.POWER_ARMOR_NONE; - // check for gib + // check for gib if (self.health <= self.gib_health) { GameBase.gi .sound(self, Defines.CHAN_VOICE, GameBase.gi @@ -1102,7 +1102,7 @@ public class M_Brain { if (self.deadflag == Defines.DEAD_DEAD) return; - // regular death + // regular death GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_death, 1, Defines.ATTN_NORM, 0); self.deadflag = Defines.DEAD_DEAD; @@ -1163,7 +1163,7 @@ public class M_Brain { self.monsterinfo.walk = brain_walk; self.monsterinfo.run = brain_run; self.monsterinfo.dodge = brain_dodge; - // self.monsterinfo.attack = brain_attack; + // self.monsterinfo.attack = brain_attack; self.monsterinfo.melee = brain_melee; self.monsterinfo.sight = brain_sight; self.monsterinfo.search = brain_search; diff --git a/src/main/java/lwjake2/game/monsters/M_Chick.java b/src/main/java/lwjake2/game/monsters/M_Chick.java index 5bee755..21801bf 100644 --- a/src/main/java/lwjake2/game/monsters/M_Chick.java +++ b/src/main/java/lwjake2/game/monsters/M_Chick.java @@ -647,7 +647,7 @@ public class M_Chick { static int sound_search; static EntThinkAdapter ChickMoan = new EntThinkAdapter() { - public String getID() { return "ChickMoan"; } + public String getID() { return "ChickMoan"; } public boolean think(edict_t self) { if (Lib.random() < 0.5) GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle1, 1, @@ -692,7 +692,7 @@ public class M_Chick { new mframe_t(GameAI.ai_stand, 0, null) }; static EntThinkAdapter chick_stand = new EntThinkAdapter() { - public String getID() { return "chick_stand"; } + public String getID() { return "chick_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = chick_move_stand; return true; @@ -703,7 +703,7 @@ public class M_Chick { FRAME_stand230, chick_frames_fidget, chick_stand); static EntThinkAdapter chick_fidget = new EntThinkAdapter() { - public String getID() { return "chick_fidget"; } + public String getID() { return "chick_fidget"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) return true; @@ -749,7 +749,7 @@ public class M_Chick { FRAME_stand130, chick_frames_stand, null); static EntThinkAdapter chick_run = new EntThinkAdapter() { - public String getID() { return "chick_run"; } + public String getID() { return "chick_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) { self.monsterinfo.currentmove = chick_move_stand; @@ -812,7 +812,7 @@ public class M_Chick { chick_frames_walk, null); static EntThinkAdapter chick_walk = new EntThinkAdapter() { - public String getID() { return "chick_walk"; } + public String getID() { return "chick_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = chick_move_walk; return true; @@ -866,7 +866,7 @@ public class M_Chick { chick_frames_pain3, chick_run); static EntPainAdapter chick_pain = new EntPainAdapter() { - public String getID() { return "chick_pain"; } + public String getID() { return "chick_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { float r; @@ -903,7 +903,7 @@ public class M_Chick { }; static EntThinkAdapter chick_dead = new EntThinkAdapter() { - public String getID() { return "chick_dead"; } + public String getID() { return "chick_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -16, -16, 0); Math3D.VectorSet(self.maxs, 16, 16, 16); @@ -961,13 +961,13 @@ public class M_Chick { FRAME_death112, chick_frames_death1, chick_dead); static EntDieAdapter chick_die = new EntDieAdapter() { - public String getID() { return "chick_die"; } + public String getID() { return "chick_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { int n; - // check for gib + // check for gib if (self.health <= self.gib_health) { GameBase.gi .sound(self, Defines.CHAN_VOICE, GameBase.gi @@ -989,7 +989,7 @@ public class M_Chick { if (self.deadflag == Defines.DEAD_DEAD) return; - // regular death + // regular death self.deadflag = Defines.DEAD_DEAD; self.takedamage = Defines.DAMAGE_YES; @@ -1008,7 +1008,7 @@ public class M_Chick { }; static EntThinkAdapter chick_duck_down = new EntThinkAdapter() { - public String getID() { return "chick_duck_down"; } + public String getID() { return "chick_duck_down"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_DUCKED) != 0) return true; @@ -1022,7 +1022,7 @@ public class M_Chick { }; static EntThinkAdapter chick_duck_hold = new EntThinkAdapter() { - public String getID() { return "chick_duck_hold"; } + public String getID() { return "chick_duck_hold"; } public boolean think(edict_t self) { if (GameBase.level.time >= self.monsterinfo.pausetime) self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME; @@ -1033,7 +1033,7 @@ public class M_Chick { }; static EntThinkAdapter chick_duck_up = new EntThinkAdapter() { - public String getID() { return "chick_duck_up"; } + public String getID() { return "chick_duck_up"; } public boolean think(edict_t self) { self.monsterinfo.aiflags &= ~Defines.AI_DUCKED; self.maxs[2] += 32; @@ -1056,7 +1056,7 @@ public class M_Chick { chick_frames_duck, chick_run); static EntDodgeAdapter chick_dodge = new EntDodgeAdapter() { - public String getID() { return "chick_dodge"; } + public String getID() { return "chick_dodge"; } public void dodge(edict_t self, edict_t attacker, float eta) { if (Lib.random() > 0.25) return; @@ -1070,7 +1070,7 @@ public class M_Chick { }; static EntThinkAdapter ChickSlash = new EntThinkAdapter() { - public String getID() { return "ChickSlash"; } + public String getID() { return "ChickSlash"; } public boolean think(edict_t self) { float[] aim = { 0, 0, 0 }; @@ -1083,7 +1083,7 @@ public class M_Chick { }; static EntThinkAdapter ChickRocket = new EntThinkAdapter() { - public String getID() { return "ChickRocket"; } + public String getID() { return "ChickRocket"; } public boolean think(edict_t self) { float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; float[] start = { 0, 0, 0 }; @@ -1107,7 +1107,7 @@ public class M_Chick { }; static EntThinkAdapter Chick_PreAttack1 = new EntThinkAdapter() { - public String getID() { return "Chick_PreAttack1"; } + public String getID() { return "Chick_PreAttack1"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_missile_prelaunch, 1, Defines.ATTN_NORM, 0); @@ -1116,7 +1116,7 @@ public class M_Chick { }; static EntThinkAdapter ChickReload = new EntThinkAdapter() { - public String getID() { return "ChickReload"; } + public String getID() { return "ChickReload"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_missile_reload, 1, Defines.ATTN_NORM, 0); @@ -1125,7 +1125,7 @@ public class M_Chick { }; static EntThinkAdapter chick_attack1 = new EntThinkAdapter() { - public String getID() { return "chick_attack1"; } + public String getID() { return "chick_attack1"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = chick_move_attack1; return true; @@ -1133,7 +1133,7 @@ public class M_Chick { }; static EntThinkAdapter chick_rerocket = new EntThinkAdapter() { - public String getID() { return "chick_rerocket"; } + public String getID() { return "chick_rerocket"; } public boolean think(edict_t self) { if (self.enemy.health > 0) { if (GameUtil.range(self, self.enemy) > Defines.RANGE_MELEE) @@ -1196,7 +1196,7 @@ public class M_Chick { FRAME_attak132, chick_frames_end_attack1, chick_run); static EntThinkAdapter chick_reslash = new EntThinkAdapter() { - public String getID() { return "chick_reslash"; } + public String getID() { return "chick_reslash"; } public boolean think(edict_t self) { if (self.enemy.health > 0) { if (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE) @@ -1237,7 +1237,7 @@ public class M_Chick { FRAME_attak216, chick_frames_end_slash, chick_run); static EntThinkAdapter chick_slash = new EntThinkAdapter() { - public String getID() { return "chick_slash"; } + public String getID() { return "chick_slash"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = chick_move_slash; return true; @@ -1253,7 +1253,7 @@ public class M_Chick { FRAME_attak203, chick_frames_start_slash, chick_slash); static EntThinkAdapter chick_melee = new EntThinkAdapter() { - public String getID() { return "chick_melee"; } + public String getID() { return "chick_melee"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = chick_move_start_slash; return true; @@ -1261,7 +1261,7 @@ public class M_Chick { }; static EntThinkAdapter chick_attack = new EntThinkAdapter() { - public String getID() { return "chick_attack"; } + public String getID() { return "chick_attack"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = chick_move_start_attack1; return true; @@ -1269,7 +1269,7 @@ public class M_Chick { }; static EntInteractAdapter chick_sight = new EntInteractAdapter() { - public String getID() { return "chick_sight"; } + public String getID() { return "chick_sight"; } public boolean interact(edict_t self, edict_t other) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1, Defines.ATTN_NORM, 0); diff --git a/src/main/java/lwjake2/game/monsters/M_Flash.java b/src/main/java/lwjake2/game/monsters/M_Flash.java index 4f7327e..eb233cb 100644 --- a/src/main/java/lwjake2/game/monsters/M_Flash.java +++ b/src/main/java/lwjake2/game/monsters/M_Flash.java @@ -20,471 +20,471 @@ package lwjake2.game.monsters; public class M_Flash { - // m_flash.c + // m_flash.c - // this file is included in both the game dll and quake2, - // the game needs it to source shot locations, the client - // needs it to position muzzle flashes + // this file is included in both the game dll and quake2, + // the game needs it to source shot locations, the client + // needs it to position muzzle flashes public static float monster_flash_offset[][] = { - // flash 0 is not used + // flash 0 is not used { 0.0f, 0.0f, 0.0f }, - // MZ2_TANK_BLASTER_1 1 + // MZ2_TANK_BLASTER_1 1 { 20.7f, -18.5f, 28.7f }, - // MZ2_TANK_BLASTER_2 2 + // MZ2_TANK_BLASTER_2 2 { 16.6f, -21.5f, 30.1f }, - // MZ2_TANK_BLASTER_3 3 + // MZ2_TANK_BLASTER_3 3 { 11.8f, -23.9f, 32.1f }, - // MZ2_TANK_MACHINEGUN_1 4 + // MZ2_TANK_MACHINEGUN_1 4 { 22.9f, -0.7f, 25.3f }, - // MZ2_TANK_MACHINEGUN_2 5 + // MZ2_TANK_MACHINEGUN_2 5 { 22.2f, 6.2f, 22.3f }, - // MZ2_TANK_MACHINEGUN_3 6 + // MZ2_TANK_MACHINEGUN_3 6 { 19.4f, 13.1f, 18.6f }, - // MZ2_TANK_MACHINEGUN_4 7 + // MZ2_TANK_MACHINEGUN_4 7 { 19.4f, 18.8f, 18.6f }, - // MZ2_TANK_MACHINEGUN_5 8 + // MZ2_TANK_MACHINEGUN_5 8 { 17.9f, 25.0f, 18.6f }, - // MZ2_TANK_MACHINEGUN_6 9 + // MZ2_TANK_MACHINEGUN_6 9 { 14.1f, 30.5f, 20.6f }, - // MZ2_TANK_MACHINEGUN_7 10 + // MZ2_TANK_MACHINEGUN_7 10 { 9.3f, 35.3f, 22.1f }, - // MZ2_TANK_MACHINEGUN_8 11 + // MZ2_TANK_MACHINEGUN_8 11 { 4.7f, 38.4f, 22.1f }, - // MZ2_TANK_MACHINEGUN_9 12 + // MZ2_TANK_MACHINEGUN_9 12 { -1.1f, 40.4f, 24.1f }, - // MZ2_TANK_MACHINEGUN_10 13 + // MZ2_TANK_MACHINEGUN_10 13 { -6.5f, 41.2f, 24.1f }, - // MZ2_TANK_MACHINEGUN_11 14 + // MZ2_TANK_MACHINEGUN_11 14 { 3.2f, 40.1f, 24.7f }, - // MZ2_TANK_MACHINEGUN_12 15 + // MZ2_TANK_MACHINEGUN_12 15 { 11.7f, 36.7f, 26.0f }, - // MZ2_TANK_MACHINEGUN_13 16 + // MZ2_TANK_MACHINEGUN_13 16 { 18.9f, 31.3f, 26.0f }, - // MZ2_TANK_MACHINEGUN_14 17 + // MZ2_TANK_MACHINEGUN_14 17 { 24.4f, 24.4f, 26.4f }, - // MZ2_TANK_MACHINEGUN_15 18 + // MZ2_TANK_MACHINEGUN_15 18 { 27.1f, 17.1f, 27.2f }, - // MZ2_TANK_MACHINEGUN_16 19 + // MZ2_TANK_MACHINEGUN_16 19 { 28.5f, 9.1f, 28.0f }, - // MZ2_TANK_MACHINEGUN_17 20 + // MZ2_TANK_MACHINEGUN_17 20 { 27.1f, 2.2f, 28.0f }, - // MZ2_TANK_MACHINEGUN_18 21 + // MZ2_TANK_MACHINEGUN_18 21 { 24.9f, -2.8f, 28.0f }, - // MZ2_TANK_MACHINEGUN_19 22 + // MZ2_TANK_MACHINEGUN_19 22 { 21.6f, -7.0f, 26.4f }, - // MZ2_TANK_ROCKET_1 23 + // MZ2_TANK_ROCKET_1 23 { 6.2f, 29.1f, 49.1f }, - // MZ2_TANK_ROCKET_2 24 + // MZ2_TANK_ROCKET_2 24 { 6.9f, 23.8f, 49.1f }, - // MZ2_TANK_ROCKET_3 25 + // MZ2_TANK_ROCKET_3 25 { 8.3f, 17.8f, 49.5f }, - // MZ2_INFANTRY_MACHINEGUN_1 26 + // MZ2_INFANTRY_MACHINEGUN_1 26 { 26.6f, 7.1f, 13.1f }, - // MZ2_INFANTRY_MACHINEGUN_2 27 + // MZ2_INFANTRY_MACHINEGUN_2 27 { 18.2f, 7.5f, 15.4f }, - // MZ2_INFANTRY_MACHINEGUN_3 28 + // MZ2_INFANTRY_MACHINEGUN_3 28 { 17.2f, 10.3f, 17.9f }, - // MZ2_INFANTRY_MACHINEGUN_4 29 + // MZ2_INFANTRY_MACHINEGUN_4 29 { 17.0f, 12.8f, 20.1f }, - // MZ2_INFANTRY_MACHINEGUN_5 30 + // MZ2_INFANTRY_MACHINEGUN_5 30 { 15.1f, 14.1f, 21.8f }, - // MZ2_INFANTRY_MACHINEGUN_6 31 + // MZ2_INFANTRY_MACHINEGUN_6 31 { 11.8f, 17.2f, 23.1f }, - // MZ2_INFANTRY_MACHINEGUN_7 32 + // MZ2_INFANTRY_MACHINEGUN_7 32 { 11.4f, 20.2f, 21.0f }, - // MZ2_INFANTRY_MACHINEGUN_8 33 + // MZ2_INFANTRY_MACHINEGUN_8 33 { 9.0f, 23.0f, 18.9f }, - // MZ2_INFANTRY_MACHINEGUN_9 34 + // MZ2_INFANTRY_MACHINEGUN_9 34 { 13.9f, 18.6f, 17.7f }, - // MZ2_INFANTRY_MACHINEGUN_10 35 + // MZ2_INFANTRY_MACHINEGUN_10 35 { 15.4f, 15.6f, 15.8f }, - // MZ2_INFANTRY_MACHINEGUN_11 36 + // MZ2_INFANTRY_MACHINEGUN_11 36 { 10.2f, 15.2f, 25.1f }, - // MZ2_INFANTRY_MACHINEGUN_12 37 + // MZ2_INFANTRY_MACHINEGUN_12 37 { -1.9f, 15.1f, 28.2f }, - // MZ2_INFANTRY_MACHINEGUN_13 38 + // MZ2_INFANTRY_MACHINEGUN_13 38 { -12.4f, 13.0f, 20.2f }, - // MZ2_SOLDIER_BLASTER_1 39 + // MZ2_SOLDIER_BLASTER_1 39 { 10.6f * 1.2f, 7.7f * 1.2f, 7.8f * 1.2f }, - // MZ2_SOLDIER_BLASTER_2 40 + // MZ2_SOLDIER_BLASTER_2 40 { 21.1f * 1.2f, 3.6f * 1.2f, 19.0f * 1.2f }, - // MZ2_SOLDIER_SHOTGUN_1 41 + // MZ2_SOLDIER_SHOTGUN_1 41 { 10.6f * 1.2f, 7.7f * 1.2f, 7.8f * 1.2f }, - // MZ2_SOLDIER_SHOTGUN_2 42 + // MZ2_SOLDIER_SHOTGUN_2 42 { 21.1f * 1.2f, 3.6f * 1.2f, 19.0f * 1.2f }, - // MZ2_SOLDIER_MACHINEGUN_1 43 + // MZ2_SOLDIER_MACHINEGUN_1 43 { 10.6f * 1.2f, 7.7f * 1.2f, 7.8f * 1.2f }, - // MZ2_SOLDIER_MACHINEGUN_2 44 + // MZ2_SOLDIER_MACHINEGUN_2 44 { 21.1f * 1.2f, 3.6f * 1.2f, 19.0f * 1.2f }, - // MZ2_GUNNER_MACHINEGUN_1 45 + // MZ2_GUNNER_MACHINEGUN_1 45 { 30.1f * 1.15f, 3.9f * 1.15f, 19.6f * 1.15f }, - // MZ2_GUNNER_MACHINEGUN_2 46 + // MZ2_GUNNER_MACHINEGUN_2 46 { 29.1f * 1.15f, 2.5f * 1.15f, 20.7f * 1.15f }, - // MZ2_GUNNER_MACHINEGUN_3 47 + // MZ2_GUNNER_MACHINEGUN_3 47 { 28.2f * 1.15f, 2.5f * 1.15f, 22.2f * 1.15f }, - // MZ2_GUNNER_MACHINEGUN_4 48 + // MZ2_GUNNER_MACHINEGUN_4 48 { 28.2f * 1.15f, 3.6f * 1.15f, 22.0f * 1.15f }, - // MZ2_GUNNER_MACHINEGUN_5 49 + // MZ2_GUNNER_MACHINEGUN_5 49 { 26.9f * 1.15f, 2.0f * 1.15f, 23.4f * 1.15f }, - // MZ2_GUNNER_MACHINEGUN_6 50 + // MZ2_GUNNER_MACHINEGUN_6 50 { 26.5f * 1.15f, 0.6f * 1.15f, 20.8f * 1.15f }, - // MZ2_GUNNER_MACHINEGUN_7 51 + // MZ2_GUNNER_MACHINEGUN_7 51 { 26.9f * 1.15f, 0.5f * 1.15f, 21.5f * 1.15f }, - // MZ2_GUNNER_MACHINEGUN_8 52 + // MZ2_GUNNER_MACHINEGUN_8 52 { 29.0f * 1.15f, 2.4f * 1.15f, 19.5f * 1.15f }, - // MZ2_GUNNER_GRENADE_1 53 + // MZ2_GUNNER_GRENADE_1 53 { 4.6f * 1.15f, -16.8f * 1.15f, 7.3f * 1.15f }, - // MZ2_GUNNER_GRENADE_2 54 + // MZ2_GUNNER_GRENADE_2 54 { 4.6f * 1.15f, -16.8f * 1.15f, 7.3f * 1.15f }, - // MZ2_GUNNER_GRENADE_3 55 + // MZ2_GUNNER_GRENADE_3 55 { 4.6f * 1.15f, -16.8f * 1.15f, 7.3f * 1.15f }, - // MZ2_GUNNER_GRENADE_4 56 + // MZ2_GUNNER_GRENADE_4 56 { 4.6f * 1.15f, -16.8f * 1.15f, 7.3f * 1.15f }, - // MZ2_CHICK_ROCKET_1 57 - // -24.8f, -9.0f, 39.0f}, + // MZ2_CHICK_ROCKET_1 57 + // -24.8f, -9.0f, 39.0f}, { 24.8f, -9.0f, 39.0f }, // PGM - this was incorrect in Q2 - // MZ2_FLYER_BLASTER_1 58 + // MZ2_FLYER_BLASTER_1 58 { 12.1f, 13.4f, -14.5f }, - // MZ2_FLYER_BLASTER_2 59 + // MZ2_FLYER_BLASTER_2 59 { 12.1f, -7.4f, -14.5f }, - // MZ2_MEDIC_BLASTER_1 60 + // MZ2_MEDIC_BLASTER_1 60 { 12.1f, 5.4f, 16.5f }, - // MZ2_GLADIATOR_RAILGUN_1 61 + // MZ2_GLADIATOR_RAILGUN_1 61 { 30.0f, 18.0f, 28.0f }, - // MZ2_HOVER_BLASTER_1 62 + // MZ2_HOVER_BLASTER_1 62 { 32.5f, -0.8f, 10.0f }, - // MZ2_ACTOR_MACHINEGUN_1 63 + // MZ2_ACTOR_MACHINEGUN_1 63 { 18.4f, 7.4f, 9.6f }, - // MZ2_SUPERTANK_MACHINEGUN_1 64 + // MZ2_SUPERTANK_MACHINEGUN_1 64 { 30.0f, 30.0f, 88.5f }, - // MZ2_SUPERTANK_MACHINEGUN_2 65 + // MZ2_SUPERTANK_MACHINEGUN_2 65 { 30.0f, 30.0f, 88.5f }, - // MZ2_SUPERTANK_MACHINEGUN_3 66 + // MZ2_SUPERTANK_MACHINEGUN_3 66 { 30.0f, 30.0f, 88.5f }, - // MZ2_SUPERTANK_MACHINEGUN_4 67 + // MZ2_SUPERTANK_MACHINEGUN_4 67 { 30.0f, 30.0f, 88.5f }, - // MZ2_SUPERTANK_MACHINEGUN_5 68 + // MZ2_SUPERTANK_MACHINEGUN_5 68 { 30.0f, 30.0f, 88.5f }, - // MZ2_SUPERTANK_MACHINEGUN_6 69 + // MZ2_SUPERTANK_MACHINEGUN_6 69 { 30.0f, 30.0f, 88.5f }, - // MZ2_SUPERTANK_ROCKET_1 70 + // MZ2_SUPERTANK_ROCKET_1 70 { 16.0f, -22.5f, 91.2f }, - // MZ2_SUPERTANK_ROCKET_2 71 + // MZ2_SUPERTANK_ROCKET_2 71 { 16.0f, -33.4f, 86.7f }, - // MZ2_SUPERTANK_ROCKET_3 72 + // MZ2_SUPERTANK_ROCKET_3 72 { 16.0f, -42.8f, 83.3f }, - // --- Start Xian Stuff --- - // MZ2_BOSS2_MACHINEGUN_L1 73 + // --- Start Xian Stuff --- + // MZ2_BOSS2_MACHINEGUN_L1 73 { 32f, -40f, 70f }, - // MZ2_BOSS2_MACHINEGUN_L2 74 + // MZ2_BOSS2_MACHINEGUN_L2 74 { 32f, -40f, 70f }, - // MZ2_BOSS2_MACHINEGUN_L3 75 + // MZ2_BOSS2_MACHINEGUN_L3 75 { 32f, -40f, 70f }, - // MZ2_BOSS2_MACHINEGUN_L4 76 + // MZ2_BOSS2_MACHINEGUN_L4 76 { 32f, -40f, 70f }, - // MZ2_BOSS2_MACHINEGUN_L5 77 + // MZ2_BOSS2_MACHINEGUN_L5 77 { 32f, -40f, 70f }, - // --- End Xian Stuff + // --- End Xian Stuff - // MZ2_BOSS2_ROCKET_1 78 + // MZ2_BOSS2_ROCKET_1 78 { 22.0f, 16.0f, 10.0f }, - // MZ2_BOSS2_ROCKET_2 79 + // MZ2_BOSS2_ROCKET_2 79 { 22.0f, 8.0f, 10.0f }, - // MZ2_BOSS2_ROCKET_3 80 + // MZ2_BOSS2_ROCKET_3 80 { 22.0f, -8.0f, 10.0f }, - // MZ2_BOSS2_ROCKET_4 81 + // MZ2_BOSS2_ROCKET_4 81 { 22.0f, -16.0f, 10.0f }, - // MZ2_FLOAT_BLASTER_1 82 + // MZ2_FLOAT_BLASTER_1 82 { 32.5f, -0.8f, 10f }, - // MZ2_SOLDIER_BLASTER_3 83 + // MZ2_SOLDIER_BLASTER_3 83 { 20.8f * 1.2f, 10.1f * 1.2f, -2.7f * 1.2f }, - // MZ2_SOLDIER_SHOTGUN_3 84 + // MZ2_SOLDIER_SHOTGUN_3 84 { 20.8f * 1.2f, 10.1f * 1.2f, -2.7f * 1.2f }, - // MZ2_SOLDIER_MACHINEGUN_3 85 + // MZ2_SOLDIER_MACHINEGUN_3 85 { 20.8f * 1.2f, 10.1f * 1.2f, -2.7f * 1.2f }, - // MZ2_SOLDIER_BLASTER_4 86 + // MZ2_SOLDIER_BLASTER_4 86 { 7.6f * 1.2f, 9.3f * 1.2f, 0.8f * 1.2f }, - // MZ2_SOLDIER_SHOTGUN_4 87 + // MZ2_SOLDIER_SHOTGUN_4 87 { 7.6f * 1.2f, 9.3f * 1.2f, 0.8f * 1.2f }, - // MZ2_SOLDIER_MACHINEGUN_4 88 + // MZ2_SOLDIER_MACHINEGUN_4 88 { 7.6f * 1.2f, 9.3f * 1.2f, 0.8f * 1.2f }, - // MZ2_SOLDIER_BLASTER_5 89 + // MZ2_SOLDIER_BLASTER_5 89 { 30.5f * 1.2f, 9.9f * 1.2f, -18.7f * 1.2f }, - // MZ2_SOLDIER_SHOTGUN_5 90 + // MZ2_SOLDIER_SHOTGUN_5 90 { 30.5f * 1.2f, 9.9f * 1.2f, -18.7f * 1.2f }, - // MZ2_SOLDIER_MACHINEGUN_5 91 + // MZ2_SOLDIER_MACHINEGUN_5 91 { 30.5f * 1.2f, 9.9f * 1.2f, -18.7f * 1.2f }, - // MZ2_SOLDIER_BLASTER_6 92 + // MZ2_SOLDIER_BLASTER_6 92 { 27.6f * 1.2f, 3.4f * 1.2f, -10.4f * 1.2f }, - // MZ2_SOLDIER_SHOTGUN_6 93 + // MZ2_SOLDIER_SHOTGUN_6 93 { 27.6f * 1.2f, 3.4f * 1.2f, -10.4f * 1.2f }, - // MZ2_SOLDIER_MACHINEGUN_6 94 + // MZ2_SOLDIER_MACHINEGUN_6 94 { 27.6f * 1.2f, 3.4f * 1.2f, -10.4f * 1.2f }, - // MZ2_SOLDIER_BLASTER_7 95 + // MZ2_SOLDIER_BLASTER_7 95 { 28.9f * 1.2f, 4.6f * 1.2f, -8.1f * 1.2f }, - // MZ2_SOLDIER_SHOTGUN_7 96 + // MZ2_SOLDIER_SHOTGUN_7 96 { 28.9f * 1.2f, 4.6f * 1.2f, -8.1f * 1.2f }, - // MZ2_SOLDIER_MACHINEGUN_7 97 + // MZ2_SOLDIER_MACHINEGUN_7 97 { 28.9f * 1.2f, 4.6f * 1.2f, -8.1f * 1.2f }, - // MZ2_SOLDIER_BLASTER_8 98 - // 34.5f * 1.2f, 9.6f * 1.2f, 6.1f * 1.2f}, + // MZ2_SOLDIER_BLASTER_8 98 + // 34.5f * 1.2f, 9.6f * 1.2f, 6.1f * 1.2f}, { 31.5f * 1.2f, 9.6f * 1.2f, 10.1f * 1.2f }, - // MZ2_SOLDIER_SHOTGUN_8 99 + // MZ2_SOLDIER_SHOTGUN_8 99 { 34.5f * 1.2f, 9.6f * 1.2f, 6.1f * 1.2f }, - // MZ2_SOLDIER_MACHINEGUN_8 100 + // MZ2_SOLDIER_MACHINEGUN_8 100 { 34.5f * 1.2f, 9.6f * 1.2f, 6.1f * 1.2f }, - // --- Xian shit below --- - // MZ2_MAKRON_BFG 101 + // --- Xian shit below --- + // MZ2_MAKRON_BFG 101 { 17f, -19.5f, 62.9f }, - // MZ2_MAKRON_BLASTER_1 102 + // MZ2_MAKRON_BLASTER_1 102 { -3.6f, -24.1f, 59.5f }, - // MZ2_MAKRON_BLASTER_2 103 + // MZ2_MAKRON_BLASTER_2 103 { -1.6f, -19.3f, 59.5f }, - // MZ2_MAKRON_BLASTER_3 104 + // MZ2_MAKRON_BLASTER_3 104 { -0.1f, -14.4f, 59.5f }, - // MZ2_MAKRON_BLASTER_4 105 + // MZ2_MAKRON_BLASTER_4 105 { 2.0f, -7.6f, 59.5f }, - // MZ2_MAKRON_BLASTER_5 106 + // MZ2_MAKRON_BLASTER_5 106 { 3.4f, 1.3f, 59.5f }, - // MZ2_MAKRON_BLASTER_6 107 + // MZ2_MAKRON_BLASTER_6 107 { 3.7f, 11.1f, 59.5f }, - // MZ2_MAKRON_BLASTER_7 108 + // MZ2_MAKRON_BLASTER_7 108 { -0.3f, 22.3f, 59.5f }, - // MZ2_MAKRON_BLASTER_8 109 + // MZ2_MAKRON_BLASTER_8 109 { -6f, 33f, 59.5f }, - // MZ2_MAKRON_BLASTER_9 110 + // MZ2_MAKRON_BLASTER_9 110 { -9.3f, 36.4f, 59.5f }, - // MZ2_MAKRON_BLASTER_10 111 + // MZ2_MAKRON_BLASTER_10 111 { -7f, 35f, 59.5f }, - // MZ2_MAKRON_BLASTER_11 112 + // MZ2_MAKRON_BLASTER_11 112 { -2.1f, 29f, 59.5f }, - // MZ2_MAKRON_BLASTER_12 113 + // MZ2_MAKRON_BLASTER_12 113 { 3.9f, 17.3f, 59.5f }, - // MZ2_MAKRON_BLASTER_13 114 + // MZ2_MAKRON_BLASTER_13 114 { 6.1f, 5.8f, 59.5f }, - // MZ2_MAKRON_BLASTER_14 115 + // MZ2_MAKRON_BLASTER_14 115 { 5.9f, -4.4f, 59.5f }, - // MZ2_MAKRON_BLASTER_15 116 + // MZ2_MAKRON_BLASTER_15 116 { 4.2f, -14.1f, 59.5f }, - // MZ2_MAKRON_BLASTER_16 117 + // MZ2_MAKRON_BLASTER_16 117 { 2.4f, -18.8f, 59.5f }, - // MZ2_MAKRON_BLASTER_17 118 + // MZ2_MAKRON_BLASTER_17 118 { -1.8f, -25.5f, 59.5f }, - // MZ2_MAKRON_RAILGUN_1 119 + // MZ2_MAKRON_RAILGUN_1 119 { -17.3f, 7.8f, 72.4f }, - // MZ2_JORG_MACHINEGUN_L1 120 + // MZ2_JORG_MACHINEGUN_L1 120 { 78.5f, -47.1f, 96f }, - // MZ2_JORG_MACHINEGUN_L2 121 + // MZ2_JORG_MACHINEGUN_L2 121 { 78.5f, -47.1f, 96f }, - // MZ2_JORG_MACHINEGUN_L3 122 + // MZ2_JORG_MACHINEGUN_L3 122 { 78.5f, -47.1f, 96f }, - // MZ2_JORG_MACHINEGUN_L4 123 + // MZ2_JORG_MACHINEGUN_L4 123 { 78.5f, -47.1f, 96f }, - // MZ2_JORG_MACHINEGUN_L5 124 + // MZ2_JORG_MACHINEGUN_L5 124 { 78.5f, -47.1f, 96f }, - // MZ2_JORG_MACHINEGUN_L6 125 + // MZ2_JORG_MACHINEGUN_L6 125 { 78.5f, -47.1f, 96f }, - // MZ2_JORG_MACHINEGUN_R1 126 + // MZ2_JORG_MACHINEGUN_R1 126 { 78.5f, 46.7f, 96f }, - // MZ2_JORG_MACHINEGUN_R2 127 + // MZ2_JORG_MACHINEGUN_R2 127 { 78.5f, 46.7f, 96f }, - // MZ2_JORG_MACHINEGUN_R3 128 + // MZ2_JORG_MACHINEGUN_R3 128 { 78.5f, 46.7f, 96f }, - // MZ2_JORG_MACHINEGUN_R4 129 + // MZ2_JORG_MACHINEGUN_R4 129 { 78.5f, 46.7f, 96f }, - // MZ2_JORG_MACHINEGUN_R5 130 + // MZ2_JORG_MACHINEGUN_R5 130 { 78.5f, 46.7f, 96f }, - // MZ2_JORG_MACHINEGUN_R6 131 + // MZ2_JORG_MACHINEGUN_R6 131 { 78.5f, 46.7f, 96f }, - // MZ2_JORG_BFG_1 132 + // MZ2_JORG_BFG_1 132 { 6.3f, -9f, 111.2f }, - // MZ2_BOSS2_MACHINEGUN_R1 73 + // MZ2_BOSS2_MACHINEGUN_R1 73 { 32f, 40f, 70f }, - // MZ2_BOSS2_MACHINEGUN_R2 74 + // MZ2_BOSS2_MACHINEGUN_R2 74 { 32f, 40f, 70f }, - // MZ2_BOSS2_MACHINEGUN_R3 75 + // MZ2_BOSS2_MACHINEGUN_R3 75 { 32f, 40f, 70f }, - // MZ2_BOSS2_MACHINEGUN_R4 76 + // MZ2_BOSS2_MACHINEGUN_R4 76 { 32f, 40f, 70f }, - // MZ2_BOSS2_MACHINEGUN_R5 77 + // MZ2_BOSS2_MACHINEGUN_R5 77 { 32f, 40f, 70f }, - // --- End Xian Shit --- + // --- End Xian Shit --- - // ROGUE - // note that the above really ends at 137 - // carrier machineguns - // MZ2_CARRIER_MACHINEGUN_L1 + // ROGUE + // note that the above really ends at 137 + // carrier machineguns + // MZ2_CARRIER_MACHINEGUN_L1 { 56f, -32f, 32f }, - // MZ2_CARRIER_MACHINEGUN_R1 + // MZ2_CARRIER_MACHINEGUN_R1 { 56f, 32f, 32f }, - // MZ2_CARRIER_GRENADE + // MZ2_CARRIER_GRENADE { 42f, 24f, 50f }, - // MZ2_TURRET_MACHINEGUN 141 + // MZ2_TURRET_MACHINEGUN 141 { 16f, 0f, 0f }, - // MZ2_TURRET_ROCKET 142 + // MZ2_TURRET_ROCKET 142 { 16f, 0f, 0f }, - // MZ2_TURRET_BLASTER 143 + // MZ2_TURRET_BLASTER 143 { 16f, 0f, 0f }, - // MZ2_STALKER_BLASTER 144 + // MZ2_STALKER_BLASTER 144 { 24f, 0f, 6f }, - // MZ2_DAEDALUS_BLASTER 145 + // MZ2_DAEDALUS_BLASTER 145 { 32.5f, -0.8f, 10.0f }, - // MZ2_MEDIC_BLASTER_2 146 + // MZ2_MEDIC_BLASTER_2 146 { 12.1f, 5.4f, 16.5f }, - // MZ2_CARRIER_RAILGUN 147 + // MZ2_CARRIER_RAILGUN 147 { 32f, 0f, 6f }, - // MZ2_WIDOW_DISRUPTOR 148 + // MZ2_WIDOW_DISRUPTOR 148 { 57.72f, 14.50f, 88.81f }, - // MZ2_WIDOW_BLASTER 149 + // MZ2_WIDOW_BLASTER 149 { 56f, 32f, 32f }, - // MZ2_WIDOW_RAIL 150 + // MZ2_WIDOW_RAIL 150 { 62f, -20f, 84f }, - // MZ2_WIDOW_PLASMABEAM 151 // PMM - not used! + // MZ2_WIDOW_PLASMABEAM 151 // PMM - not used! { 32f, 0f, 6f }, - // MZ2_CARRIER_MACHINEGUN_L2 152 + // MZ2_CARRIER_MACHINEGUN_L2 152 { 61f, -32f, 12f }, - // MZ2_CARRIER_MACHINEGUN_R2 153 + // MZ2_CARRIER_MACHINEGUN_R2 153 { 61f, 32f, 12f }, - // MZ2_WIDOW_RAIL_LEFT 154 + // MZ2_WIDOW_RAIL_LEFT 154 { 17f, -62f, 91f }, - // MZ2_WIDOW_RAIL_RIGHT 155 + // MZ2_WIDOW_RAIL_RIGHT 155 { 68f, 12f, 86f }, - // MZ2_WIDOW_BLASTER_SWEEP1 156 pmm - the sweeps need to be in + // MZ2_WIDOW_BLASTER_SWEEP1 156 pmm - the sweeps need to be in // sequential order { 47.5f, 56f, 89f }, - // MZ2_WIDOW_BLASTER_SWEEP2 157 + // MZ2_WIDOW_BLASTER_SWEEP2 157 { 54f, 52f, 91f }, - // MZ2_WIDOW_BLASTER_SWEEP3 158 + // MZ2_WIDOW_BLASTER_SWEEP3 158 { 58f, 40f, 91f }, - // MZ2_WIDOW_BLASTER_SWEEP4 159 + // MZ2_WIDOW_BLASTER_SWEEP4 159 { 68f, 30f, 88f }, - // MZ2_WIDOW_BLASTER_SWEEP5 160 + // MZ2_WIDOW_BLASTER_SWEEP5 160 { 74f, 20f, 88f }, - // MZ2_WIDOW_BLASTER_SWEEP6 161 + // MZ2_WIDOW_BLASTER_SWEEP6 161 { 73f, 11f, 87f }, - // MZ2_WIDOW_BLASTER_SWEEP7 162 + // MZ2_WIDOW_BLASTER_SWEEP7 162 { 73f, 3f, 87f }, - // MZ2_WIDOW_BLASTER_SWEEP8 163 + // MZ2_WIDOW_BLASTER_SWEEP8 163 { 70f, -12f, 87f }, - // MZ2_WIDOW_BLASTER_SWEEP9 164 + // MZ2_WIDOW_BLASTER_SWEEP9 164 { 67f, -20f, 90f }, - // MZ2_WIDOW_BLASTER_100 165 + // MZ2_WIDOW_BLASTER_100 165 { -20f, 76f, 90f }, - // MZ2_WIDOW_BLASTER_90 166 + // MZ2_WIDOW_BLASTER_90 166 { -8f, 74f, 90f }, - // MZ2_WIDOW_BLASTER_80 167 + // MZ2_WIDOW_BLASTER_80 167 { 0f, 72f, 90f }, - // MZ2_WIDOW_BLASTER_70 168 d06 + // MZ2_WIDOW_BLASTER_70 168 d06 { 10f, 71f, 89f }, - // MZ2_WIDOW_BLASTER_60 169 d07 + // MZ2_WIDOW_BLASTER_60 169 d07 { 23f, 70f, 87f }, - // MZ2_WIDOW_BLASTER_50 170 d08 + // MZ2_WIDOW_BLASTER_50 170 d08 { 32f, 64f, 85f }, - // MZ2_WIDOW_BLASTER_40 171 + // MZ2_WIDOW_BLASTER_40 171 { 40f, 58f, 84f }, - // MZ2_WIDOW_BLASTER_30 172 d10 + // MZ2_WIDOW_BLASTER_30 172 d10 { 48f, 50f, 83f }, - // MZ2_WIDOW_BLASTER_20 173 + // MZ2_WIDOW_BLASTER_20 173 { 54f, 42f, 82f }, - // MZ2_WIDOW_BLASTER_10 174 d12 + // MZ2_WIDOW_BLASTER_10 174 d12 { 56f, 34f, 82f }, - // MZ2_WIDOW_BLASTER_0 175 + // MZ2_WIDOW_BLASTER_0 175 { 58f, 26f, 82f }, - // MZ2_WIDOW_BLASTER_10L 176 d14 + // MZ2_WIDOW_BLASTER_10L 176 d14 { 60f, 16f, 82f }, - // MZ2_WIDOW_BLASTER_20L 177 + // MZ2_WIDOW_BLASTER_20L 177 { 59f, 6f, 81f }, - // MZ2_WIDOW_BLASTER_30L 178 d16 + // MZ2_WIDOW_BLASTER_30L 178 d16 { 58f, -2f, 80f }, - // MZ2_WIDOW_BLASTER_40L 179 + // MZ2_WIDOW_BLASTER_40L 179 { 57f, -10f, 79f }, - // MZ2_WIDOW_BLASTER_50L 180 d18 + // MZ2_WIDOW_BLASTER_50L 180 d18 { 54f, -18f, 78f }, - // MZ2_WIDOW_BLASTER_60L 181 + // MZ2_WIDOW_BLASTER_60L 181 { 42f, -32f, 80f }, - // MZ2_WIDOW_BLASTER_70L 182 d20 + // MZ2_WIDOW_BLASTER_70L 182 d20 { 36f, -40f, 78f }, - // MZ2_WIDOW_RUN_1 183 + // MZ2_WIDOW_RUN_1 183 { 68.4f, 10.88f, 82.08f }, - // MZ2_WIDOW_RUN_2 184 + // MZ2_WIDOW_RUN_2 184 { 68.51f, 8.64f, 85.14f }, - // MZ2_WIDOW_RUN_3 185 + // MZ2_WIDOW_RUN_3 185 { 68.66f, 6.38f, 88.78f }, - // MZ2_WIDOW_RUN_4 186 + // MZ2_WIDOW_RUN_4 186 { 68.73f, 5.1f, 84.47f }, - // MZ2_WIDOW_RUN_5 187 + // MZ2_WIDOW_RUN_5 187 { 68.82f, 4.79f, 80.52f }, - // MZ2_WIDOW_RUN_6 188 + // MZ2_WIDOW_RUN_6 188 { 68.77f, 6.11f, 85.37f }, - // MZ2_WIDOW_RUN_7 189 + // MZ2_WIDOW_RUN_7 189 { 68.67f, 7.99f, 90.24f }, - // MZ2_WIDOW_RUN_8 190 + // MZ2_WIDOW_RUN_8 190 { 68.55f, 9.54f, 87.36f }, - // MZ2_CARRIER_ROCKET_1 191 + // MZ2_CARRIER_ROCKET_1 191 { 0f, 0f, -5f }, - // MZ2_CARRIER_ROCKET_2 192 + // MZ2_CARRIER_ROCKET_2 192 { 0f, 0f, -5f }, - // MZ2_CARRIER_ROCKET_3 193 + // MZ2_CARRIER_ROCKET_3 193 { 0f, 0f, -5f }, - // MZ2_CARRIER_ROCKET_4 194 + // MZ2_CARRIER_ROCKET_4 194 { 0f, 0f, -5f }, - // MZ2_WIDOW2_BEAMER_1 195 - // 72.13f, -17.63f, 93.77f}, + // MZ2_WIDOW2_BEAMER_1 195 + // 72.13f, -17.63f, 93.77f}, { 69.00f, -17.63f, 93.77f }, - // MZ2_WIDOW2_BEAMER_2 196 - // 71.46f, -17.08f, 89.82f}, + // MZ2_WIDOW2_BEAMER_2 196 + // 71.46f, -17.08f, 89.82f}, { 69.00f, -17.08f, 89.82f }, - // MZ2_WIDOW2_BEAMER_3 197 - // 71.47f, -18.40f, 90.70f}, + // MZ2_WIDOW2_BEAMER_3 197 + // 71.47f, -18.40f, 90.70f}, { 69.00f, -18.40f, 90.70f }, - // MZ2_WIDOW2_BEAMER_4 198 - // 71.96f, -18.34f, 94.32f}, + // MZ2_WIDOW2_BEAMER_4 198 + // 71.96f, -18.34f, 94.32f}, { 69.00f, -18.34f, 94.32f }, - // MZ2_WIDOW2_BEAMER_5 199 - // 72.25f, -18.30f, 97.98f}, + // MZ2_WIDOW2_BEAMER_5 199 + // 72.25f, -18.30f, 97.98f}, { 69.00f, -18.30f, 97.98f }, - // MZ2_WIDOW2_BEAM_SWEEP_1 200 + // MZ2_WIDOW2_BEAM_SWEEP_1 200 { 45.04f, -59.02f, 92.24f }, - // MZ2_WIDOW2_BEAM_SWEEP_2 201 + // MZ2_WIDOW2_BEAM_SWEEP_2 201 { 50.68f, -54.70f, 91.96f }, - // MZ2_WIDOW2_BEAM_SWEEP_3 202 + // MZ2_WIDOW2_BEAM_SWEEP_3 202 { 56.57f, -47.72f, 91.65f }, - // MZ2_WIDOW2_BEAM_SWEEP_4 203 + // MZ2_WIDOW2_BEAM_SWEEP_4 203 { 61.75f, -38.75f, 91.38f }, - // MZ2_WIDOW2_BEAM_SWEEP_5 204 + // MZ2_WIDOW2_BEAM_SWEEP_5 204 { 65.55f, -28.76f, 91.24f }, - // MZ2_WIDOW2_BEAM_SWEEP_6 205 + // MZ2_WIDOW2_BEAM_SWEEP_6 205 { 67.79f, -18.90f, 91.22f }, - // MZ2_WIDOW2_BEAM_SWEEP_7 206 + // MZ2_WIDOW2_BEAM_SWEEP_7 206 { 68.60f, -9.52f, 91.23f }, - // MZ2_WIDOW2_BEAM_SWEEP_8 207 + // MZ2_WIDOW2_BEAM_SWEEP_8 207 { 68.08f, 0.18f, 91.32f }, - // MZ2_WIDOW2_BEAM_SWEEP_9 208 + // MZ2_WIDOW2_BEAM_SWEEP_9 208 { 66.14f, 9.79f, 91.44f }, - // MZ2_WIDOW2_BEAM_SWEEP_10 209 + // MZ2_WIDOW2_BEAM_SWEEP_10 209 { 62.77f, 18.91f, 91.65f }, - // MZ2_WIDOW2_BEAM_SWEEP_11 210 + // MZ2_WIDOW2_BEAM_SWEEP_11 210 { 58.29f, 27.11f, 92.00f }, - // end of table + // end of table { 0.0f, 0.0f, 0.0f } }; } \ No newline at end of file diff --git a/src/main/java/lwjake2/game/monsters/M_Flipper.java b/src/main/java/lwjake2/game/monsters/M_Flipper.java index ebb3eff..270bade 100644 --- a/src/main/java/lwjake2/game/monsters/M_Flipper.java +++ b/src/main/java/lwjake2/game/monsters/M_Flipper.java @@ -36,7 +36,7 @@ import lwjake2.util.Math3D; public class M_Flipper { - // This file generated by ModelGen - Do NOT Modify + // This file generated by ModelGen - Do NOT Modify public final static int FRAME_flpbit01 = 0; @@ -383,7 +383,7 @@ public class M_Flipper { FRAME_flphor01, flipper_frames_stand, null); static EntThinkAdapter flipper_stand = new EntThinkAdapter() { - public String getID() { return "flipper_stand"; } + public String getID() { return "flipper_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = flipper_move_stand; return true; @@ -427,7 +427,7 @@ public class M_Flipper { FRAME_flpver29, flipper_frames_run, null); static EntThinkAdapter flipper_run_loop = new EntThinkAdapter() { - public String getID() { return "flipper_run_loop"; } + public String getID() { return "flipper_run_loop"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = flipper_move_run_loop; return true; @@ -446,7 +446,7 @@ public class M_Flipper { FRAME_flpver06, flipper_frames_run_start, flipper_run_loop); static EntThinkAdapter flipper_run = new EntThinkAdapter() { - public String getID() { return "flipper_run"; } + public String getID() { return "flipper_run"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = flipper_move_run_start; return true; @@ -484,7 +484,7 @@ public class M_Flipper { FRAME_flphor24, flipper_frames_walk, null); static EntThinkAdapter flipper_walk = new EntThinkAdapter() { - public String getID() { return "flipper_walk"; } + public String getID() { return "flipper_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = flipper_move_walk; return true; @@ -502,7 +502,7 @@ public class M_Flipper { FRAME_flphor05, flipper_frames_start_run, null); static EntThinkAdapter flipper_start_run = new EntThinkAdapter() { - public String getID() { return "flipper_start_run"; } + public String getID() { return "flipper_start_run"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = flipper_move_start_run; return true; @@ -530,7 +530,7 @@ public class M_Flipper { FRAME_flppn205, flipper_frames_pain1, flipper_run); static EntThinkAdapter flipper_bite = new EntThinkAdapter() { - public String getID() { return "flipper_bite"; } + public String getID() { return "flipper_bite"; } public boolean think(edict_t self) { float[] aim = { 0, 0, 0 }; @@ -541,7 +541,7 @@ public class M_Flipper { }; static EntThinkAdapter flipper_preattack = new EntThinkAdapter() { - public String getID() { return "flipper_preattack"; } + public String getID() { return "flipper_preattack"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_chomp, 1, @@ -576,7 +576,7 @@ public class M_Flipper { FRAME_flpbit20, flipper_frames_attack, flipper_run); static EntThinkAdapter flipper_melee = new EntThinkAdapter() { - public String getID() { return "flipper_melee"; } + public String getID() { return "flipper_melee"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = flipper_move_attack; return true; @@ -584,7 +584,7 @@ public class M_Flipper { }; static EntPainAdapter flipper_pain = new EntPainAdapter() { - public String getID() { return "flipper_pain"; } + public String getID() { return "flipper_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { int n; @@ -614,7 +614,7 @@ public class M_Flipper { }; static EntThinkAdapter flipper_dead = new EntThinkAdapter() { - public String getID() { return "flipper_dead"; } + public String getID() { return "flipper_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -16, -16, -24); Math3D.VectorSet(self.maxs, 16, 16, -8); @@ -688,7 +688,7 @@ public class M_Flipper { FRAME_flpdth56, flipper_frames_death, flipper_dead); static EntInteractAdapter flipper_sight = new EntInteractAdapter() { - public String getID() { return "flipper_sight"; } + public String getID() { return "flipper_sight"; } public boolean interact(edict_t self, edict_t other) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1, Defines.ATTN_NORM, 0); @@ -697,13 +697,13 @@ public class M_Flipper { }; static EntDieAdapter flipper_die = new EntDieAdapter() { - public String getID() { return "flipper_die"; } + public String getID() { return "flipper_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { int n; - // check for gib + // check for gib if (self.health <= self.gib_health) { GameBase.gi .sound(self, Defines.CHAN_VOICE, GameBase.gi @@ -725,7 +725,7 @@ public class M_Flipper { if (self.deadflag == Defines.DEAD_DEAD) return; - // regular death + // regular death GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_death, 1, Defines.ATTN_NORM, 0); self.deadflag = Defines.DEAD_DEAD; diff --git a/src/main/java/lwjake2/game/monsters/M_Float.java b/src/main/java/lwjake2/game/monsters/M_Float.java index 180b4bd..cdba843 100644 --- a/src/main/java/lwjake2/game/monsters/M_Float.java +++ b/src/main/java/lwjake2/game/monsters/M_Float.java @@ -40,7 +40,7 @@ import lwjake2.util.Math3D; public class M_Float { - // This file generated by ModelGen - Do NOT Modify + // This file generated by ModelGen - Do NOT Modify public final static int FRAME_actvat01 = 0; @@ -555,7 +555,7 @@ public class M_Float { static int sound_sight; static EntInteractAdapter floater_sight = new EntInteractAdapter() { - public String getID() { return "floater_sight"; } + public String getID() { return "floater_sight"; } public boolean interact(edict_t self, edict_t other) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1, Defines.ATTN_NORM, 0); @@ -564,7 +564,7 @@ public class M_Float { }; static EntThinkAdapter floater_idle = new EntThinkAdapter() { - public String getID() { return "floater_idle"; } + public String getID() { return "floater_idle"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1, Defines.ATTN_IDLE, 0); @@ -573,7 +573,7 @@ public class M_Float { }; static EntThinkAdapter floater_fire_blaster = new EntThinkAdapter() { - public String getID() { return "floater_fire_blaster"; } + public String getID() { return "floater_fire_blaster"; } public boolean think(edict_t self) { float[] start = { 0, 0, 0 }; float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; @@ -717,7 +717,7 @@ public class M_Float { FRAME_stand252, floater_frames_stand2, null); static EntThinkAdapter floater_stand = new EntThinkAdapter() { - public String getID() { return "floater_stand"; } + public String getID() { return "floater_stand"; } public boolean think(edict_t self) { if (Lib.random() <= 0.5) self.monsterinfo.currentmove = floater_move_stand1; @@ -763,7 +763,7 @@ public class M_Float { FRAME_actvat31, floater_frames_activate, null); static EntThinkAdapter floater_run = new EntThinkAdapter() { - public String getID() { return "floater_run"; } + public String getID() { return "floater_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) @@ -800,7 +800,7 @@ public class M_Float { static float[] aim = { Defines.MELEE_DISTANCE, 0, 0 }; static EntThinkAdapter floater_wham = new EntThinkAdapter() { - public String getID() { return "floater_wham"; } + public String getID() { return "floater_wham"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_attack3, 1, @@ -831,7 +831,7 @@ public class M_Float { new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), - // -- LOOP Ends + // -- LOOP Ends new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), @@ -843,7 +843,7 @@ public class M_Float { FRAME_attak225, floater_frames_attack2, floater_run); static EntThinkAdapter floater_zap = new EntThinkAdapter() { - public String getID() { return "floater_zap"; } + public String getID() { return "floater_zap"; } public boolean think(edict_t self) { float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; float[] origin = { 0, 0, 0 }; @@ -858,7 +858,7 @@ public class M_Float { Math3D.VectorSet(offset, 18.5f, -0.9f, 10f); Math3D.G_ProjectSource(self.s.origin, offset, forward, right, origin); - // G_ProjectSource (self.s.origin, + // G_ProjectSource (self.s.origin, // monster_flash_offset[flash_number], forward, right, origin); GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_attack2, 1, @@ -890,7 +890,7 @@ public class M_Float { new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, floater_zap), - // -- LOOP Starts + // -- LOOP Starts new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), @@ -911,7 +911,7 @@ public class M_Float { new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), - // -- LOOP Ends + // -- LOOP Ends new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), @@ -937,7 +937,7 @@ public class M_Float { new mframe_t(GameAI.ai_move, 0, null) }; static EntThinkAdapter floater_dead = new EntThinkAdapter() { - public String getID() { return "floater_dead"; } + public String getID() { return "floater_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -16, -16, -24); Math3D.VectorSet(self.maxs, 16, 16, -8); @@ -1109,7 +1109,7 @@ public class M_Float { FRAME_stand152, floater_frames_run, null); static EntThinkAdapter floater_walk = new EntThinkAdapter() { - public String getID() { return "floater_walk"; } + public String getID() { return "floater_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = floater_move_walk; return true; @@ -1117,7 +1117,7 @@ public class M_Float { }; static EntThinkAdapter floater_attack = new EntThinkAdapter() { - public String getID() { return "floater_attack"; } + public String getID() { return "floater_attack"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = floater_move_attack1; return true; @@ -1125,7 +1125,7 @@ public class M_Float { }; static EntThinkAdapter floater_melee = new EntThinkAdapter() { - public String getID() { return "floater_melee"; } + public String getID() { return "floater_melee"; } public boolean think(edict_t self) { if (Lib.random() < 0.5) @@ -1137,7 +1137,7 @@ public class M_Float { }; static EntPainAdapter floater_pain = new EntPainAdapter() { - public String getID() { return "floater_pain"; } + public String getID() { return "floater_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { int n; @@ -1166,7 +1166,7 @@ public class M_Float { }; static EntDieAdapter floater_die = new EntDieAdapter() { - public String getID() { return "floater_die"; } + public String getID() { return "floater_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { @@ -1216,7 +1216,7 @@ public class M_Float { self.monsterinfo.stand = floater_stand; self.monsterinfo.walk = floater_walk; self.monsterinfo.run = floater_run; - // self.monsterinfo.dodge = floater_dodge; + // self.monsterinfo.dodge = floater_dodge; self.monsterinfo.attack = floater_attack; self.monsterinfo.melee = floater_melee; self.monsterinfo.sight = floater_sight; diff --git a/src/main/java/lwjake2/game/monsters/M_Flyer.java b/src/main/java/lwjake2/game/monsters/M_Flyer.java index f6f23a6..6ed4a42 100644 --- a/src/main/java/lwjake2/game/monsters/M_Flyer.java +++ b/src/main/java/lwjake2/game/monsters/M_Flyer.java @@ -37,7 +37,7 @@ import lwjake2.util.Lib; import lwjake2.util.Math3D; public class M_Flyer { - // This file generated by ModelGen - Do NOT Modify + // This file generated by ModelGen - Do NOT Modify public final static int ACTION_nothing = 0; @@ -370,7 +370,7 @@ public class M_Flyer { static int sound_die; public static EntInteractAdapter flyer_sight = new EntInteractAdapter() { - public String getID() { return "flyer_sight"; } + public String getID() { return "flyer_sight"; } public boolean interact(edict_t self, edict_t other) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1, Defines.ATTN_NORM, 0); @@ -379,7 +379,7 @@ public class M_Flyer { }; static EntThinkAdapter flyer_idle = new EntThinkAdapter() { - public String getID() { return "flyer_idle"; } + public String getID() { return "flyer_idle"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1, Defines.ATTN_IDLE, 0); @@ -388,7 +388,7 @@ public class M_Flyer { }; static EntThinkAdapter flyer_pop_blades = new EntThinkAdapter() { - public String getID() { return "flyer_pop_blades"; } + public String getID() { return "flyer_pop_blades"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sproing, 1, Defines.ATTN_NORM, 0); @@ -547,7 +547,7 @@ public class M_Flyer { flyer_frames_run, null); static EntThinkAdapter flyer_run = new EntThinkAdapter() { - public String getID() { return "flyer_run"; } + public String getID() { return "flyer_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) self.monsterinfo.currentmove = flyer_move_stand; @@ -558,7 +558,7 @@ public class M_Flyer { }; static EntThinkAdapter flyer_walk = new EntThinkAdapter() { - public String getID() { return "flyer_walk"; } + public String getID() { return "flyer_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = flyer_move_walk; return true; @@ -566,7 +566,7 @@ public class M_Flyer { }; static EntThinkAdapter flyer_stand = new EntThinkAdapter() { - public String getID() { return "flyer_stand"; } + public String getID() { return "flyer_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = flyer_move_stand; return true; @@ -574,7 +574,7 @@ public class M_Flyer { }; static EntThinkAdapter flyer_nextmove = new EntThinkAdapter() { - public String getID() { return "flyer_nextmove"; } + public String getID() { return "flyer_nextmove"; } public boolean think(edict_t self) { if (nextmove == ACTION_attack1) self.monsterinfo.currentmove = flyer_move_start_melee; @@ -610,7 +610,7 @@ public class M_Flyer { flyer_frames_stop, null); static EntThinkAdapter flyer_stop = new EntThinkAdapter() { - public String getID() { return "flyer_stop"; } + public String getID() { return "flyer_stop"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = flyer_move_stop; return true; @@ -618,7 +618,7 @@ public class M_Flyer { }; static EntThinkAdapter flyer_start = new EntThinkAdapter() { - public String getID() { return "flyer_start"; } + public String getID() { return "flyer_start"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = flyer_move_start; return true; @@ -722,7 +722,7 @@ public class M_Flyer { FRAME_bankl07, flyer_frames_bankleft, null); static EntThinkAdapter flyer_fireleft = new EntThinkAdapter() { - public String getID() { return "flyer_fireleft"; } + public String getID() { return "flyer_fireleft"; } public boolean think(edict_t self) { flyer_fire(self, Defines.MZ2_FLYER_BLASTER_1); return true; @@ -730,7 +730,7 @@ public class M_Flyer { }; static EntThinkAdapter flyer_fireright = new EntThinkAdapter() { - public String getID() { return "flyer_fireright"; } + public String getID() { return "flyer_fireright"; } public boolean think(edict_t self) { flyer_fire(self, Defines.MZ2_FLYER_BLASTER_2); return true; @@ -761,7 +761,7 @@ public class M_Flyer { FRAME_attak217, flyer_frames_attack2, flyer_run); static EntThinkAdapter flyer_slash_left = new EntThinkAdapter() { - public String getID() { return "flyer_slash_left"; } + public String getID() { return "flyer_slash_left"; } public boolean think(edict_t self) { float[] aim = { 0, 0, 0 }; @@ -774,7 +774,7 @@ public class M_Flyer { }; static EntThinkAdapter flyer_slash_right = new EntThinkAdapter() { - public String getID() { return "flyer_slash_right"; } + public String getID() { return "flyer_slash_right"; } public boolean think(edict_t self) { float[] aim = { 0, 0, 0 }; @@ -787,7 +787,7 @@ public class M_Flyer { }; static EntThinkAdapter flyer_loop_melee = new EntThinkAdapter() { - public String getID() { return "flyer_loop_melee"; } + public String getID() { return "flyer_loop_melee"; } public boolean think(edict_t self) { /* * if (random() <= 0.5) self.monsterinfo.currentmove = @@ -836,7 +836,7 @@ public class M_Flyer { }; static EntThinkAdapter flyer_check_melee = new EntThinkAdapter() { - public String getID() { return "flyer_check_melee"; } + public String getID() { return "flyer_check_melee"; } public boolean think(edict_t self) { if (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE) if (Lib.random() <= 0.8) @@ -853,7 +853,7 @@ public class M_Flyer { FRAME_attak118, flyer_frames_loop_melee, flyer_check_melee); static EntThinkAdapter flyer_attack = new EntThinkAdapter() { - public String getID() { return "flyer_attack"; } + public String getID() { return "flyer_attack"; } public boolean think(edict_t self) { /* * if (random() <= 0.5) self.monsterinfo.currentmove = @@ -866,7 +866,7 @@ public class M_Flyer { }; static EntThinkAdapter flyer_setstart = new EntThinkAdapter() { - public String getID() { return "flyer_setstart"; } + public String getID() { return "flyer_setstart"; } public boolean think(edict_t self) { nextmove = ACTION_run; self.monsterinfo.currentmove = flyer_move_start; @@ -875,17 +875,17 @@ public class M_Flyer { }; static EntThinkAdapter flyer_melee = new EntThinkAdapter() { - public String getID() { return "flyer_melee"; } + public String getID() { return "flyer_melee"; } public boolean think(edict_t self) { - // flyer.nextmove = ACTION_attack1; - // self.monsterinfo.currentmove = flyer_move_stop; + // flyer.nextmove = ACTION_attack1; + // self.monsterinfo.currentmove = flyer_move_stop; self.monsterinfo.currentmove = flyer_move_start_melee; return true; } }; static EntPainAdapter flyer_pain = new EntPainAdapter() { - public String getID() { return "flyer_pain"; } + public String getID() { return "flyer_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { int n; @@ -918,7 +918,7 @@ public class M_Flyer { }; static EntDieAdapter flyer_die = new EntDieAdapter() { - public String getID() { return "flyer_die"; } + public String getID() { return "flyer_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_die, 1, diff --git a/src/main/java/lwjake2/game/monsters/M_Gladiator.java b/src/main/java/lwjake2/game/monsters/M_Gladiator.java index 4258eaf..e4ee3ca 100644 --- a/src/main/java/lwjake2/game/monsters/M_Gladiator.java +++ b/src/main/java/lwjake2/game/monsters/M_Gladiator.java @@ -38,7 +38,7 @@ import lwjake2.util.Math3D; public class M_Gladiator { - // This file generated by ModelGen - Do NOT Modify + // This file generated by ModelGen - Do NOT Modify public final static int FRAME_stand1 = 0; @@ -243,7 +243,7 @@ public class M_Gladiator { static int sound_sight; static EntThinkAdapter gladiator_idle = new EntThinkAdapter() { - public String getID() { return "gladiator_idle"; } + public String getID() { return "gladiator_idle"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1, @@ -253,7 +253,7 @@ public class M_Gladiator { }; static EntInteractAdapter gladiator_sight = new EntInteractAdapter() { - public String getID() { return "gladiator_sight"; } + public String getID() { return "gladiator_sight"; } public boolean interact(edict_t self, edict_t other) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1, @@ -263,7 +263,7 @@ public class M_Gladiator { }; static EntThinkAdapter gladiator_search = new EntThinkAdapter() { - public String getID() { return "gladiator_search"; } + public String getID() { return "gladiator_search"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search, 1, @@ -273,7 +273,7 @@ public class M_Gladiator { }; static EntThinkAdapter gladiator_cleaver_swing = new EntThinkAdapter() { - public String getID() { return "gladiator_cleaver_swing"; } + public String getID() { return "gladiator_cleaver_swing"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_cleaver_swing, @@ -295,7 +295,7 @@ public class M_Gladiator { FRAME_stand7, gladiator_frames_stand, null); static EntThinkAdapter gladiator_stand = new EntThinkAdapter() { - public String getID() { return "gladiator_stand"; } + public String getID() { return "gladiator_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = gladiator_move_stand; @@ -325,7 +325,7 @@ public class M_Gladiator { gladiator_frames_walk, null); static EntThinkAdapter gladiator_walk = new EntThinkAdapter() { - public String getID() { return "gladiator_walk"; } + public String getID() { return "gladiator_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = gladiator_move_walk; @@ -346,7 +346,7 @@ public class M_Gladiator { gladiator_frames_run, null); static EntThinkAdapter gladiator_run = new EntThinkAdapter() { - public String getID() { return "gladiator_run"; } + public String getID() { return "gladiator_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) @@ -359,7 +359,7 @@ public class M_Gladiator { }; static EntThinkAdapter GaldiatorMelee = new EntThinkAdapter() { - public String getID() { return "GaldiatorMelee"; } + public String getID() { return "GaldiatorMelee"; } public boolean think(edict_t self) { float[] aim = { 0, 0, 0 }; @@ -398,7 +398,7 @@ public class M_Gladiator { FRAME_melee17, gladiator_frames_attack_melee, gladiator_run); static EntThinkAdapter gladiator_melee = new EntThinkAdapter() { - public String getID() { return "gladiator_melee"; } + public String getID() { return "gladiator_melee"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = gladiator_move_attack_melee; @@ -407,7 +407,7 @@ public class M_Gladiator { }; static EntThinkAdapter GladiatorGun = new EntThinkAdapter() { - public String getID() { return "GladiatorGun"; } + public String getID() { return "GladiatorGun"; } public boolean think(edict_t self) { float[] start = { 0, 0, 0 }; @@ -448,7 +448,7 @@ public class M_Gladiator { FRAME_attack9, gladiator_frames_attack_gun, gladiator_run); static EntThinkAdapter gladiator_attack = new EntThinkAdapter() { - public String getID() { return "gladiator_attack"; } + public String getID() { return "gladiator_attack"; } public boolean think(edict_t self) { float range; @@ -495,7 +495,7 @@ public class M_Gladiator { FRAME_painup7, gladiator_frames_pain_air, gladiator_run); static EntPainAdapter gladiator_pain = new EntPainAdapter() { - public String getID() { return "gladiator_pain"; } + public String getID() { return "gladiator_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { if (self.health < (self.max_health / 2)) @@ -529,7 +529,7 @@ public class M_Gladiator { }; static EntThinkAdapter gladiator_dead = new EntThinkAdapter() { - public String getID() { return "gladiator_dead"; } + public String getID() { return "gladiator_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -16, -16, -24); @@ -570,12 +570,12 @@ public class M_Gladiator { FRAME_death22, gladiator_frames_death, gladiator_dead); static EntDieAdapter gladiator_die = new EntDieAdapter() { - public String getID() { return "gladiator_die"; } + public String getID() { return "gladiator_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { int n; - // check for gib + // check for gib if (self.health <= self.gib_health) { GameBase.gi .sound(self, Defines.CHAN_VOICE, GameBase.gi @@ -597,7 +597,7 @@ public class M_Gladiator { if (self.deadflag == Defines.DEAD_DEAD) return; - // regular death + // regular death GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_die, 1, Defines.ATTN_NORM, 0); self.deadflag = Defines.DEAD_DEAD; diff --git a/src/main/java/lwjake2/game/monsters/M_Gunner.java b/src/main/java/lwjake2/game/monsters/M_Gunner.java index 61b3a62..2c14c4d 100644 --- a/src/main/java/lwjake2/game/monsters/M_Gunner.java +++ b/src/main/java/lwjake2/game/monsters/M_Gunner.java @@ -37,7 +37,7 @@ import lwjake2.util.Lib; import lwjake2.util.Math3D; public class M_Gunner { - // This file generated by ModelGen - Do NOT Modify + // This file generated by ModelGen - Do NOT Modify public final static int FRAME_stand01 = 0; @@ -474,7 +474,7 @@ public class M_Gunner { static int sound_sight; static EntThinkAdapter gunner_idlesound = new EntThinkAdapter() { - public String getID() { return "gunner_idlesound"; } + public String getID() { return "gunner_idlesound"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1, Defines.ATTN_IDLE, 0); @@ -483,7 +483,7 @@ public class M_Gunner { }; static EntInteractAdapter gunner_sight = new EntInteractAdapter() { - public String getID() { return "gunner_sight"; } + public String getID() { return "gunner_sight"; } public boolean interact(edict_t self, edict_t other) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1, Defines.ATTN_NORM, 0); @@ -492,7 +492,7 @@ public class M_Gunner { }; static EntThinkAdapter gunner_search = new EntThinkAdapter() { - public String getID() { return "gunner_search"; } + public String getID() { return "gunner_search"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search, 1, Defines.ATTN_NORM, 0); @@ -552,7 +552,7 @@ public class M_Gunner { new mframe_t(GameAI.ai_stand, 0, null) }; static EntThinkAdapter gunner_stand = new EntThinkAdapter() { - public String getID() { return "gunner_stand"; } + public String getID() { return "gunner_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = gunner_move_stand; return true; @@ -563,7 +563,7 @@ public class M_Gunner { FRAME_stand70, gunner_frames_fidget, gunner_stand); static EntThinkAdapter gunner_fidget = new EntThinkAdapter() { - public String getID() { return "gunner_fidget"; } + public String getID() { return "gunner_fidget"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) return true; @@ -627,7 +627,7 @@ public class M_Gunner { gunner_frames_walk, null); static EntThinkAdapter gunner_walk = new EntThinkAdapter() { - public String getID() { return "gunner_walk"; } + public String getID() { return "gunner_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = gunner_move_walk; return true; @@ -648,7 +648,7 @@ public class M_Gunner { gunner_frames_run, null); static EntThinkAdapter gunner_run = new EntThinkAdapter() { - public String getID() { return "gunner_run"; } + public String getID() { return "gunner_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) self.monsterinfo.currentmove = gunner_move_stand; @@ -670,7 +670,7 @@ public class M_Gunner { FRAME_runs06, gunner_frames_runandshoot, null); static EntThinkAdapter gunner_runandshoot = new EntThinkAdapter() { - public String getID() { return "gunner_runandshoot"; } + public String getID() { return "gunner_runandshoot"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = gunner_move_runandshoot; return true; @@ -724,7 +724,7 @@ public class M_Gunner { FRAME_pain118, gunner_frames_pain1, gunner_run); static EntPainAdapter gunner_pain = new EntPainAdapter() { - public String getID() { return "gunner_pain"; } + public String getID() { return "gunner_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { if (self.health < (self.max_health / 2)) self.s.skinnum = 1; @@ -755,7 +755,7 @@ public class M_Gunner { }; static EntThinkAdapter gunner_dead = new EntThinkAdapter() { - public String getID() { return "gunner_dead"; } + public String getID() { return "gunner_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -16, -16, -24); Math3D.VectorSet(self.maxs, 16, 16, -8); @@ -784,12 +784,12 @@ public class M_Gunner { FRAME_death11, gunner_frames_death, gunner_dead); static EntDieAdapter gunner_die = new EntDieAdapter() { - public String getID() { return "gunner_die"; } + public String getID() { return "gunner_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { int n; - // check for gib + // check for gib if (self.health <= self.gib_health) { GameBase.gi .sound(self, Defines.CHAN_VOICE, GameBase.gi @@ -811,7 +811,7 @@ public class M_Gunner { if (self.deadflag == Defines.DEAD_DEAD) return; - // regular death + // regular death GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_death, 1, Defines.ATTN_NORM, 0); self.deadflag = Defines.DEAD_DEAD; @@ -821,7 +821,7 @@ public class M_Gunner { }; static EntThinkAdapter gunner_duck_down = new EntThinkAdapter() { - public String getID() { return "gunner_duck_down"; } + public String getID() { return "gunner_duck_down"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_DUCKED) != 0) return true; @@ -840,7 +840,7 @@ public class M_Gunner { }; static EntThinkAdapter gunner_duck_hold = new EntThinkAdapter() { - public String getID() { return "gunner_duck_hold"; } + public String getID() { return "gunner_duck_hold"; } public boolean think(edict_t self) { if (GameBase.level.time >= self.monsterinfo.pausetime) self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME; @@ -851,7 +851,7 @@ public class M_Gunner { }; static EntThinkAdapter gunner_duck_up = new EntThinkAdapter() { - public String getID() { return "gunner_duck_up"; } + public String getID() { return "gunner_duck_up"; } public boolean think(edict_t self) { self.monsterinfo.aiflags &= ~Defines.AI_DUCKED; self.maxs[2] += 32; @@ -875,7 +875,7 @@ public class M_Gunner { gunner_frames_duck, gunner_run); static EntDodgeAdapter gunner_dodge = new EntDodgeAdapter() { - public String getID() { return "gunner_dodge"; } + public String getID() { return "gunner_dodge"; } public void dodge(edict_t self, edict_t attacker, float eta) { if (Lib.random() > 0.25) return; @@ -888,7 +888,7 @@ public class M_Gunner { }; static EntThinkAdapter gunner_opengun = new EntThinkAdapter() { - public String getID() { return "gunner_opengun"; } + public String getID() { return "gunner_opengun"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_open, 1, Defines.ATTN_IDLE, 0); @@ -897,7 +897,7 @@ public class M_Gunner { }; static EntThinkAdapter GunnerFire = new EntThinkAdapter() { - public String getID() { return "GunnerFire"; } + public String getID() { return "GunnerFire"; } public boolean think(edict_t self) { float[] start = { 0, 0, 0 }; float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; @@ -929,7 +929,7 @@ public class M_Gunner { }; static EntThinkAdapter GunnerGrenade = new EntThinkAdapter() { - public String getID() { return "GunnerGrenade"; } + public String getID() { return "GunnerGrenade"; } public boolean think(edict_t self) { float[] start = { 0, 0, 0 }; float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; @@ -961,7 +961,7 @@ public class M_Gunner { }; static EntThinkAdapter gunner_attack = new EntThinkAdapter() { - public String getID() { return "gunner_attack"; } + public String getID() { return "gunner_attack"; } public boolean think(edict_t self) { if (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE) { self.monsterinfo.currentmove = gunner_move_attack_chain; @@ -976,7 +976,7 @@ public class M_Gunner { }; static EntThinkAdapter gunner_fire_chain = new EntThinkAdapter() { - public String getID() { return "gunner_fire_chain"; } + public String getID() { return "gunner_fire_chain"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = gunner_move_fire_chain; return true; @@ -1006,7 +1006,7 @@ public class M_Gunner { new mframe_t(GameAI.ai_charge, 0, GunnerFire) }; static EntThinkAdapter gunner_refire_chain = new EntThinkAdapter() { - public String getID() { return "gunner_refire_chain"; } + public String getID() { return "gunner_refire_chain"; } public boolean think(edict_t self) { if (self.enemy.health > 0) if (GameUtil.visible(self, self.enemy)) diff --git a/src/main/java/lwjake2/game/monsters/M_Hover.java b/src/main/java/lwjake2/game/monsters/M_Hover.java index b7ea2b6..1f5a6ce 100644 --- a/src/main/java/lwjake2/game/monsters/M_Hover.java +++ b/src/main/java/lwjake2/game/monsters/M_Hover.java @@ -37,7 +37,7 @@ import lwjake2.util.Math3D; public class M_Hover { - // This file generated by ModelGen - Do NOT Modify + // This file generated by ModelGen - Do NOT Modify public final static int FRAME_stand01 = 0; @@ -466,7 +466,7 @@ public class M_Hover { static int sound_search2; static EntThinkAdapter hover_reattack = new EntThinkAdapter() { - public String getID() { return "hover_reattack"; } + public String getID() { return "hover_reattack"; } public boolean think(edict_t self) { if (self.enemy.health > 0) if (GameUtil.visible(self, self.enemy)) @@ -480,7 +480,7 @@ public class M_Hover { }; static EntThinkAdapter hover_fire_blaster = new EntThinkAdapter() { - public String getID() { return "hover_fire_blaster"; } + public String getID() { return "hover_fire_blaster"; } public boolean think(edict_t self) { float[] start = { 0, 0, 0 }; float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; @@ -509,7 +509,7 @@ public class M_Hover { }; static EntThinkAdapter hover_stand = new EntThinkAdapter() { - public String getID() { return "hover_stand"; } + public String getID() { return "hover_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = hover_move_stand; return true; @@ -517,7 +517,7 @@ public class M_Hover { }; static EntThinkAdapter hover_run = new EntThinkAdapter() { - public String getID() { return "hover_run"; } + public String getID() { return "hover_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) self.monsterinfo.currentmove = hover_move_stand; @@ -528,7 +528,7 @@ public class M_Hover { }; static EntThinkAdapter hover_walk = new EntThinkAdapter() { - public String getID() { return "hover_walk"; } + public String getID() { return "hover_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = hover_move_walk; return true; @@ -536,7 +536,7 @@ public class M_Hover { }; static EntThinkAdapter hover_start_attack = new EntThinkAdapter() { - public String getID() { return "hover_start_attack"; } + public String getID() { return "hover_start_attack"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = hover_move_start_attack; return true; @@ -544,7 +544,7 @@ public class M_Hover { }; static EntThinkAdapter hover_attack = new EntThinkAdapter() { - public String getID() { return "hover_attack"; } + public String getID() { return "hover_attack"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = hover_move_attack1; return true; @@ -552,7 +552,7 @@ public class M_Hover { }; static EntPainAdapter hover_pain = new EntPainAdapter() { - public String getID() { return "hover_pain"; } + public String getID() { return "hover_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { if (self.health < (self.max_health / 2)) self.s.skinnum = 1; @@ -584,7 +584,7 @@ public class M_Hover { }; static EntThinkAdapter hover_deadthink = new EntThinkAdapter() { - public String getID() { return "hover_deadthink"; } + public String getID() { return "hover_deadthink"; } public boolean think(edict_t self) { if (null == self.groundentity && GameBase.level.time < self.timestamp) { @@ -597,7 +597,7 @@ public class M_Hover { }; static EntThinkAdapter hover_dead = new EntThinkAdapter() { - public String getID() { return "hover_dead"; } + public String getID() { return "hover_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -16, -16, -24); Math3D.VectorSet(self.maxs, 16, 16, -8); @@ -611,12 +611,12 @@ public class M_Hover { }; static EntDieAdapter hover_die = new EntDieAdapter() { - public String getID() { return "hover_die"; } + public String getID() { return "hover_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { int n; - // check for gib + // check for gib if (self.health <= self.gib_health) { GameBase.gi .sound(self, Defines.CHAN_VOICE, GameBase.gi @@ -638,7 +638,7 @@ public class M_Hover { if (self.deadflag == Defines.DEAD_DEAD) return; - // regular death + // regular death if (Lib.random() < 0.5) GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_death1, 1, Defines.ATTN_NORM, 0); @@ -652,7 +652,7 @@ public class M_Hover { }; static EntInteractAdapter hover_sight = new EntInteractAdapter() { - public String getID() { return "hover_sight"; } + public String getID() { return "hover_sight"; } public boolean interact(edict_t self, edict_t other) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1, Defines.ATTN_NORM, 0); @@ -661,7 +661,7 @@ public class M_Hover { }; static EntThinkAdapter hover_search = new EntThinkAdapter() { - public String getID() { return "hover_search"; } + public String getID() { return "hover_search"; } public boolean think(edict_t self) { if (Lib.random() < 0.5) GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search1, 1, @@ -1067,7 +1067,7 @@ public class M_Hover { self.monsterinfo.stand = hover_stand; self.monsterinfo.walk = hover_walk; self.monsterinfo.run = hover_run; - // self.monsterinfo.dodge = hover_dodge; + // self.monsterinfo.dodge = hover_dodge; self.monsterinfo.attack = hover_start_attack; self.monsterinfo.sight = hover_sight; self.monsterinfo.search = hover_search; diff --git a/src/main/java/lwjake2/game/monsters/M_Infantry.java b/src/main/java/lwjake2/game/monsters/M_Infantry.java index 368c181..c1e9e2b 100644 --- a/src/main/java/lwjake2/game/monsters/M_Infantry.java +++ b/src/main/java/lwjake2/game/monsters/M_Infantry.java @@ -40,7 +40,7 @@ import lwjake2.util.Math3D; public class M_Infantry { - // This file generated by ModelGen - Do NOT Modify + // This file generated by ModelGen - Do NOT Modify public final static int FRAME_gun02 = 0; @@ -508,7 +508,7 @@ public class M_Infantry { FRAME_stand71, infantry_frames_stand, null); public static EntThinkAdapter infantry_stand = new EntThinkAdapter() { - public String getID() { return "infantry_stand"; } + public String getID() { return "infantry_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = infantry_move_stand; return true; @@ -570,7 +570,7 @@ public class M_Infantry { FRAME_stand49, infantry_frames_fidget, infantry_stand); static EntThinkAdapter infantry_fidget = new EntThinkAdapter() { - public String getID() { return "infantry_fidget"; } + public String getID() { return "infantry_fidget"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = infantry_move_fidget; GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1, @@ -597,7 +597,7 @@ public class M_Infantry { infantry_frames_walk, null); static EntThinkAdapter infantry_walk = new EntThinkAdapter() { - public String getID() { return "infantry_walk"; } + public String getID() { return "infantry_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = infantry_move_walk; return true; @@ -618,7 +618,7 @@ public class M_Infantry { infantry_frames_run, null); static EntThinkAdapter infantry_run = new EntThinkAdapter() { - public String getID() { return "infantry_run"; } + public String getID() { return "infantry_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) self.monsterinfo.currentmove = infantry_move_stand; @@ -659,7 +659,7 @@ public class M_Infantry { FRAME_pain210, infantry_frames_pain2, infantry_run); static EntPainAdapter infantry_pain = new EntPainAdapter() { - public String getID() { return "infantry_pain"; } + public String getID() { return "infantry_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { int n; @@ -697,7 +697,7 @@ public class M_Infantry { { 90.0f, 35.0f, 0.0f } }; static EntThinkAdapter InfantryMachineGun = new EntThinkAdapter() { - public String getID() { return "InfantryMachineGun"; } + public String getID() { return "InfantryMachineGun"; } public boolean think(edict_t self) { float[] start = { 0, 0, 0 }, target = { 0, 0, 0 }; float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; @@ -742,7 +742,7 @@ public class M_Infantry { }; static EntInteractAdapter infantry_sight = new EntInteractAdapter() { - public String getID() { return "infantry_sight"; } + public String getID() { return "infantry_sight"; } public boolean interact(edict_t self, edict_t other) { GameBase.gi.sound(self, Defines.CHAN_BODY, sound_sight, 1, Defines.ATTN_NORM, 0); @@ -753,7 +753,7 @@ public class M_Infantry { /// static EntThinkAdapter infantry_dead = new EntThinkAdapter() { - public String getID() { return "infantry_dead"; } + public String getID() { return "infantry_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -16, -16, -24); Math3D.VectorSet(self.maxs, 16, 16, -8); @@ -791,7 +791,7 @@ public class M_Infantry { static mmove_t infantry_move_death1 = new mmove_t(FRAME_death101, FRAME_death120, infantry_frames_death1, infantry_dead); - // Off with his head + // Off with his head static mframe_t infantry_frames_death2[] = new mframe_t[] { new mframe_t(GameAI.ai_move, 0, null), new mframe_t(GameAI.ai_move, 1, null), @@ -837,13 +837,13 @@ public class M_Infantry { FRAME_death309, infantry_frames_death3, infantry_dead); public static EntDieAdapter infantry_die = new EntDieAdapter() { - public String getID() { return "infantry_die"; } + public String getID() { return "infantry_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { int n; - // check for gib + // check for gib if (self.health <= self.gib_health) { GameBase.gi .sound(self, Defines.CHAN_VOICE, GameBase.gi @@ -865,7 +865,7 @@ public class M_Infantry { if (self.deadflag == Defines.DEAD_DEAD) return; - // regular death + // regular death self.deadflag = Defines.DEAD_DEAD; self.takedamage = Defines.DAMAGE_YES; @@ -887,7 +887,7 @@ public class M_Infantry { }; static EntThinkAdapter infantry_duck_down = new EntThinkAdapter() { - public String getID() { return "infantry_duck_down"; } + public String getID() { return "infantry_duck_down"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_DUCKED) != 0) return true; @@ -901,7 +901,7 @@ public class M_Infantry { }; static EntThinkAdapter infantry_duck_hold = new EntThinkAdapter() { - public String getID() { return "infantry_duck_hold"; } + public String getID() { return "infantry_duck_hold"; } public boolean think(edict_t self) { if (GameBase.level.time >= self.monsterinfo.pausetime) self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME; @@ -912,7 +912,7 @@ public class M_Infantry { }; static EntThinkAdapter infantry_duck_up = new EntThinkAdapter() { - public String getID() { return "infantry_duck_up"; } + public String getID() { return "infantry_duck_up"; } public boolean think(edict_t self) { self.monsterinfo.aiflags &= ~Defines.AI_DUCKED; self.maxs[2] += 32; @@ -933,7 +933,7 @@ public class M_Infantry { infantry_frames_duck, infantry_run); static EntDodgeAdapter infantry_dodge = new EntDodgeAdapter() { - public String getID() { return "infantry_dodge"; } + public String getID() { return "infantry_dodge"; } public void dodge(edict_t self, edict_t attacker, float eta) { if (Lib.random() > 0.25) return; @@ -946,7 +946,7 @@ public class M_Infantry { }; static EntThinkAdapter infantry_cock_gun = new EntThinkAdapter() { - public String getID() { return "infantry_cock_gun"; } + public String getID() { return "infantry_cock_gun"; } public boolean think(edict_t self) { int n; @@ -960,7 +960,7 @@ public class M_Infantry { }; static EntThinkAdapter infantry_fire = new EntThinkAdapter() { - public String getID() { return "infantry_fire"; } + public String getID() { return "infantry_fire"; } public boolean think(edict_t self) { InfantryMachineGun.think(self); @@ -993,7 +993,7 @@ public class M_Infantry { FRAME_attak115, infantry_frames_attack1, infantry_run); static EntThinkAdapter infantry_swing = new EntThinkAdapter() { - public String getID() { return "infantry_swing"; } + public String getID() { return "infantry_swing"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_punch_swing, 1, @@ -1003,7 +1003,7 @@ public class M_Infantry { }; static EntThinkAdapter infantry_smack = new EntThinkAdapter() { - public String getID() { return "infantry_smack"; } + public String getID() { return "infantry_smack"; } public boolean think(edict_t self) { float[] aim = { 0, 0, 0 }; @@ -1029,7 +1029,7 @@ public class M_Infantry { FRAME_attak208, infantry_frames_attack2, infantry_run); static EntThinkAdapter infantry_attack = new EntThinkAdapter() { - public String getID() { return "infantry_attack"; } + public String getID() { return "infantry_attack"; } public boolean think(edict_t self) { if (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE) self.monsterinfo.currentmove = infantry_move_attack2; diff --git a/src/main/java/lwjake2/game/monsters/M_Insane.java b/src/main/java/lwjake2/game/monsters/M_Insane.java index be339e3..eedae23 100644 --- a/src/main/java/lwjake2/game/monsters/M_Insane.java +++ b/src/main/java/lwjake2/game/monsters/M_Insane.java @@ -33,7 +33,7 @@ import lwjake2.util.Lib; import lwjake2.util.Math3D; public class M_Insane { - // This file generated by ModelGen - Do NOT Modify + // This file generated by ModelGen - Do NOT Modify public final static int FRAME_stand1 = 0; @@ -610,7 +610,7 @@ public class M_Insane { static int sound_scream[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; static EntThinkAdapter insane_fist = new EntThinkAdapter() { - public String getID() { return "insane_fist"; } + public String getID() { return "insane_fist"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_fist, 1, Defines.ATTN_IDLE, 0); @@ -619,7 +619,7 @@ public class M_Insane { }; static EntThinkAdapter insane_shake = new EntThinkAdapter() { - public String getID() { return "insane_shake"; } + public String getID() { return "insane_shake"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_shake, 1, Defines.ATTN_IDLE, 0); @@ -628,7 +628,7 @@ public class M_Insane { }; static EntThinkAdapter insane_moan = new EntThinkAdapter() { - public String getID() { return "insane_moan"; } + public String getID() { return "insane_moan"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_moan, 1, Defines.ATTN_IDLE, 0); @@ -637,7 +637,7 @@ public class M_Insane { }; static EntThinkAdapter insane_scream = new EntThinkAdapter() { - public String getID() { return "insane_scream"; } + public String getID() { return "insane_scream"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_scream[Lib.rand() % 8], 1, Defines.ATTN_IDLE, 0); @@ -646,7 +646,7 @@ public class M_Insane { }; static EntThinkAdapter insane_cross = new EntThinkAdapter() { - public String getID() { return "insane_cross"; } + public String getID() { return "insane_cross"; } public boolean think(edict_t self) { if (Lib.random() < 0.8) self.monsterinfo.currentmove = insane_move_cross; @@ -657,7 +657,7 @@ public class M_Insane { }; static EntThinkAdapter insane_walk = new EntThinkAdapter() { - public String getID() { return "insane_walk"; } + public String getID() { return "insane_walk"; } public boolean think(edict_t self) { if ((self.spawnflags & 16) != 0) // Hold Ground? if (self.s.frame == FRAME_cr_pain10) { @@ -675,7 +675,7 @@ public class M_Insane { }; static EntThinkAdapter insane_run = new EntThinkAdapter() { - public String getID() { return "insane_run"; } + public String getID() { return "insane_run"; } public boolean think(edict_t self) { if ((self.spawnflags & 16) != 0) // Hold Ground? if (self.s.frame == FRAME_cr_pain10) { @@ -693,12 +693,12 @@ public class M_Insane { }; static EntPainAdapter insane_pain = new EntPainAdapter() { - public String getID() { return "insane_pain"; } + public String getID() { return "insane_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { int l, r; - // if (self.health < (self.max_health / 2)) - // self.s.skinnum = 1; + // if (self.health < (self.max_health / 2)) + // self.s.skinnum = 1; if (GameBase.level.time < self.pain_debounce_time) return; @@ -736,7 +736,7 @@ public class M_Insane { }; static EntThinkAdapter insane_onground = new EntThinkAdapter() { - public String getID() { return "insane_onground"; } + public String getID() { return "insane_onground"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = insane_move_down; return true; @@ -744,9 +744,9 @@ public class M_Insane { }; static EntThinkAdapter insane_checkdown = new EntThinkAdapter() { - public String getID() { return "insane_checkdown"; } + public String getID() { return "insane_checkdown"; } public boolean think(edict_t self) { - // if ( (self.s.frame == FRAME_stand94) || (self.s.frame == + // if ( (self.s.frame == FRAME_stand94) || (self.s.frame == // FRAME_stand65) ) if ((self.spawnflags & 32) != 0) // Always stand return true; @@ -760,9 +760,9 @@ public class M_Insane { }; static EntThinkAdapter insane_checkup = new EntThinkAdapter() { - public String getID() { return "insane_checkup"; } + public String getID() { return "insane_checkup"; } public boolean think(edict_t self) { - // If Hold_Ground and Crawl are set + // If Hold_Ground and Crawl are set if ((self.spawnflags & 4) != 0 && (self.spawnflags & 16) != 0) return true; if (Lib.random() < 0.5) @@ -772,7 +772,7 @@ public class M_Insane { }; static EntThinkAdapter insane_stand = new EntThinkAdapter() { - public String getID() { return "insane_stand"; } + public String getID() { return "insane_stand"; } public boolean think(edict_t self) { if ((self.spawnflags & 8) != 0) // If crucified { @@ -791,7 +791,7 @@ public class M_Insane { }; static EntThinkAdapter insane_dead = new EntThinkAdapter() { - public String getID() { return "insane_dead"; } + public String getID() { return "insane_dead"; } public boolean think(edict_t self) { if ((self.spawnflags & 8) != 0) { self.flags |= Defines.FL_FLY; @@ -808,7 +808,7 @@ public class M_Insane { }; static EntDieAdapter insane_die = new EntDieAdapter() { - public String getID() { return "insane_die"; } + public String getID() { return "insane_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { int n; @@ -1234,7 +1234,7 @@ public class M_Insane { * CRAWL CRUCIFIED STAND_GROUND ALWAYS_STAND */ public static void SP_misc_insane(edict_t self) { - // static int skin = 0; //@@ + // static int skin = 0; //@@ if (GameBase.deathmatch.value != 0) { GameUtil.G_FreeEdict(self); @@ -1278,10 +1278,10 @@ public class M_Insane { self.monsterinfo.aiflags |= Defines.AI_GOOD_GUY; // @@ - // self.s.skinnum = skin; - // skin++; - // if (skin > 12) - // skin = 0; + // self.s.skinnum = skin; + // skin++; + // if (skin > 12) + // skin = 0; GameBase.gi.linkentity(self); diff --git a/src/main/java/lwjake2/game/monsters/M_Medic.java b/src/main/java/lwjake2/game/monsters/M_Medic.java index e16b6e2..4a02bee 100644 --- a/src/main/java/lwjake2/game/monsters/M_Medic.java +++ b/src/main/java/lwjake2/game/monsters/M_Medic.java @@ -40,7 +40,7 @@ import lwjake2.util.Lib; import lwjake2.util.Math3D; public class M_Medic { - // This file generated by ModelGen - Do NOT Modify + // This file generated by ModelGen - Do NOT Modify public final static int FRAME_walk1 = 0; @@ -572,7 +572,7 @@ public class M_Medic { } static EntThinkAdapter medic_idle = new EntThinkAdapter() { - public String getID(){ return "medic_idle"; } + public String getID(){ return "medic_idle"; } public boolean think(edict_t self) { edict_t ent; @@ -591,7 +591,7 @@ public class M_Medic { }; static EntThinkAdapter medic_search = new EntThinkAdapter() { - public String getID(){ return "medic_search"; } + public String getID(){ return "medic_search"; } public boolean think(edict_t self) { edict_t ent; @@ -613,7 +613,7 @@ public class M_Medic { }; static EntInteractAdapter medic_sight = new EntInteractAdapter() { - public String getID(){ return "medic_sight"; } + public String getID(){ return "medic_sight"; } public boolean interact(edict_t self, edict_t other) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1, Defines.ATTN_NORM, 0); @@ -717,7 +717,7 @@ public class M_Medic { medic_frames_stand, null); static EntThinkAdapter medic_stand = new EntThinkAdapter() { - public String getID(){ return "medic_stand"; } + public String getID(){ return "medic_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = medic_move_stand; return true; @@ -742,7 +742,7 @@ public class M_Medic { medic_frames_walk, null); static EntThinkAdapter medic_walk = new EntThinkAdapter() { - public String getID(){ return "medic_walk"; } + public String getID(){ return "medic_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = medic_move_walk; return true; @@ -761,7 +761,7 @@ public class M_Medic { medic_frames_run, null); static EntThinkAdapter medic_run = new EntThinkAdapter() { - public String getID(){ return "medic_run"; } + public String getID(){ return "medic_run"; } public boolean think(edict_t self) { if (0 == (self.monsterinfo.aiflags & Defines.AI_MEDIC)) { edict_t ent; @@ -819,7 +819,7 @@ public class M_Medic { medic_frames_pain2, medic_run); static EntPainAdapter medic_pain = new EntPainAdapter() { - public String getID(){ return "medic_pain"; } + public String getID(){ return "medic_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { if (self.health < (self.max_health / 2)) @@ -846,7 +846,7 @@ public class M_Medic { }; static EntThinkAdapter medic_fire_blaster = new EntThinkAdapter() { - public String getID(){ return "medic_fire_blaster"; } + public String getID(){ return "medic_fire_blaster"; } public boolean think(edict_t self) { float[] start = { 0, 0, 0 }; float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; @@ -881,7 +881,7 @@ public class M_Medic { }; static EntThinkAdapter medic_dead = new EntThinkAdapter() { - public String getID(){ return "medic_dead"; } + public String getID(){ return "medic_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -16, -16, -24); Math3D.VectorSet(self.maxs, 16, 16, -8); @@ -929,7 +929,7 @@ public class M_Medic { medic_frames_death, medic_dead); static EntDieAdapter medic_die = new EntDieAdapter() { - public String getID(){ return "medic_die"; } + public String getID(){ return "medic_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { @@ -939,7 +939,7 @@ public class M_Medic { if ((self.enemy != null) && (self.enemy.owner == self)) self.enemy.owner = null; - // check for gib + // check for gib if (self.health <= self.gib_health) { GameBase.gi .sound(self, Defines.CHAN_VOICE, GameBase.gi @@ -961,7 +961,7 @@ public class M_Medic { if (self.deadflag == Defines.DEAD_DEAD) return; - // regular death + // regular death GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_die, 1, Defines.ATTN_NORM, 0); self.deadflag = Defines.DEAD_DEAD; @@ -972,7 +972,7 @@ public class M_Medic { }; static EntThinkAdapter medic_duck_down = new EntThinkAdapter() { - public String getID(){ return "medic_duck_down"; } + public String getID(){ return "medic_duck_down"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_DUCKED) != 0) return true; @@ -986,7 +986,7 @@ public class M_Medic { }; static EntThinkAdapter medic_duck_hold = new EntThinkAdapter() { - public String getID(){ return "medic_duck_hold"; } + public String getID(){ return "medic_duck_hold"; } public boolean think(edict_t self) { if (GameBase.level.time >= self.monsterinfo.pausetime) self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME; @@ -997,7 +997,7 @@ public class M_Medic { }; static EntThinkAdapter medic_duck_up = new EntThinkAdapter() { - public String getID(){ return "medic_duck_up"; } + public String getID(){ return "medic_duck_up"; } public boolean think(edict_t self) { self.monsterinfo.aiflags &= ~Defines.AI_DUCKED; self.maxs[2] += 32; @@ -1029,7 +1029,7 @@ public class M_Medic { medic_frames_duck, medic_run); static EntDodgeAdapter medic_dodge = new EntDodgeAdapter() { - public String getID(){ return "medic_dodge"; } + public String getID(){ return "medic_dodge"; } public void dodge(edict_t self, edict_t attacker, float eta) { if (Lib.random() > 0.25) return; @@ -1063,7 +1063,7 @@ public class M_Medic { FRAME_attack30, medic_frames_attackHyperBlaster, medic_run); static EntThinkAdapter medic_continue = new EntThinkAdapter() { - public String getID(){ return "medic_continue"; } + public String getID(){ return "medic_continue"; } public boolean think(edict_t self) { if (GameUtil.visible(self, self.enemy)) if (Lib.random() <= 0.95) @@ -1096,7 +1096,7 @@ public class M_Medic { FRAME_attack14, medic_frames_attackBlaster, medic_run); static EntThinkAdapter medic_hook_launch = new EntThinkAdapter() { - public String getID(){ return "medic_hook_launch"; } + public String getID(){ return "medic_hook_launch"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_hook_launch, 1, Defines.ATTN_NORM, 0); @@ -1112,7 +1112,7 @@ public class M_Medic { { 32.7f, -19.7f, 10.4f } }; static EntThinkAdapter medic_cable_attack = new EntThinkAdapter() { - public String getID(){ return "medic_cable_attack"; } + public String getID(){ return "medic_cable_attack"; } public boolean think(edict_t self) { float[] offset = { 0, 0, 0 }, start = { 0, 0, 0 }, end = { 0, 0, 0 }, f = { 0, 0, 0 }, r = { 0, 0, 0 }; @@ -1193,7 +1193,7 @@ public class M_Medic { }; static EntThinkAdapter medic_hook_retract = new EntThinkAdapter() { - public String getID(){ return "medic_hook_retract"; } + public String getID(){ return "medic_hook_retract"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_hook_retract, 1, Defines.ATTN_NORM, 0); @@ -1236,7 +1236,7 @@ public class M_Medic { FRAME_attack60, medic_frames_attackCable, medic_run); static EntThinkAdapter medic_attack = new EntThinkAdapter() { - public String getID(){ return "medic_attack"; } + public String getID(){ return "medic_attack"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_MEDIC) != 0) self.monsterinfo.currentmove = medic_move_attackCable; @@ -1247,7 +1247,7 @@ public class M_Medic { }; static EntThinkAdapter medic_checkattack = new EntThinkAdapter() { - public String getID(){ return "medic_checkattack"; } + public String getID(){ return "medic_checkattack"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_MEDIC) != 0) { medic_attack.think(self); diff --git a/src/main/java/lwjake2/game/monsters/M_Mutant.java b/src/main/java/lwjake2/game/monsters/M_Mutant.java index de0d3f0..d2b41ff 100644 --- a/src/main/java/lwjake2/game/monsters/M_Mutant.java +++ b/src/main/java/lwjake2/game/monsters/M_Mutant.java @@ -41,7 +41,7 @@ import lwjake2.util.Math3D; public class M_Mutant { - // This file generated by ModelGen - Do NOT Modify + // This file generated by ModelGen - Do NOT Modify public final static int FRAME_attack01 = 0; @@ -370,10 +370,10 @@ public class M_Mutant { static int sound_thud; // - // SOUNDS + // SOUNDS // static EntThinkAdapter mutant_step = new EntThinkAdapter() { - public String getID(){ return "mutant_step"; } + public String getID(){ return "mutant_step"; } public boolean think(edict_t self) { int n; n = (Lib.rand() + 1) % 3; @@ -391,7 +391,7 @@ public class M_Mutant { }; static EntInteractAdapter mutant_sight = new EntInteractAdapter() { - public String getID(){ return "mutant_sight"; } + public String getID(){ return "mutant_sight"; } public boolean interact(edict_t self, edict_t other) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1, Defines.ATTN_NORM, 0); @@ -400,7 +400,7 @@ public class M_Mutant { }; static EntThinkAdapter mutant_search = new EntThinkAdapter() { - public String getID(){ return "mutant_search"; } + public String getID(){ return "mutant_search"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search, 1, Defines.ATTN_NORM, 0); @@ -409,7 +409,7 @@ public class M_Mutant { }; static EntThinkAdapter mutant_swing = new EntThinkAdapter() { - public String getID(){ return "mutant_swing"; } + public String getID(){ return "mutant_swing"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_swing, 1, Defines.ATTN_NORM, 0); @@ -418,7 +418,7 @@ public class M_Mutant { }; // - // STAND + // STAND // static mframe_t mutant_frames_stand[] = new mframe_t[] { @@ -488,7 +488,7 @@ public class M_Mutant { FRAME_stand151, mutant_frames_stand, null); static EntThinkAdapter mutant_stand = new EntThinkAdapter() { - public String getID(){ return "mutant_stand"; } + public String getID(){ return "mutant_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = mutant_move_stand; return true; @@ -496,11 +496,11 @@ public class M_Mutant { }; // - // IDLE + // IDLE // static EntThinkAdapter mutant_idle_loop = new EntThinkAdapter() { - public String getID(){ return "mutant_idle_loop"; } + public String getID(){ return "mutant_idle_loop"; } public boolean think(edict_t self) { if (Lib.random() < 0.75) self.monsterinfo.nextframe = FRAME_stand155; @@ -529,7 +529,7 @@ public class M_Mutant { FRAME_stand164, mutant_frames_idle, mutant_stand); static EntThinkAdapter mutant_idle = new EntThinkAdapter() { - public String getID(){ return "mutant_idle"; } + public String getID(){ return "mutant_idle"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = mutant_move_idle; GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1, @@ -539,7 +539,7 @@ public class M_Mutant { }; // - // WALK + // WALK // static mframe_t mutant_frames_walk[] = new mframe_t[] { @@ -560,7 +560,7 @@ public class M_Mutant { mutant_frames_walk, null); static EntThinkAdapter mutant_walk_loop = new EntThinkAdapter() { - public String getID(){ return "mutant_walk_loop"; } + public String getID(){ return "mutant_walk_loop"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = mutant_move_walk; return true; @@ -577,7 +577,7 @@ public class M_Mutant { FRAME_walk04, mutant_frames_start_walk, mutant_walk_loop); static EntThinkAdapter mutant_walk = new EntThinkAdapter() { - public String getID(){ return "mutant_walk"; } + public String getID(){ return "mutant_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = mutant_move_start_walk; return true; @@ -585,7 +585,7 @@ public class M_Mutant { }; // - // RUN + // RUN // static mframe_t mutant_frames_run[] = new mframe_t[] { @@ -600,7 +600,7 @@ public class M_Mutant { mutant_frames_run, null); static EntThinkAdapter mutant_run = new EntThinkAdapter() { - public String getID(){ return "mutant_run"; } + public String getID(){ return "mutant_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) self.monsterinfo.currentmove = mutant_move_stand; @@ -612,11 +612,11 @@ public class M_Mutant { }; // - // MELEE + // MELEE // static EntThinkAdapter mutant_hit_left = new EntThinkAdapter() { - public String getID(){ return "mutant_hit_left"; } + public String getID(){ return "mutant_hit_left"; } public boolean think(edict_t self) { float[] aim = { 0, 0, 0 }; @@ -632,7 +632,7 @@ public class M_Mutant { }; static EntThinkAdapter mutant_hit_right = new EntThinkAdapter() { - public String getID(){ return "mutant_hit_right"; } + public String getID(){ return "mutant_hit_right"; } public boolean think(edict_t self) { float[] aim = { 0, 0, 0 }; @@ -648,7 +648,7 @@ public class M_Mutant { }; static EntThinkAdapter mutant_check_refire = new EntThinkAdapter() { - public String getID(){ return "mutant_check_refire"; } + public String getID(){ return "mutant_check_refire"; } public boolean think(edict_t self) { if (null == self.enemy || !self.enemy.inuse || self.enemy.health <= 0) @@ -674,7 +674,7 @@ public class M_Mutant { FRAME_attack15, mutant_frames_attack, mutant_run); static EntThinkAdapter mutant_melee = new EntThinkAdapter() { - public String getID(){ return "mutant_melee"; } + public String getID(){ return "mutant_melee"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = mutant_move_attack; return true; @@ -682,11 +682,11 @@ public class M_Mutant { }; // - // ATTACK + // ATTACK // static EntTouchAdapter mutant_jump_touch = new EntTouchAdapter() { - public String getID(){ return "mutant_jump_touch"; } + public String getID(){ return "mutant_jump_touch"; } public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { @@ -723,7 +723,7 @@ public class M_Mutant { }; static EntThinkAdapter mutant_jump_takeoff = new EntThinkAdapter() { - public String getID(){ return "mutant_jump_takeoff"; } + public String getID(){ return "mutant_jump_takeoff"; } public boolean think(edict_t self) { float[] forward = { 0, 0, 0 }; @@ -743,7 +743,7 @@ public class M_Mutant { }; static EntThinkAdapter mutant_check_landing = new EntThinkAdapter() { - public String getID(){ return "mutant_check_landing"; } + public String getID(){ return "mutant_check_landing"; } public boolean think(edict_t self) { if (self.groundentity != null) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_thud, 1, @@ -775,7 +775,7 @@ public class M_Mutant { FRAME_attack08, mutant_frames_jump, mutant_run); static EntThinkAdapter mutant_jump = new EntThinkAdapter() { - public String getID(){ return "mutant_jump"; } + public String getID(){ return "mutant_jump"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = mutant_move_jump; @@ -784,10 +784,10 @@ public class M_Mutant { }; // - // CHECKATTACK + // CHECKATTACK // static EntThinkAdapter mutant_check_melee = new EntThinkAdapter() { - public String getID(){ return "mutant_check_melee"; } + public String getID(){ return "mutant_check_melee"; } public boolean think(edict_t self) { if (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE) return true; @@ -797,7 +797,7 @@ public class M_Mutant { }; static EntThinkAdapter mutant_check_jump = new EntThinkAdapter() { - public String getID(){ return "mutant_check_jump"; } + public String getID(){ return "mutant_check_jump"; } public boolean think(edict_t self) { float[] v = { 0, 0, 0 }; @@ -826,7 +826,7 @@ public class M_Mutant { }; static EntThinkAdapter mutant_checkattack = new EntThinkAdapter() { - public String getID(){ return "mutant_checkattack"; } + public String getID(){ return "mutant_checkattack"; } public boolean think(edict_t self) { if (null == self.enemy || self.enemy.health <= 0) @@ -848,7 +848,7 @@ public class M_Mutant { }; // - // PAIN + // PAIN // static mframe_t mutant_frames_pain1[] = new mframe_t[] { @@ -889,7 +889,7 @@ public class M_Mutant { FRAME_pain311, mutant_frames_pain3, mutant_run); static EntPainAdapter mutant_pain = new EntPainAdapter() { - public String getID(){ return "mutant_pain"; } + public String getID(){ return "mutant_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { float r; @@ -922,10 +922,10 @@ public class M_Mutant { }; // - // DEATH + // DEATH // static EntThinkAdapter mutant_dead = new EntThinkAdapter() { - public String getID(){ return "mutant_dead"; } + public String getID(){ return "mutant_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -16, -16, -24); Math3D.VectorSet(self.maxs, 16, 16, -8); @@ -968,7 +968,7 @@ public class M_Mutant { FRAME_death210, mutant_frames_death2, mutant_dead); static EntDieAdapter mutant_die = new EntDieAdapter() { - public String getID(){ return "mutant_die"; } + public String getID(){ return "mutant_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { int n; @@ -1008,7 +1008,7 @@ public class M_Mutant { }; // - // SPAWN + // SPAWN // /* @@ -1016,7 +1016,7 @@ public class M_Mutant { * Trigger_Spawn Sight */ public static EntThinkAdapter SP_monster_mutant = new EntThinkAdapter() { - public String getID(){ return "SP_monster_mutant"; } + public String getID(){ return "SP_monster_mutant"; } public boolean think(edict_t self) { if (GameBase.deathmatch.value != 0) { GameUtil.G_FreeEdict(self); diff --git a/src/main/java/lwjake2/game/monsters/M_Parasite.java b/src/main/java/lwjake2/game/monsters/M_Parasite.java index c8370a5..f5f3d95 100644 --- a/src/main/java/lwjake2/game/monsters/M_Parasite.java +++ b/src/main/java/lwjake2/game/monsters/M_Parasite.java @@ -301,7 +301,7 @@ public class M_Parasite { static int sound_search; static EntThinkAdapter parasite_launch = new EntThinkAdapter() { - public String getID(){ return "parasite_launch"; } + public String getID(){ return "parasite_launch"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_launch, 1, @@ -311,7 +311,7 @@ public class M_Parasite { }; static EntThinkAdapter parasite_reel_in = new EntThinkAdapter() { - public String getID(){ return "parasite_reel_in"; } + public String getID(){ return "parasite_reel_in"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_reelin, 1, Defines.ATTN_NORM, 0); @@ -320,7 +320,7 @@ public class M_Parasite { }; static EntInteractAdapter parasite_sight = new EntInteractAdapter() { - public String getID(){ return "parasite_sight"; } + public String getID(){ return "parasite_sight"; } public boolean interact(edict_t self, edict_t other) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_sight, 1, Defines.ATTN_NORM, 0); @@ -329,7 +329,7 @@ public class M_Parasite { }; static EntThinkAdapter parasite_tap = new EntThinkAdapter() { - public String getID(){ return "parasite_tap"; } + public String getID(){ return "parasite_tap"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_tap, 1, Defines.ATTN_IDLE, 0); @@ -338,7 +338,7 @@ public class M_Parasite { }; static EntThinkAdapter parasite_scratch = new EntThinkAdapter() { - public String getID(){ return "parasite_scratch"; } + public String getID(){ return "parasite_scratch"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_scratch, 1, Defines.ATTN_IDLE, 0); @@ -347,7 +347,7 @@ public class M_Parasite { }; static EntThinkAdapter parasite_search = new EntThinkAdapter() { - public String getID(){ return "parasite_search"; } + public String getID(){ return "parasite_search"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_search, 1, Defines.ATTN_IDLE, 0); @@ -356,7 +356,7 @@ public class M_Parasite { }; static EntThinkAdapter parasite_start_walk = new EntThinkAdapter() { - public String getID(){ return "parasite_start_walk"; } + public String getID(){ return "parasite_start_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = parasite_move_start_walk; return true; @@ -364,7 +364,7 @@ public class M_Parasite { }; static EntThinkAdapter parasite_walk = new EntThinkAdapter() { - public String getID(){ return "parasite_walk"; } + public String getID(){ return "parasite_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = parasite_move_walk; return true; @@ -372,7 +372,7 @@ public class M_Parasite { }; static EntThinkAdapter parasite_stand = new EntThinkAdapter() { - public String getID(){ return "parasite_stand"; } + public String getID(){ return "parasite_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = parasite_move_stand; return true; @@ -380,7 +380,7 @@ public class M_Parasite { }; static EntThinkAdapter parasite_end_fidget = new EntThinkAdapter() { - public String getID(){ return "parasite_end_fidget"; } + public String getID(){ return "parasite_end_fidget"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = parasite_move_end_fidget; return true; @@ -388,7 +388,7 @@ public class M_Parasite { }; static EntThinkAdapter parasite_do_fidget = new EntThinkAdapter() { - public String getID(){ return "parasite_do_fidget"; } + public String getID(){ return "parasite_do_fidget"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = parasite_move_fidget; return true; @@ -396,7 +396,7 @@ public class M_Parasite { }; static EntThinkAdapter parasite_refidget = new EntThinkAdapter() { - public String getID(){ return "parasite_refidget"; } + public String getID(){ return "parasite_refidget"; } public boolean think(edict_t self) { if (Lib.random() <= 0.8) self.monsterinfo.currentmove = parasite_move_fidget; @@ -407,7 +407,7 @@ public class M_Parasite { }; static EntThinkAdapter parasite_idle = new EntThinkAdapter() { - public String getID(){ return "parasite_idle"; } + public String getID(){ return "parasite_idle"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = parasite_move_start_fidget; return true; @@ -415,7 +415,7 @@ public class M_Parasite { }; static EntThinkAdapter parasite_start_run = new EntThinkAdapter() { - public String getID(){ return "parasite_start_run"; } + public String getID(){ return "parasite_start_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) self.monsterinfo.currentmove = parasite_move_stand; @@ -426,7 +426,7 @@ public class M_Parasite { }; static EntThinkAdapter parasite_run = new EntThinkAdapter() { - public String getID(){ return "parasite_run"; } + public String getID(){ return "parasite_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) self.monsterinfo.currentmove = parasite_move_stand; @@ -568,7 +568,7 @@ public class M_Parasite { FRAME_pain111, parasite_frames_pain1, parasite_start_run); static EntPainAdapter parasite_pain = new EntPainAdapter() { - public String getID(){ return "parasite_pain"; } + public String getID(){ return "parasite_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { if (self.health < (self.max_health / 2)) self.s.skinnum = 1; @@ -593,7 +593,7 @@ public class M_Parasite { }; static EntThinkAdapter parasite_drain_attack = new EntThinkAdapter() { - public String getID(){ return "parasite_drain_attack"; } + public String getID(){ return "parasite_drain_attack"; } public boolean think(edict_t self) { float[] offset = { 0, 0, 0 }, start = { 0, 0, 0 }, f = { 0, 0, 0 }, r = { 0, 0, 0 }, end = { 0, 0, 0 }, dir = { 0, 0, 0 }; @@ -714,11 +714,11 @@ public class M_Parasite { */ static EntThinkAdapter parasite_attack = new EntThinkAdapter() { - public String getID(){ return "parasite_attack"; } + public String getID(){ return "parasite_attack"; } public boolean think(edict_t self) { - // if (random() <= 0.2) - // self.monsterinfo.currentmove = ¶site_move_break; - // else + // if (random() <= 0.2) + // self.monsterinfo.currentmove = ¶site_move_break; + // else self.monsterinfo.currentmove = parasite_move_drain; return true; } @@ -729,7 +729,7 @@ public class M_Parasite { */ static EntThinkAdapter parasite_dead = new EntThinkAdapter() { - public String getID(){ return "parasite_dead"; } + public String getID(){ return "parasite_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -16, -16, -24); Math3D.VectorSet(self.maxs, 16, 16, -8); @@ -754,7 +754,7 @@ public class M_Parasite { FRAME_death107, parasite_frames_death, parasite_dead); static EntDieAdapter parasite_die = new EntDieAdapter() { - public String getID(){ return "parasite_die"; } + public String getID(){ return "parasite_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { int n; @@ -800,7 +800,7 @@ public class M_Parasite { */ public static EntThinkAdapter SP_monster_parasite = new EntThinkAdapter() { - public String getID(){ return "SP_monster_parasite"; } + public String getID(){ return "SP_monster_parasite"; } public boolean think(edict_t self) { if (GameBase.deathmatch.value != 0) { GameUtil.G_FreeEdict(self); diff --git a/src/main/java/lwjake2/game/monsters/M_Player.java b/src/main/java/lwjake2/game/monsters/M_Player.java index 02c2c64..bd2bc05 100644 --- a/src/main/java/lwjake2/game/monsters/M_Player.java +++ b/src/main/java/lwjake2/game/monsters/M_Player.java @@ -19,7 +19,7 @@ package lwjake2.game.monsters; public class M_Player { - // This file generated by qdata - Do NOT Modify + // This file generated by qdata - Do NOT Modify public final static int FRAME_stand01 = 0; diff --git a/src/main/java/lwjake2/game/monsters/M_Soldier.java b/src/main/java/lwjake2/game/monsters/M_Soldier.java index 643411c..62f0556 100644 --- a/src/main/java/lwjake2/game/monsters/M_Soldier.java +++ b/src/main/java/lwjake2/game/monsters/M_Soldier.java @@ -1014,7 +1014,7 @@ public class M_Soldier { static int sound_cock; static EntThinkAdapter soldier_dead = new EntThinkAdapter() { - public String getID(){ return "soldier_dead"; } + public String getID(){ return "soldier_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -16, -16, -24); @@ -1028,7 +1028,7 @@ public class M_Soldier { }; static EntDieAdapter soldier_die = new EntDieAdapter() { - public String getID(){ return "soldier_die"; } + public String getID(){ return "soldier_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { int n; @@ -1091,7 +1091,7 @@ public class M_Soldier { }; static EntThinkAdapter soldier_attack1_refire1 = new EntThinkAdapter() { - public String getID(){ return "soldier_attack1_refire1"; } + public String getID(){ return "soldier_attack1_refire1"; } public boolean think(edict_t self) { if (self.s.skinnum > 1) return true; @@ -1109,7 +1109,7 @@ public class M_Soldier { }; static EntThinkAdapter soldier_attack1_refire2 = new EntThinkAdapter() { - public String getID(){ return "soldier_attack1_refire2"; } + public String getID(){ return "soldier_attack1_refire2"; } public boolean think(edict_t self) { if (self.s.skinnum < 2) return true; @@ -1125,7 +1125,7 @@ public class M_Soldier { }; static EntThinkAdapter soldier_attack2_refire1 = new EntThinkAdapter() { - public String getID(){ return "soldier_attack2_refire1"; } + public String getID(){ return "soldier_attack2_refire1"; } public boolean think(edict_t self) { if (self.s.skinnum > 1) return true; @@ -1143,7 +1143,7 @@ public class M_Soldier { }; static EntThinkAdapter soldier_attack2_refire2 = new EntThinkAdapter() { - public String getID(){ return "soldier_attack2_refire2"; } + public String getID(){ return "soldier_attack2_refire2"; } public boolean think(edict_t self) { if (self.s.skinnum < 2) return true; @@ -1159,7 +1159,7 @@ public class M_Soldier { }; static EntThinkAdapter soldier_attack3_refire = new EntThinkAdapter() { - public String getID(){ return "soldier_attack3_refire"; } + public String getID(){ return "soldier_attack3_refire"; } public boolean think(edict_t self) { if ((GameBase.level.time + 0.4) < self.monsterinfo.pausetime) self.monsterinfo.nextframe = FRAME_attak303; @@ -1168,7 +1168,7 @@ public class M_Soldier { }; static EntThinkAdapter soldier_attack6_refire = new EntThinkAdapter() { - public String getID(){ return "soldier_attack6_refire"; } + public String getID(){ return "soldier_attack6_refire"; } public boolean think(edict_t self) { if (self.enemy.health <= 0) return true; @@ -1184,7 +1184,7 @@ public class M_Soldier { // ATTACK6 (run & shoot) static EntThinkAdapter soldier_fire8 = new EntThinkAdapter() { - public String getID(){ return "soldier_fire8"; } + public String getID(){ return "soldier_fire8"; } public boolean think(edict_t self) { soldier_fire(self, 7); return true; @@ -1194,7 +1194,7 @@ public class M_Soldier { // ATTACK1 (blaster/shotgun) static EntThinkAdapter soldier_fire1 = new EntThinkAdapter() { - public String getID(){ return "soldier_fire1"; } + public String getID(){ return "soldier_fire1"; } public boolean think(edict_t self) { soldier_fire(self, 0); return true; @@ -1204,7 +1204,7 @@ public class M_Soldier { // ATTACK2 (blaster/shotgun) static EntThinkAdapter soldier_fire2 = new EntThinkAdapter() { - public String getID(){ return "soldier_fire2"; } + public String getID(){ return "soldier_fire2"; } public boolean think(edict_t self) { soldier_fire(self, 1); return true; @@ -1212,7 +1212,7 @@ public class M_Soldier { }; static EntThinkAdapter soldier_duck_down = new EntThinkAdapter() { - public String getID(){ return "soldier_duck_down"; } + public String getID(){ return "soldier_duck_down"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_DUCKED) != 0) return true; @@ -1226,7 +1226,7 @@ public class M_Soldier { }; static EntThinkAdapter soldier_fire3 = new EntThinkAdapter() { - public String getID(){ return "soldier_fire3"; } + public String getID(){ return "soldier_fire3"; } public boolean think(edict_t self) { soldier_duck_down.think(self); soldier_fire(self, 2); @@ -1237,16 +1237,16 @@ public class M_Soldier { // ATTACK4 (machinegun) static EntThinkAdapter soldier_fire4 = new EntThinkAdapter() { - public String getID(){ return "soldier_fire4"; } + public String getID(){ return "soldier_fire4"; } public boolean think(edict_t self) { soldier_fire(self, 3); // - // if (self.enemy.health <= 0) - // return; + // if (self.enemy.health <= 0) + // return; // - // if ( ((skill.value == 3) && (random() < 0.5)) || (range(self, + // if ( ((skill.value == 3) && (random() < 0.5)) || (range(self, // self.enemy) == RANGE_MELEE) ) - // self.monsterinfo.nextframe = FRAME_attak402; + // self.monsterinfo.nextframe = FRAME_attak402; return true; } }; @@ -1256,7 +1256,7 @@ public class M_Soldier { // static EntThinkAdapter soldier_fire6 = new EntThinkAdapter() { - public String getID(){ return "soldier_fire6"; } + public String getID(){ return "soldier_fire6"; } public boolean think(edict_t self) { soldier_fire(self, 5); return true; @@ -1264,7 +1264,7 @@ public class M_Soldier { }; static EntThinkAdapter soldier_fire7 = new EntThinkAdapter() { - public String getID(){ return "soldier_fire7"; } + public String getID(){ return "soldier_fire7"; } public boolean think(edict_t self) { soldier_fire(self, 6); return true; @@ -1272,7 +1272,7 @@ public class M_Soldier { }; static EntThinkAdapter soldier_idle = new EntThinkAdapter() { - public String getID(){ return "soldier_idle"; } + public String getID(){ return "soldier_idle"; } public boolean think(edict_t self) { if (Lib.random() > 0.8) GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1, @@ -1282,7 +1282,7 @@ public class M_Soldier { }; static EntThinkAdapter soldier_stand = new EntThinkAdapter() { - public String getID(){ return "soldier_stand"; } + public String getID(){ return "soldier_stand"; } public boolean think(edict_t self) { if ((self.monsterinfo.currentmove == soldier_move_stand3) || (Lib.random() < 0.8)) @@ -1297,7 +1297,7 @@ public class M_Soldier { // WALK // static EntThinkAdapter soldier_walk1_random = new EntThinkAdapter() { - public String getID(){ return "soldier_walk1_random"; } + public String getID(){ return "soldier_walk1_random"; } public boolean think(edict_t self) { if (Lib.random() > 0.1) self.monsterinfo.nextframe = FRAME_walk101; @@ -1306,7 +1306,7 @@ public class M_Soldier { }; static EntThinkAdapter soldier_walk = new EntThinkAdapter() { - public String getID(){ return "soldier_walk"; } + public String getID(){ return "soldier_walk"; } public boolean think(edict_t self) { if (Lib.random() < 0.5) self.monsterinfo.currentmove = soldier_move_walk1; @@ -1317,7 +1317,7 @@ public class M_Soldier { }; static EntThinkAdapter soldier_run = new EntThinkAdapter() { - public String getID(){ return "soldier_run"; } + public String getID(){ return "soldier_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) { self.monsterinfo.currentmove = soldier_move_stand1; @@ -1336,7 +1336,7 @@ public class M_Soldier { }; static EntPainAdapter soldier_pain = new EntPainAdapter() { - public String getID(){ return "soldier_pain"; } + public String getID(){ return "soldier_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { float r; int n; @@ -1389,7 +1389,7 @@ public class M_Soldier { // static EntThinkAdapter soldier_duck_up = new EntThinkAdapter() { - public String getID(){ return "soldier_duck_up"; } + public String getID(){ return "soldier_duck_up"; } public boolean think(edict_t self) { self.monsterinfo.aiflags &= ~Defines.AI_DUCKED; self.maxs[2] += 32; @@ -1400,7 +1400,7 @@ public class M_Soldier { }; static EntInteractAdapter soldier_sight = new EntInteractAdapter() { - public String getID(){ return "soldier_sight"; } + public String getID(){ return "soldier_sight"; } public boolean interact(edict_t self, edict_t other) { if (Lib.random() < 0.5) GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight1, 1, @@ -1423,7 +1423,7 @@ public class M_Soldier { // static EntThinkAdapter SP_monster_soldier_x = new EntThinkAdapter() { - public String getID(){ return "SP_monster_soldier_x"; } + public String getID(){ return "SP_monster_soldier_x"; } public boolean think(edict_t self) { self.s.modelindex = GameBase.gi @@ -1466,7 +1466,7 @@ public class M_Soldier { * Trigger_Spawn Sight */ public static EntThinkAdapter SP_monster_soldier_light = new EntThinkAdapter() { - public String getID(){ return "SP_monster_soldier_light"; } + public String getID(){ return "SP_monster_soldier_light"; } public boolean think(edict_t self) { if (GameBase.deathmatch.value != 0) { GameUtil.G_FreeEdict(self); @@ -1494,7 +1494,7 @@ public class M_Soldier { */ public static EntThinkAdapter SP_monster_soldier = new EntThinkAdapter() { - public String getID(){ return "SP_monster_soldier"; } + public String getID(){ return "SP_monster_soldier"; } public boolean think(edict_t self) { Com.DPrintf("Spawning a soldier at " + self.s.origin[0] + " " + self.s.origin[1] + " " + @@ -1524,7 +1524,7 @@ public class M_Soldier { * Trigger_Spawn Sight */ public static EntThinkAdapter SP_monster_soldier_ss = new EntThinkAdapter() { - public String getID(){ return "SP_monster_soldier_ss"; } + public String getID(){ return "SP_monster_soldier_ss"; } public boolean think(edict_t self) { if (GameBase.deathmatch.value != 0) { GameUtil.G_FreeEdict(self); @@ -1609,7 +1609,7 @@ public class M_Soldier { } static EntThinkAdapter soldier_cock = new EntThinkAdapter() { - public String getID(){ return "soldier_cock"; } + public String getID(){ return "soldier_cock"; } public boolean think(edict_t self) { if (self.s.frame == FRAME_stand322) GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_cock, 1, @@ -1781,7 +1781,7 @@ public class M_Soldier { // static EntThinkAdapter soldier_duck_hold = new EntThinkAdapter() { - public String getID(){ return "soldier_duck_hold"; } + public String getID(){ return "soldier_duck_hold"; } public boolean think(edict_t self) { if (GameBase.level.time >= self.monsterinfo.pausetime) self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME; @@ -2214,7 +2214,7 @@ public class M_Soldier { // ATTACK3 (duck and shoot) static EntThinkAdapter soldier_attack = new EntThinkAdapter() { - public String getID(){ return "soldier_attack"; } + public String getID(){ return "soldier_attack"; } public boolean think(edict_t self) { if (self.s.skinnum < 4) { if (Lib.random() < 0.5) @@ -2229,7 +2229,7 @@ public class M_Soldier { }; static EntDodgeAdapter soldier_dodge = new EntDodgeAdapter() { - public String getID(){ return "soldier_dodge"; } + public String getID(){ return "soldier_dodge"; } public void dodge(edict_t self, edict_t attacker, float eta) { float r; diff --git a/src/main/java/lwjake2/game/monsters/M_Supertank.java b/src/main/java/lwjake2/game/monsters/M_Supertank.java index ddb9ec5..8a232ee 100644 --- a/src/main/java/lwjake2/game/monsters/M_Supertank.java +++ b/src/main/java/lwjake2/game/monsters/M_Supertank.java @@ -563,7 +563,7 @@ public class M_Supertank { static int tread_sound; static EntThinkAdapter TreadSound = new EntThinkAdapter() { - public String getID(){ return "TreadSound"; } + public String getID(){ return "TreadSound"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, tread_sound, 1, Defines.ATTN_NORM, 0); @@ -572,7 +572,7 @@ public class M_Supertank { }; static EntThinkAdapter supertank_search = new EntThinkAdapter() { - public String getID(){ return "supertank_search"; } + public String getID(){ return "supertank_search"; } public boolean think(edict_t self) { if (Lib.random() < 0.5) GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search1, 1, @@ -654,7 +654,7 @@ public class M_Supertank { FRAME_stand_60, supertank_frames_stand, null); static EntThinkAdapter supertank_stand = new EntThinkAdapter() { - public String getID() { return "supertank_stand"; } + public String getID() { return "supertank_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = supertank_move_stand; return true; @@ -712,7 +712,7 @@ public class M_Supertank { FRAME_forwrd_18, supertank_frames_forward, null); static EntThinkAdapter supertank_forward = new EntThinkAdapter() { - public String getID(){ return "supertank_forward"; } + public String getID(){ return "supertank_forward"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = supertank_move_forward; return true; @@ -720,7 +720,7 @@ public class M_Supertank { }; static EntThinkAdapter supertank_walk = new EntThinkAdapter() { - public String getID(){ return "supertank_walk"; } + public String getID(){ return "supertank_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = supertank_move_forward; return true; @@ -728,7 +728,7 @@ public class M_Supertank { }; static EntThinkAdapter supertank_run = new EntThinkAdapter() { - public String getID(){ return "supertank_run"; } + public String getID(){ return "supertank_run"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) self.monsterinfo.currentmove = supertank_move_stand; @@ -742,7 +742,7 @@ public class M_Supertank { // death // static EntThinkAdapter supertank_dead = new EntThinkAdapter() { - public String getID(){ return "supertank_dead"; } + public String getID(){ return "supertank_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -60, -60, 0); Math3D.VectorSet(self.maxs, 60, 60, 72); @@ -755,7 +755,7 @@ public class M_Supertank { }; static EntThinkAdapter supertankRocket = new EntThinkAdapter() { - public String getID(){ return "supertankRocket"; } + public String getID(){ return "supertankRocket"; } public boolean think(edict_t self) { float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; float[] start = { 0, 0, 0 }; @@ -789,7 +789,7 @@ public class M_Supertank { }; static EntThinkAdapter supertankMachineGun = new EntThinkAdapter() { - public String getID(){ return "supertankMachineGun"; } + public String getID(){ return "supertankMachineGun"; } public boolean think(edict_t self) { float[] dir = { 0, 0, 0 }; float[] vec = { 0, 0, 0 }; @@ -826,7 +826,7 @@ public class M_Supertank { }; static EntThinkAdapter supertank_attack = new EntThinkAdapter() { - public String getID(){ return "supertank_attack"; } + public String getID(){ return "supertank_attack"; } public boolean think(edict_t self) { float[] vec = { 0, 0, 0 }; float range; @@ -1053,7 +1053,7 @@ public class M_Supertank { FRAME_attak2_27, supertank_frames_attack2, supertank_run); static EntThinkAdapter supertank_reattack1 = new EntThinkAdapter() { - public String getID(){ return "supertank_reattack1"; } + public String getID(){ return "supertank_reattack1"; } public boolean think(edict_t self) { if (GameUtil.visible(self, self.enemy)) if (Lib.random() < 0.9) @@ -1097,7 +1097,7 @@ public class M_Supertank { FRAME_attak1_20, supertank_frames_end_attack1, supertank_run); static EntPainAdapter supertank_pain = new EntPainAdapter() { - public String getID(){ return "supertank_pain"; } + public String getID(){ return "supertank_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { if (self.health < (self.max_health / 2)) self.s.skinnum = 1; @@ -1138,7 +1138,7 @@ public class M_Supertank { }; static EntDieAdapter supertank_die = new EntDieAdapter() { - public String getID(){ return "supertank_die"; } + public String getID(){ return "supertank_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_death, 1, @@ -1159,7 +1159,7 @@ public class M_Supertank { * Trigger_Spawn Sight */ public static EntThinkAdapter SP_monster_supertank = new EntThinkAdapter() { - public String getID(){ return "SP_monster_supertank"; } + public String getID(){ return "SP_monster_supertank"; } public boolean think(edict_t self) { if (GameBase.deathmatch.value != 0) { GameUtil.G_FreeEdict(self); @@ -1173,7 +1173,7 @@ public class M_Supertank { sound_search1 = GameBase.gi.soundindex("bosstank/btkunqv1.wav"); sound_search2 = GameBase.gi.soundindex("bosstank/btkunqv2.wav"); - // self.s.sound = gi.soundindex ("bosstank/btkengn1.wav"); + // self.s.sound = gi.soundindex ("bosstank/btkengn1.wav"); tread_sound = GameBase.gi.soundindex("bosstank/btkengn1.wav"); self.movetype = Defines.MOVETYPE_STEP; @@ -1211,7 +1211,7 @@ public class M_Supertank { /** Common Boss explode animation. */ public static EntThinkAdapter BossExplode = new EntThinkAdapter() { - public String getID(){ return "BossExplode"; } + public String getID(){ return "BossExplode"; } public boolean think(edict_t self) { float[] org = { 0, 0, 0 }; diff --git a/src/main/java/lwjake2/game/monsters/M_Tank.java b/src/main/java/lwjake2/game/monsters/M_Tank.java index b2b4486..ce3a483 100644 --- a/src/main/java/lwjake2/game/monsters/M_Tank.java +++ b/src/main/java/lwjake2/game/monsters/M_Tank.java @@ -651,7 +651,7 @@ public class M_Tank { // static EntInteractAdapter tank_sight = new EntInteractAdapter() { - public String getID(){ return "tank_sight"; } + public String getID(){ return "tank_sight"; } public boolean interact(edict_t self, edict_t other) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1, Defines.ATTN_NORM, 0); @@ -660,7 +660,7 @@ public class M_Tank { }; static EntThinkAdapter tank_footstep = new EntThinkAdapter() { - public String getID(){ return "tank_footstep"; } + public String getID(){ return "tank_footstep"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_BODY, sound_step, 1, Defines.ATTN_NORM, 0); @@ -669,7 +669,7 @@ public class M_Tank { }; static EntThinkAdapter tank_thud = new EntThinkAdapter() { - public String getID(){ return "tank_thud"; } + public String getID(){ return "tank_thud"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_BODY, sound_thud, 1, Defines.ATTN_NORM, 0); @@ -678,7 +678,7 @@ public class M_Tank { }; static EntThinkAdapter tank_windup = new EntThinkAdapter() { - public String getID(){ return "tank_windup"; } + public String getID(){ return "tank_windup"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_windup, 1, Defines.ATTN_NORM, 0); @@ -687,7 +687,7 @@ public class M_Tank { }; static EntThinkAdapter tank_idle = new EntThinkAdapter() { - public String getID(){ return "tank_idle"; } + public String getID(){ return "tank_idle"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1, Defines.ATTN_IDLE, 0); @@ -735,7 +735,7 @@ public class M_Tank { tank_frames_stand, null); static EntThinkAdapter tank_stand = new EntThinkAdapter() { - public String getID(){ return "tank_stand"; } + public String getID(){ return "tank_stand"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = tank_move_stand; return true; @@ -746,7 +746,7 @@ public class M_Tank { // walk // static EntThinkAdapter tank_run = new EntThinkAdapter() { - public String getID(){ return "tank_run"; } + public String getID(){ return "tank_run"; } public boolean think(edict_t self) { if (self.enemy != null && self.enemy.client != null) self.monsterinfo.aiflags |= Defines.AI_BRUTAL; @@ -769,7 +769,7 @@ public class M_Tank { }; static EntThinkAdapter tank_walk = new EntThinkAdapter() { - public String getID(){ return "tank_walk"; } + public String getID(){ return "tank_walk"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = tank_move_walk; return true; @@ -905,7 +905,7 @@ public class M_Tank { tank_frames_pain3, tank_run); static EntPainAdapter tank_pain = new EntPainAdapter() { - public String getID(){ return "tank_pain"; } + public String getID(){ return "tank_pain"; } public void pain(edict_t self, edict_t other, float kick, int damage) { if (self.health < (self.max_health / 2)) self.s.skinnum |= 1; @@ -951,7 +951,7 @@ public class M_Tank { // static EntThinkAdapter TankBlaster = new EntThinkAdapter() { - public String getID(){ return "TankBlaster"; } + public String getID(){ return "TankBlaster"; } public boolean think(edict_t self) { float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; float[] start = { 0, 0, 0 }; @@ -984,7 +984,7 @@ public class M_Tank { }; static EntThinkAdapter TankStrike = new EntThinkAdapter() { - public String getID(){ return "TankStrike"; } + public String getID(){ return "TankStrike"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_strike, 1, Defines.ATTN_NORM, 0); @@ -994,7 +994,7 @@ public class M_Tank { }; static EntThinkAdapter TankRocket = new EntThinkAdapter() { - public String getID(){ return "TankRocket"; } + public String getID(){ return "TankRocket"; } public boolean think(edict_t self) { float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; float[] start = { 0, 0, 0 }; @@ -1028,7 +1028,7 @@ public class M_Tank { }; static EntThinkAdapter TankMachineGun = new EntThinkAdapter() { - public String getID(){ return "TankMachineGun"; } + public String getID(){ return "TankMachineGun"; } public boolean think(edict_t self) { float[] dir = { 0, 0, 0 }; @@ -1071,7 +1071,7 @@ public class M_Tank { }; static EntThinkAdapter tank_reattack_blaster = new EntThinkAdapter() { - public String getID(){ return "tank_reattack_blaster"; } + public String getID(){ return "tank_reattack_blaster"; } public boolean think(edict_t self) { if (GameBase.skill.value >= 2) if (GameUtil.visible(self, self.enemy)) @@ -1133,7 +1133,7 @@ public class M_Tank { FRAME_attak122, tank_frames_attack_post_blast, tank_run); static EntThinkAdapter tank_poststrike = new EntThinkAdapter() { - public String getID(){ return "tank_poststrike"; } + public String getID(){ return "tank_poststrike"; } public boolean think(edict_t self) { self.enemy = null; tank_run.think(self); @@ -1142,7 +1142,7 @@ public class M_Tank { }; static EntThinkAdapter tank_doattack_rocket = new EntThinkAdapter() { - public String getID(){ return "tank_doattack_rocket"; } + public String getID(){ return "tank_doattack_rocket"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = tank_move_attack_fire_rocket; return true; @@ -1150,7 +1150,7 @@ public class M_Tank { }; static EntThinkAdapter tank_refire_rocket = new EntThinkAdapter() { - public String getID(){ return "tank_refire_rocket"; } + public String getID(){ return "tank_refire_rocket"; } public boolean think(edict_t self) { // Only on hard or nightmare if (GameBase.skill.value >= 2) @@ -1320,7 +1320,7 @@ public class M_Tank { FRAME_attak429, tank_frames_attack_chain, tank_run); static EntThinkAdapter tank_attack = new EntThinkAdapter() { - public String getID(){ return "tank_attack"; } + public String getID(){ return "tank_attack"; } public boolean think(edict_t self) { float[] vec = { 0, 0, 0 }; float range; @@ -1368,7 +1368,7 @@ public class M_Tank { // death // static EntThinkAdapter tank_dead = new EntThinkAdapter() { - public String getID(){ return "tank_dead"; } + public String getID(){ return "tank_dead"; } public boolean think(edict_t self) { Math3D.VectorSet(self.mins, -16, -16, -16); Math3D.VectorSet(self.maxs, 16, 16, -0); @@ -1418,7 +1418,7 @@ public class M_Tank { FRAME_death132, tank_frames_death1, tank_dead); static EntDieAdapter tank_die = new EntDieAdapter() { - public String getID(){ return "tank_die"; } + public String getID(){ return "tank_die"; } public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { int n; @@ -1472,7 +1472,7 @@ public class M_Tank { * Trigger_Spawn Sight */ public static EntThinkAdapter SP_monster_tank = new EntThinkAdapter() { - public String getID(){ return "SP_monster_tank"; } + public String getID(){ return "SP_monster_tank"; } public boolean think(edict_t self) { if (GameBase.deathmatch.value != 0) { GameUtil.G_FreeEdict(self); diff --git a/src/main/java/lwjake2/game/moveinfo_t.java b/src/main/java/lwjake2/game/moveinfo_t.java index 80447a6..ca2dd0d 100644 --- a/src/main/java/lwjake2/game/moveinfo_t.java +++ b/src/main/java/lwjake2/game/moveinfo_t.java @@ -23,89 +23,89 @@ import lwjake2.util.QuakeFile; import java.io.IOException; public class moveinfo_t { - // fixed data - float[] start_origin= { 0, 0, 0 }; - float[] start_angles= { 0, 0, 0 }; - float[] end_origin= { 0, 0, 0 }; - float[] end_angles= { 0, 0, 0 }; + // fixed data + float[] start_origin= { 0, 0, 0 }; + float[] start_angles= { 0, 0, 0 }; + float[] end_origin= { 0, 0, 0 }; + float[] end_angles= { 0, 0, 0 }; - int sound_start; - int sound_middle; - int sound_end; + int sound_start; + int sound_middle; + int sound_end; - float accel; - float speed; - float decel; - float distance; + float accel; + float speed; + float decel; + float distance; - float wait; + float wait; - // state data - int state; - float[] dir= { 0, 0, 0 }; + // state data + int state; + float[] dir= { 0, 0, 0 }; - float current_speed; - float move_speed; - float next_speed; - float remaining_distance; - float decel_distance; - EntThinkAdapter endfunc; + float current_speed; + float move_speed; + float next_speed; + float remaining_distance; + float decel_distance; + EntThinkAdapter endfunc; - /** saves the moveinfo to the file. */ - public void write(QuakeFile f) throws IOException { - f.writeVector(start_origin); - f.writeVector(start_angles); - f.writeVector(end_origin); - f.writeVector(end_angles); + /** saves the moveinfo to the file. */ + public void write(QuakeFile f) throws IOException { + f.writeVector(start_origin); + f.writeVector(start_angles); + f.writeVector(end_origin); + f.writeVector(end_angles); - f.writeInt(sound_start); - f.writeInt(sound_middle); - f.writeInt(sound_end); + f.writeInt(sound_start); + f.writeInt(sound_middle); + f.writeInt(sound_end); - f.writeFloat(accel); - f.writeFloat(speed); - f.writeFloat(decel); - f.writeFloat(distance); + f.writeFloat(accel); + f.writeFloat(speed); + f.writeFloat(decel); + f.writeFloat(distance); - f.writeFloat(wait); + f.writeFloat(wait); - f.writeInt(state); - f.writeVector(dir); + f.writeInt(state); + f.writeVector(dir); - f.writeFloat(current_speed); - f.writeFloat(move_speed); - f.writeFloat(next_speed); - f.writeFloat(remaining_distance); - f.writeFloat(decel_distance); - f.writeAdapter(endfunc); - } + f.writeFloat(current_speed); + f.writeFloat(move_speed); + f.writeFloat(next_speed); + f.writeFloat(remaining_distance); + f.writeFloat(decel_distance); + f.writeAdapter(endfunc); + } - /** Reads the moveinfo from a file. */ - public void read(QuakeFile f) throws IOException { - start_origin= f.readVector(); - start_angles= f.readVector(); - end_origin= f.readVector(); - end_angles= f.readVector(); + /** Reads the moveinfo from a file. */ + public void read(QuakeFile f) throws IOException { + start_origin= f.readVector(); + start_angles= f.readVector(); + end_origin= f.readVector(); + end_angles= f.readVector(); - sound_start= f.readInt(); - sound_middle= f.readInt(); - sound_end= f.readInt(); + sound_start= f.readInt(); + sound_middle= f.readInt(); + sound_end= f.readInt(); - accel= f.readFloat(); - speed= f.readFloat(); - decel= f.readFloat(); - distance= f.readFloat(); + accel= f.readFloat(); + speed= f.readFloat(); + decel= f.readFloat(); + distance= f.readFloat(); - wait= f.readFloat(); + wait= f.readFloat(); - state= f.readInt(); - dir= f.readVector(); + state= f.readInt(); + dir= f.readVector(); - current_speed= f.readFloat(); - move_speed= f.readFloat(); - next_speed= f.readFloat(); - remaining_distance= f.readFloat(); - decel_distance= f.readFloat(); - endfunc= (EntThinkAdapter) f.readAdapter(); - } + current_speed= f.readFloat(); + move_speed= f.readFloat(); + next_speed= f.readFloat(); + remaining_distance= f.readFloat(); + decel_distance= f.readFloat(); + endfunc= (EntThinkAdapter) f.readAdapter(); + } } diff --git a/src/main/java/lwjake2/game/player_state_t.java b/src/main/java/lwjake2/game/player_state_t.java index 82fd2e2..f981c83 100644 --- a/src/main/java/lwjake2/game/player_state_t.java +++ b/src/main/java/lwjake2/game/player_state_t.java @@ -27,175 +27,175 @@ import java.io.IOException; import java.io.RandomAccessFile; /** - Player_state_t is the information needed in addition to pmove_state_t - to rendered a view. There will only be 10 player_state_t sent each second, - but the number of pmove_state_t changes will be relative to client - frame rates. + Player_state_t is the information needed in addition to pmove_state_t + to rendered a view. There will only be 10 player_state_t sent each second, + but the number of pmove_state_t changes will be relative to client + frame rates. */ public class player_state_t { - public pmove_state_t pmove= new pmove_state_t(); // for prediction + public pmove_state_t pmove= new pmove_state_t(); // for prediction - // these fields do not need to be communicated bit-precise - public float[] viewangles= { 0, 0, 0 }; // for fixed views - public float[] viewoffset= { 0, 0, 0 }; // add to pmovestate->origin - public float[] kick_angles= { 0, 0, 0 }; // add to view direction to get render angles + // these fields do not need to be communicated bit-precise + public float[] viewangles= { 0, 0, 0 }; // for fixed views + public float[] viewoffset= { 0, 0, 0 }; // add to pmovestate->origin + public float[] kick_angles= { 0, 0, 0 }; // add to view direction to get render angles - // set by weapon kicks, pain effects, etc - public float[] gunangles= { 0, 0, 0 }; - public float[] gunoffset= { 0, 0, 0 }; - public int gunindex; - public int gunframe; + // set by weapon kicks, pain effects, etc + public float[] gunangles= { 0, 0, 0 }; + public float[] gunoffset= { 0, 0, 0 }; + public int gunindex; + public int gunframe; - public float blend[]= new float[4]; // rgba full screen effect + public float blend[]= new float[4]; // rgba full screen effect - public float fov; // horizontal field of view + public float fov; // horizontal field of view - public int rdflags; // refdef flags + public int rdflags; // refdef flags - public short stats[]= new short[Defines.MAX_STATS]; + public short stats[]= new short[Defines.MAX_STATS]; - /** Lets cleverly reset the structure. */ - private static player_state_t prototype= new player_state_t(); + /** Lets cleverly reset the structure. */ + private static player_state_t prototype= new player_state_t(); - /** Clears the player_state. */ - public void clear() { - this.set(prototype); - } + /** Clears the player_state. */ + public void clear() { + this.set(prototype); + } - /** Clones the object. */ - public player_state_t getClone() { - return new player_state_t().set(this); - } + /** Clones the object. */ + public player_state_t getClone() { + return new player_state_t().set(this); + } - /** Copies the player state data. */ - public player_state_t set(player_state_t from) { - pmove.set(from.pmove); - Math3D.VectorCopy(from.viewangles, viewangles); - Math3D.VectorCopy(from.viewoffset, viewoffset); - Math3D.VectorCopy(from.kick_angles, kick_angles); + /** Copies the player state data. */ + public player_state_t set(player_state_t from) { + pmove.set(from.pmove); + Math3D.VectorCopy(from.viewangles, viewangles); + Math3D.VectorCopy(from.viewoffset, viewoffset); + Math3D.VectorCopy(from.kick_angles, kick_angles); - Math3D.VectorCopy(from.gunangles, gunangles); - Math3D.VectorCopy(from.gunoffset, gunoffset); + Math3D.VectorCopy(from.gunangles, gunangles); + Math3D.VectorCopy(from.gunoffset, gunoffset); - gunindex= from.gunindex; - gunframe= from.gunframe; + gunindex= from.gunindex; + gunframe= from.gunframe; - blend[0]= from.blend[0]; - blend[1]= from.blend[1]; - blend[2]= from.blend[2]; - blend[3]= from.blend[3]; + blend[0]= from.blend[0]; + blend[1]= from.blend[1]; + blend[2]= from.blend[2]; + blend[3]= from.blend[3]; - fov= from.fov; - rdflags= from.rdflags; + fov= from.fov; + rdflags= from.rdflags; - System.arraycopy(from.stats, 0, stats, 0, Defines.MAX_STATS); + System.arraycopy(from.stats, 0, stats, 0, Defines.MAX_STATS); - return this; - } + return this; + } - /** Reads a player_state from a file. */ - public void load(RandomAccessFile f) throws IOException { - pmove.load(f); + /** Reads a player_state from a file. */ + public void load(RandomAccessFile f) throws IOException { + pmove.load(f); - viewangles[0]= f.readFloat(); - viewangles[1]= f.readFloat(); - viewangles[2]= f.readFloat(); + viewangles[0]= f.readFloat(); + viewangles[1]= f.readFloat(); + viewangles[2]= f.readFloat(); - viewoffset[0]= f.readFloat(); - viewoffset[1]= f.readFloat(); - viewoffset[2]= f.readFloat(); + viewoffset[0]= f.readFloat(); + viewoffset[1]= f.readFloat(); + viewoffset[2]= f.readFloat(); - kick_angles[0]= f.readFloat(); - kick_angles[1]= f.readFloat(); - kick_angles[2]= f.readFloat(); + kick_angles[0]= f.readFloat(); + kick_angles[1]= f.readFloat(); + kick_angles[2]= f.readFloat(); - gunangles[0]= f.readFloat(); - gunangles[1]= f.readFloat(); - gunangles[2]= f.readFloat(); + gunangles[0]= f.readFloat(); + gunangles[1]= f.readFloat(); + gunangles[2]= f.readFloat(); - gunoffset[0]= f.readFloat(); - gunoffset[1]= f.readFloat(); - gunoffset[2]= f.readFloat(); + gunoffset[0]= f.readFloat(); + gunoffset[1]= f.readFloat(); + gunoffset[2]= f.readFloat(); - gunindex= f.readInt(); - gunframe= f.readInt(); + gunindex= f.readInt(); + gunframe= f.readInt(); - blend[0]= f.readFloat(); - blend[1]= f.readFloat(); - blend[2]= f.readFloat(); - blend[3]= f.readFloat(); + blend[0]= f.readFloat(); + blend[1]= f.readFloat(); + blend[2]= f.readFloat(); + blend[3]= f.readFloat(); - fov= f.readFloat(); + fov= f.readFloat(); - rdflags= f.readInt(); + rdflags= f.readInt(); - for (int n= 0; n < Defines.MAX_STATS; n++) - stats[n]= f.readShort(); - } + for (int n= 0; n < Defines.MAX_STATS; n++) + stats[n]= f.readShort(); + } - /** Writes a player_state to a file. */ - public void write(RandomAccessFile f) throws IOException { - pmove.write(f); + /** Writes a player_state to a file. */ + public void write(RandomAccessFile f) throws IOException { + pmove.write(f); - f.writeFloat(viewangles[0]); - f.writeFloat(viewangles[1]); - f.writeFloat(viewangles[2]); + f.writeFloat(viewangles[0]); + f.writeFloat(viewangles[1]); + f.writeFloat(viewangles[2]); - f.writeFloat(viewoffset[0]); - f.writeFloat(viewoffset[1]); - f.writeFloat(viewoffset[2]); + f.writeFloat(viewoffset[0]); + f.writeFloat(viewoffset[1]); + f.writeFloat(viewoffset[2]); - f.writeFloat(kick_angles[0]); - f.writeFloat(kick_angles[1]); - f.writeFloat(kick_angles[2]); + f.writeFloat(kick_angles[0]); + f.writeFloat(kick_angles[1]); + f.writeFloat(kick_angles[2]); - f.writeFloat(gunangles[0]); - f.writeFloat(gunangles[1]); - f.writeFloat(gunangles[2]); + f.writeFloat(gunangles[0]); + f.writeFloat(gunangles[1]); + f.writeFloat(gunangles[2]); - f.writeFloat(gunoffset[0]); - f.writeFloat(gunoffset[1]); - f.writeFloat(gunoffset[2]); + f.writeFloat(gunoffset[0]); + f.writeFloat(gunoffset[1]); + f.writeFloat(gunoffset[2]); - f.writeInt(gunindex); - f.writeInt(gunframe); + f.writeInt(gunindex); + f.writeInt(gunframe); - f.writeFloat(blend[0]); - f.writeFloat(blend[1]); - f.writeFloat(blend[2]); - f.writeFloat(blend[3]); + f.writeFloat(blend[0]); + f.writeFloat(blend[1]); + f.writeFloat(blend[2]); + f.writeFloat(blend[3]); - f.writeFloat(fov); + f.writeFloat(fov); - f.writeInt(rdflags); + f.writeInt(rdflags); - for (int n= 0; n < Defines.MAX_STATS; n++) - f.writeShort(stats[n]); - } + for (int n= 0; n < Defines.MAX_STATS; n++) + f.writeShort(stats[n]); + } - /** Prints the player state. */ + /** Prints the player state. */ // метод не используется =( -// public void dump() { -// pmove.dump(); +// public void dump() { +// pmove.dump(); // -// Lib.printv("viewangles", viewangles); -// Lib.printv("viewoffset", viewoffset); -// Lib.printv("kick_angles", kick_angles); -// Lib.printv("gunangles", gunangles); -// Lib.printv("gunoffset", gunoffset); +// Lib.printv("viewangles", viewangles); +// Lib.printv("viewoffset", viewoffset); +// Lib.printv("kick_angles", kick_angles); +// Lib.printv("gunangles", gunangles); +// Lib.printv("gunoffset", gunoffset); // -// Com.Println("gunindex: " + gunindex); -// Com.Println("gunframe: " + gunframe); +// Com.Println("gunindex: " + gunindex); +// Com.Println("gunframe: " + gunframe); // -// Lib.printv("blend", blend); +// Lib.printv("blend", blend); // -// Com.Println("fov: " + fov); +// Com.Println("fov: " + fov); // -// Com.Println("rdflags: " + rdflags); +// Com.Println("rdflags: " + rdflags); // -// for (int n= 0; n < Defines.MAX_STATS; n++) -// System.out.println("stats[" + n + "]: " + stats[n]); -// } +// for (int n= 0; n < Defines.MAX_STATS; n++) +// System.out.println("stats[" + n + "]: " + stats[n]); +// } } diff --git a/src/main/java/lwjake2/game/pmove_state_t.java b/src/main/java/lwjake2/game/pmove_state_t.java index 24e0490..bdc5bd2 100644 --- a/src/main/java/lwjake2/game/pmove_state_t.java +++ b/src/main/java/lwjake2/game/pmove_state_t.java @@ -26,124 +26,124 @@ import java.io.RandomAccessFile; @Slf4j public class pmove_state_t { - // this structure needs to be communicated bit-accurate - // from the server to the client to guarantee that - // prediction stays in sync, so no floats are used. - // if any part of the game code modifies this struct, it - // will result in a prediction error of some degree. + // this structure needs to be communicated bit-accurate + // from the server to the client to guarantee that + // prediction stays in sync, so no floats are used. + // if any part of the game code modifies this struct, it + // will result in a prediction error of some degree. - public int pm_type; + public int pm_type; - public short origin[] = { 0, 0, 0 }; // 12.3 - public short velocity[] = { 0, 0, 0 }; // 12.3 - /** ducked, jump_held, etc. */ - public byte pm_flags; - /** each unit = 8 ms. */ - public byte pm_time; - public short gravity; - /** add to command angles to get view direction. */ - public short delta_angles[] = { 0, 0, 0 }; - /** changed by spawns, rotating objects, and teleporters. */ - - private static pmove_state_t prototype = new pmove_state_t(); - - public void clear() - { - this.set(prototype); - } - - public void set(pmove_state_t from) { - pm_type = from.pm_type; - Math3D.VectorCopy(from.origin, origin); - Math3D.VectorCopy(from.velocity, velocity); - pm_flags = from.pm_flags; - pm_time = from.pm_time; - gravity = from.gravity; - Math3D.VectorCopy(from.delta_angles, delta_angles); - } - - public boolean equals(pmove_state_t p2) { - return pm_type == p2.pm_type - && origin[0] == p2.origin[0] - && origin[1] == p2.origin[1] - && origin[2] == p2.origin[2] - && velocity[0] == p2.velocity[0] - && velocity[1] == p2.velocity[1] - && velocity[2] == p2.origin[2] - && pm_flags == p2.pm_flags - && pm_time == p2.pm_time - && delta_angles[0] == p2.delta_angles[0] - && delta_angles[1] == p2.delta_angles[1] - && delta_angles[2] == p2.origin[2]; + public short origin[] = { 0, 0, 0 }; // 12.3 + public short velocity[] = { 0, 0, 0 }; // 12.3 + /** ducked, jump_held, etc. */ + public byte pm_flags; + /** each unit = 8 ms. */ + public byte pm_time; + public short gravity; + /** add to command angles to get view direction. */ + public short delta_angles[] = { 0, 0, 0 }; + /** changed by spawns, rotating objects, and teleporters. */ + + private static pmove_state_t prototype = new pmove_state_t(); + + public void clear() + { + this.set(prototype); + } + + public void set(pmove_state_t from) { + pm_type = from.pm_type; + Math3D.VectorCopy(from.origin, origin); + Math3D.VectorCopy(from.velocity, velocity); + pm_flags = from.pm_flags; + pm_time = from.pm_time; + gravity = from.gravity; + Math3D.VectorCopy(from.delta_angles, delta_angles); + } + + public boolean equals(pmove_state_t p2) { + return pm_type == p2.pm_type + && origin[0] == p2.origin[0] + && origin[1] == p2.origin[1] + && origin[2] == p2.origin[2] + && velocity[0] == p2.velocity[0] + && velocity[1] == p2.velocity[1] + && velocity[2] == p2.origin[2] + && pm_flags == p2.pm_flags + && pm_time == p2.pm_time + && delta_angles[0] == p2.delta_angles[0] + && delta_angles[1] == p2.delta_angles[1] + && delta_angles[2] == p2.origin[2]; - } + } - /** Reads the playermove from the file. */ - public void load(RandomAccessFile f) throws IOException { + /** Reads the playermove from the file. */ + public void load(RandomAccessFile f) throws IOException { - pm_type = f.readInt(); + pm_type = f.readInt(); - origin[0] = f.readShort(); - origin[1] = f.readShort(); - origin[2] = f.readShort(); + origin[0] = f.readShort(); + origin[1] = f.readShort(); + origin[2] = f.readShort(); - velocity[0] = f.readShort(); - velocity[1] = f.readShort(); - velocity[2] = f.readShort(); + velocity[0] = f.readShort(); + velocity[1] = f.readShort(); + velocity[2] = f.readShort(); - pm_flags = f.readByte(); - pm_time = f.readByte(); - gravity = f.readShort(); + pm_flags = f.readByte(); + pm_time = f.readByte(); + gravity = f.readShort(); - f.readShort(); + f.readShort(); - delta_angles[0] = f.readShort(); - delta_angles[1] = f.readShort(); - delta_angles[2] = f.readShort(); + delta_angles[0] = f.readShort(); + delta_angles[1] = f.readShort(); + delta_angles[2] = f.readShort(); - } - - /** Writes the playermove to the file. */ - public void write (RandomAccessFile f) throws IOException { + } + + /** Writes the playermove to the file. */ + public void write (RandomAccessFile f) throws IOException { - f.writeInt(pm_type); + f.writeInt(pm_type); - f.writeShort(origin[0]); - f.writeShort(origin[1]); - f.writeShort(origin[2]); + f.writeShort(origin[0]); + f.writeShort(origin[1]); + f.writeShort(origin[2]); - f.writeShort(velocity[0]); - f.writeShort(velocity[1]); - f.writeShort(velocity[2]); + f.writeShort(velocity[0]); + f.writeShort(velocity[1]); + f.writeShort(velocity[2]); - f.writeByte(pm_flags); - f.writeByte(pm_time); - f.writeShort(gravity); + f.writeByte(pm_flags); + f.writeByte(pm_time); + f.writeShort(gravity); - f.writeShort(0); + f.writeShort(0); - f.writeShort(delta_angles[0]); - f.writeShort(delta_angles[1]); - f.writeShort(delta_angles[2]); - } + f.writeShort(delta_angles[0]); + f.writeShort(delta_angles[1]); + f.writeShort(delta_angles[2]); + } - public void dump() { - log.info("pm_type: {}", pm_type); + public void dump() { + log.info("pm_type: {}", pm_type); - log.info("origin[0]: {}", origin[0]); - log.info("origin[1]: {}", origin[1]); - log.info("origin[2]: {}", origin[2]); + log.info("origin[0]: {}", origin[0]); + log.info("origin[1]: {}", origin[1]); + log.info("origin[2]: {}", origin[2]); - log.info("velocity[0]: {}", velocity[0]); - log.info("velocity[1]: {}", velocity[1]); - log.info("velocity[2]: {}", velocity[2]); + log.info("velocity[0]: {}", velocity[0]); + log.info("velocity[1]: {}", velocity[1]); + log.info("velocity[2]: {}", velocity[2]); - log.info("pmflags: {}", pm_flags); - log.info("pmtime: {}", pm_time); - log.info("gravity: {}", gravity); + log.info("pmflags: {}", pm_flags); + log.info("pmtime: {}", pm_time); + log.info("gravity: {}", gravity); - log.info("delta-angle[0]: {}", delta_angles[0]); - log.info("delta-angle[1]: {}", delta_angles[1]); - log.info("delta-angle[2]: {}", delta_angles[2]); - } + log.info("delta-angle[0]: {}", delta_angles[0]); + log.info("delta-angle[1]: {}", delta_angles[1]); + log.info("delta-angle[2]: {}", delta_angles[2]); + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/game/pushed_t.java b/src/main/java/lwjake2/game/pushed_t.java index d5e5f3f..deeba67 100644 --- a/src/main/java/lwjake2/game/pushed_t.java +++ b/src/main/java/lwjake2/game/pushed_t.java @@ -19,8 +19,8 @@ package lwjake2.game; public class pushed_t { - public edict_t ent; - public float[] origin= { 0.0f, 0.0f, 0.0f }; - public float[] angles= { 0.0f, 0.0f, 0.0f }; - public float deltayaw; + public edict_t ent; + public float[] origin= { 0.0f, 0.0f, 0.0f }; + public float[] angles= { 0.0f, 0.0f, 0.0f }; + public float deltayaw; } diff --git a/src/main/java/lwjake2/game/spawn_t.java b/src/main/java/lwjake2/game/spawn_t.java index 0637b1b..a7d9b6a 100644 --- a/src/main/java/lwjake2/game/spawn_t.java +++ b/src/main/java/lwjake2/game/spawn_t.java @@ -19,11 +19,11 @@ package lwjake2.game; public class spawn_t { - public spawn_t(String name, EntThinkAdapter spawn) { - this.name = name; - this.spawn = spawn; - } + public spawn_t(String name, EntThinkAdapter spawn) { + this.name = name; + this.spawn = spawn; + } - String name; - EntThinkAdapter spawn; + String name; + EntThinkAdapter spawn; } diff --git a/src/main/java/lwjake2/game/spawn_temp_t.java b/src/main/java/lwjake2/game/spawn_temp_t.java index 35c3e16..0ab7d62 100644 --- a/src/main/java/lwjake2/game/spawn_temp_t.java +++ b/src/main/java/lwjake2/game/spawn_temp_t.java @@ -21,104 +21,104 @@ package lwjake2.game; import lwjake2.util.Lib; public class spawn_temp_t { - // world vars - public String sky=""; - public float skyrotate; - public float[] skyaxis = { 0, 0, 0 }; - - public String nextmap=""; + // world vars + public String sky=""; + public float skyrotate; + public float[] skyaxis = { 0, 0, 0 }; + + public String nextmap=""; - public int lip; - public int distance; - public int height; - - public String noise=""; - public float pausetime; + public int lip; + public int distance; + public int height; + + public String noise=""; + public float pausetime; - public String item=""; - public String gravity=""; + public String item=""; + public String gravity=""; - public float minyaw; - public float maxyaw; - public float minpitch; - public float maxpitch; + public float minyaw; + public float maxyaw; + public float minpitch; + public float maxpitch; - public boolean set(String key, String value) { - if (key.equals("lip")) { - lip=Lib.atoi(value); - return true; - } // F_INT, FFL_SPAWNTEMP), - - if (key.equals("distance")) { - distance=Lib.atoi(value); - return true; - } // F_INT, FFL_SPAWNTEMP), - - if (key.equals("height")) { - height=Lib.atoi(value); - return true; - } // F_INT, FFL_SPAWNTEMP), - - if (key.equals("noise")) { - noise = GameSpawn.ED_NewString(value); - return true; - } // F_LSTRING, FFL_SPAWNTEMP), - - if (key.equals("pausetime")) { - pausetime = Lib.atof(value); - return true; - } // F_FLOAT, FFL_SPAWNTEMP), - - if (key.equals("item")) { - item = GameSpawn.ED_NewString(value); - return true; - } // F_LSTRING, FFL_SPAWNTEMP), - - if (key.equals("gravity")) { - gravity = GameSpawn.ED_NewString(value); - return true; - } // F_LSTRING, FFL_SPAWNTEMP), - - if (key.equals("sky")) { - sky = GameSpawn.ED_NewString(value); - return true; - } // F_LSTRING, FFL_SPAWNTEMP), - - if (key.equals("skyrotate")) { - skyrotate=Lib.atof(value); - return true; - } // F_FLOAT, FFL_SPAWNTEMP), - - if (key.equals("skyaxis")) { - skyaxis=Lib.atov(value); - return true; - } // F_VECTOR, FFL_SPAWNTEMP), - - if (key.equals("minyaw")) { - minyaw=Lib.atof(value); - return true; - } // F_FLOAT, FFL_SPAWNTEMP), - - if (key.equals("maxyaw")) { - maxyaw=Lib.atof(value); - return true; - } // F_FLOAT, FFL_SPAWNTEMP), - - if (key.equals("minpitch")) { - minpitch = Lib.atof(value); - return true; - } // F_FLOAT, FFL_SPAWNTEMP), - - if (key.equals("maxpitch")) { - maxpitch = Lib.atof(value); - return true; - } // F_FLOAT, FFL_SPAWNTEMP), - - if (key.equals("nextmap")) { - nextmap = GameSpawn.ED_NewString(value); - return true; - } // F_LSTRING, FFL_SPAWNTEMP), + public boolean set(String key, String value) { + if (key.equals("lip")) { + lip=Lib.atoi(value); + return true; + } // F_INT, FFL_SPAWNTEMP), + + if (key.equals("distance")) { + distance=Lib.atoi(value); + return true; + } // F_INT, FFL_SPAWNTEMP), + + if (key.equals("height")) { + height=Lib.atoi(value); + return true; + } // F_INT, FFL_SPAWNTEMP), + + if (key.equals("noise")) { + noise = GameSpawn.ED_NewString(value); + return true; + } // F_LSTRING, FFL_SPAWNTEMP), + + if (key.equals("pausetime")) { + pausetime = Lib.atof(value); + return true; + } // F_FLOAT, FFL_SPAWNTEMP), + + if (key.equals("item")) { + item = GameSpawn.ED_NewString(value); + return true; + } // F_LSTRING, FFL_SPAWNTEMP), + + if (key.equals("gravity")) { + gravity = GameSpawn.ED_NewString(value); + return true; + } // F_LSTRING, FFL_SPAWNTEMP), + + if (key.equals("sky")) { + sky = GameSpawn.ED_NewString(value); + return true; + } // F_LSTRING, FFL_SPAWNTEMP), + + if (key.equals("skyrotate")) { + skyrotate=Lib.atof(value); + return true; + } // F_FLOAT, FFL_SPAWNTEMP), + + if (key.equals("skyaxis")) { + skyaxis=Lib.atov(value); + return true; + } // F_VECTOR, FFL_SPAWNTEMP), + + if (key.equals("minyaw")) { + minyaw=Lib.atof(value); + return true; + } // F_FLOAT, FFL_SPAWNTEMP), + + if (key.equals("maxyaw")) { + maxyaw=Lib.atof(value); + return true; + } // F_FLOAT, FFL_SPAWNTEMP), + + if (key.equals("minpitch")) { + minpitch = Lib.atof(value); + return true; + } // F_FLOAT, FFL_SPAWNTEMP), + + if (key.equals("maxpitch")) { + maxpitch = Lib.atof(value); + return true; + } // F_FLOAT, FFL_SPAWNTEMP), + + if (key.equals("nextmap")) { + nextmap = GameSpawn.ED_NewString(value); + return true; + } // F_LSTRING, FFL_SPAWNTEMP), - return false; - } + return false; + } } diff --git a/src/main/java/lwjake2/game/trace_t.java b/src/main/java/lwjake2/game/trace_t.java index b9a49e2..e348dcd 100644 --- a/src/main/java/lwjake2/game/trace_t.java +++ b/src/main/java/lwjake2/game/trace_t.java @@ -22,37 +22,37 @@ import lwjake2.util.Math3D; //a trace is returned when a box is swept through the world public class trace_t { - public boolean allsolid; // if true, plane is not valid - public boolean startsolid; // if true, the initial point was in a solid area - public float fraction; // time completed, 1.0 = didn't hit anything - public float[] endpos = { 0, 0, 0 }; // final position - // memory - public cplane_t plane = new cplane_t(); // surface normal at impact - // pointer - public csurface_t surface; // surface hit - public int contents; // contents on other side of surface hit - // pointer - public edict_t ent; // not set by CM_*() functions - - public void set(trace_t from) { - allsolid = from.allsolid; - startsolid = from.allsolid; - fraction = from.fraction; - Math3D.VectorCopy(from.endpos, endpos); - plane.set(from.plane); - surface = from.surface; - contents = from.contents; - ent = from.ent; - } + public boolean allsolid; // if true, plane is not valid + public boolean startsolid; // if true, the initial point was in a solid area + public float fraction; // time completed, 1.0 = didn't hit anything + public float[] endpos = { 0, 0, 0 }; // final position + // memory + public cplane_t plane = new cplane_t(); // surface normal at impact + // pointer + public csurface_t surface; // surface hit + public int contents; // contents on other side of surface hit + // pointer + public edict_t ent; // not set by CM_*() functions + + public void set(trace_t from) { + allsolid = from.allsolid; + startsolid = from.allsolid; + fraction = from.fraction; + Math3D.VectorCopy(from.endpos, endpos); + plane.set(from.plane); + surface = from.surface; + contents = from.contents; + ent = from.ent; + } - public void clear() { - allsolid = false; - startsolid = false; - fraction = 0; - Math3D.VectorClear(endpos); - plane.clear(); - surface = null; - contents = 0; - ent = null; - } + public void clear() { + allsolid = false; + startsolid = false; + fraction = 0; + Math3D.VectorClear(endpos); + plane.clear(); + surface = null; + contents = 0; + ent = null; + } } diff --git a/src/main/java/lwjake2/game/usercmd_t.java b/src/main/java/lwjake2/game/usercmd_t.java index 7b04d1f..c9b960d 100644 --- a/src/main/java/lwjake2/game/usercmd_t.java +++ b/src/main/java/lwjake2/game/usercmd_t.java @@ -19,46 +19,46 @@ package lwjake2.game; public class usercmd_t implements Cloneable { - public byte msec; - public byte buttons; - public short angles[]= new short[3]; - public short forwardmove, sidemove, upmove; - public byte impulse; // remove? - public byte lightlevel; // light level the player is standing on + public byte msec; + public byte buttons; + public short angles[]= new short[3]; + public short forwardmove, sidemove, upmove; + public byte impulse; // remove? + public byte lightlevel; // light level the player is standing on - public void clear() { - forwardmove= sidemove= upmove= msec= buttons= impulse= lightlevel= 0; - angles[0] = angles[1] = angles[2] = 0; - } + public void clear() { + forwardmove= sidemove= upmove= msec= buttons= impulse= lightlevel= 0; + angles[0] = angles[1] = angles[2] = 0; + } - public usercmd_t() { - }; + public usercmd_t() { + }; - public usercmd_t(usercmd_t from) { - msec= from.msec; - buttons= from.buttons; - angles[0]= from.angles[0]; - angles[1]= from.angles[1]; - angles[2]= from.angles[2]; - forwardmove= from.forwardmove; - sidemove= from.sidemove; - upmove= from.upmove; - impulse= from.impulse; - lightlevel= from.lightlevel; - } + public usercmd_t(usercmd_t from) { + msec= from.msec; + buttons= from.buttons; + angles[0]= from.angles[0]; + angles[1]= from.angles[1]; + angles[2]= from.angles[2]; + forwardmove= from.forwardmove; + sidemove= from.sidemove; + upmove= from.upmove; + impulse= from.impulse; + lightlevel= from.lightlevel; + } - public usercmd_t set(usercmd_t from) { - msec= from.msec; - buttons= from.buttons; - angles[0]= from.angles[0]; - angles[1]= from.angles[1]; - angles[2]= from.angles[2]; - forwardmove= from.forwardmove; - sidemove= from.sidemove; - upmove= from.upmove; - impulse= from.impulse; - lightlevel= from.lightlevel; + public usercmd_t set(usercmd_t from) { + msec= from.msec; + buttons= from.buttons; + angles[0]= from.angles[0]; + angles[1]= from.angles[1]; + angles[2]= from.angles[2]; + forwardmove= from.forwardmove; + sidemove= from.sidemove; + upmove= from.upmove; + impulse= from.impulse; + lightlevel= from.lightlevel; - return this; - } + return this; + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/qcommon/BaseQ2FileSystem.java b/src/main/java/lwjake2/qcommon/BaseQ2FileSystem.java index 7fcfd3f..e95183e 100644 --- a/src/main/java/lwjake2/qcommon/BaseQ2FileSystem.java +++ b/src/main/java/lwjake2/qcommon/BaseQ2FileSystem.java @@ -230,7 +230,7 @@ public class BaseQ2FileSystem implements FileSystem { // check for links first for (filelink_t link : fs_links) { - // if (!strncmp (filename, link->from, link->fromlength)) + // if (!strncmp (filename, link->from, link->fromlength)) if (filename.regionMatches(0, link.from, 0, link.fromlength)) { netpath = link.to + filename.substring(link.fromlength); file = new File(netpath); @@ -494,7 +494,7 @@ public class BaseQ2FileSystem implements FileSystem { RandomAccessFile file; int numpackfiles; pack_t pack; - // unsigned checksum; + // unsigned checksum; // try { file = new RandomAccessFile(packfile, "r"); @@ -906,14 +906,14 @@ public class BaseQ2FileSystem implements FileSystem { fs_base_searchpaths = fs_searchpaths; } - // RAFAEL + // RAFAEL /* * Developer_searchpath */ @Override public int developer_searchpath(int who) { // PMM - warning removal - // char *start; + // char *start; searchpath_t s; for (s = fs_searchpaths; s != null; s = s.next) { diff --git a/src/main/java/lwjake2/qcommon/CM.java b/src/main/java/lwjake2/qcommon/CM.java index 8cbc237..481b268 100644 --- a/src/main/java/lwjake2/qcommon/CM.java +++ b/src/main/java/lwjake2/qcommon/CM.java @@ -966,7 +966,7 @@ public class CM { /** Searches the leaf number that contains the 3d point. */ public static int CM_PointLeafnum(float[] p) { - // sound may call this without map loaded + // sound may call this without map loaded if (numplanes == 0) return 0; return CM_PointLeafnum_r(p, 0); diff --git a/src/main/java/lwjake2/qcommon/CRC.java b/src/main/java/lwjake2/qcommon/CRC.java index fdc99a0..4f72e55 100644 --- a/src/main/java/lwjake2/qcommon/CRC.java +++ b/src/main/java/lwjake2/qcommon/CRC.java @@ -21,10 +21,10 @@ package lwjake2.qcommon; public class CRC { - public final static short CRC_INIT_VALUE= (short) 0xffff; - public final static short CRC_XOR_VALUE= (short) 0x0000; + public final static short CRC_INIT_VALUE= (short) 0xffff; + public final static short CRC_XOR_VALUE= (short) 0x0000; - private static int crctable[] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, + private static int crctable[] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, @@ -58,52 +58,52 @@ public class CRC 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 }; - static int CRC_Block(byte start[], int count) - { - short crc= CRC_INIT_VALUE; + static int CRC_Block(byte start[], int count) + { + short crc= CRC_INIT_VALUE; - int ndx= 0; + int ndx= 0; - while (count-- > 0) - crc= (short) ((crc << 8) ^ crctable[0xff & ((crc >> 8) ^ start[ndx++])]); + while (count-- > 0) + crc= (short) ((crc << 8) ^ crctable[0xff & ((crc >> 8) ^ start[ndx++])]); - // unsigned short - return crc & 0xFFFF; - } + // unsigned short + return crc & 0xFFFF; + } - public static void main(String[] args) - { - byte data[]= - { - (byte) 0x71, - (byte) 0xa9, - (byte) 0x05, - (byte) 0xce, - (byte) 0x8d, - (byte) 0x75, - (byte) 0x28, - (byte) 0xc8, - (byte) 0xba, - (byte) 0x97, - - (byte) 0x45, - (byte) 0xe9, - (byte) 0x8a, - (byte) 0xe0, - (byte) 0x37, - (byte) 0xbd, - (byte) 0x6c, - (byte) 0x6d, - (byte) 0x67, - (byte) 0x4a, - (byte) 0x21 }; - System.out.println("crc:" + (CRC_Block(data, 21) & 0xffff)); - System.out.println("----"); - for (int n=0; n < 5; n++) - System.out.println("seq:" + (Com.BlockSequenceCRCByte( data,0, 21,n*10) & 0xff)); - - } - + public static void main(String[] args) + { + byte data[]= + { + (byte) 0x71, + (byte) 0xa9, + (byte) 0x05, + (byte) 0xce, + (byte) 0x8d, + (byte) 0x75, + (byte) 0x28, + (byte) 0xc8, + (byte) 0xba, + (byte) 0x97, + + (byte) 0x45, + (byte) 0xe9, + (byte) 0x8a, + (byte) 0xe0, + (byte) 0x37, + (byte) 0xbd, + (byte) 0x6c, + (byte) 0x6d, + (byte) 0x67, + (byte) 0x4a, + (byte) 0x21 }; + System.out.println("crc:" + (CRC_Block(data, 21) & 0xffff)); + System.out.println("----"); + for (int n=0; n < 5; n++) + System.out.println("seq:" + (Com.BlockSequenceCRCByte( data,0, 21,n*10) & 0xff)); + + } + /* c test: * * D:\Rene\gamesrc\quake2-3.21\qcommon>crc @@ -117,37 +117,37 @@ public class CRC * int main() { - byte data[21] = - { - 0x71, - 0xa9, - 0x05, - 0xce, - 0x8d, - 0x75, - 0x28, - 0xc8, - 0xba, - 0x97, - - 0x45, - 0xe9, - 0x8a, - 0xe0, - 0x37, - 0xbd, - 0x6c, - 0x6d, - 0x67, - 0x4a, 0x21 }; - int n=0; + byte data[21] = + { + 0x71, + 0xa9, + 0x05, + 0xce, + 0x8d, + 0x75, + 0x28, + 0xc8, + 0xba, + 0x97, + + 0x45, + 0xe9, + 0x8a, + 0xe0, + 0x37, + 0xbd, + 0x6c, + 0x6d, + 0x67, + 0x4a, 0x21 }; + int n=0; - printf("crc=%d\n", (short) CRC_Block(&data, 21)); + printf("crc=%d\n", (short) CRC_Block(&data, 21)); - printf("----\n"); - for (n=0; n < 5; n++) - printf("seq:%d\n", COM_BlockSequenceCRCByte( &data,21, n*10) ); + printf("----\n"); + for (n=0; n < 5; n++) + printf("seq:%d\n", COM_BlockSequenceCRCByte( &data,21, n*10) ); } - */ - + */ + } diff --git a/src/main/java/lwjake2/qcommon/Com.java b/src/main/java/lwjake2/qcommon/Com.java index c50ea01..c9fa4bd 100644 --- a/src/main/java/lwjake2/qcommon/Com.java +++ b/src/main/java/lwjake2/qcommon/Com.java @@ -39,385 +39,385 @@ public final class Com { static String debugContext = ""; static String _debugContext = ""; - static int com_argc; - static String[] com_argv= new String[Defines.MAX_NUM_ARGVS]; + static int com_argc; + static String[] com_argv= new String[Defines.MAX_NUM_ARGVS]; - public abstract static class RD_Flusher - { - public abstract void rd_flush(int target, StringBuffer buffer); - } + public abstract static class RD_Flusher + { + public abstract void rd_flush(int target, StringBuffer buffer); + } - static int rd_target; - static StringBuffer rd_buffer; - static int rd_buffersize; - static RD_Flusher rd_flusher; + static int rd_target; + static StringBuffer rd_buffer; + static int rd_buffersize; + static RD_Flusher rd_flusher; - public static void BeginRedirect(int target, StringBuffer buffer, int buffersize, RD_Flusher flush) - { - if (0 == target || null == buffer || 0 == buffersize || null == flush) - return; + public static void BeginRedirect(int target, StringBuffer buffer, int buffersize, RD_Flusher flush) + { + if (0 == target || null == buffer || 0 == buffersize || null == flush) + return; - rd_target= target; - rd_buffer= buffer; - rd_buffersize= buffersize; - rd_flusher= flush; + rd_target= target; + rd_buffer= buffer; + rd_buffersize= buffersize; + rd_flusher= flush; - rd_buffer.setLength(0); - } + rd_buffer.setLength(0); + } - public static void EndRedirect() - { - rd_flusher.rd_flush(rd_target, rd_buffer); + public static void EndRedirect() + { + rd_flusher.rd_flush(rd_target, rd_buffer); - rd_target= 0; - rd_buffer= null; - rd_buffersize= 0; - rd_flusher= null; - } + rd_target= 0; + rd_buffer= null; + rd_buffersize= 0; + rd_flusher= null; + } - static boolean recursive= false; + static boolean recursive= false; - static String msg= ""; + static String msg= ""; - // helper class to replace the pointer-pointer - public static class ParseHelp - { - public ParseHelp(String in) - { - if (in == null) - { - data= null; - length = 0; - } - else - { - data= in.toCharArray(); - length = data.length; - } - index= 0; - } + // helper class to replace the pointer-pointer + public static class ParseHelp + { + public ParseHelp(String in) + { + if (in == null) + { + data= null; + length = 0; + } + else + { + data= in.toCharArray(); + length = data.length; + } + index= 0; + } - public ParseHelp(char in[]) - { - this(in, 0); - } + public ParseHelp(char in[]) + { + this(in, 0); + } - public ParseHelp(char in[], int offset) - { - data= in; - index= offset; - if (data != null) length = data.length; - else length = 0; - } + public ParseHelp(char in[], int offset) + { + data= in; + index= offset; + if (data != null) length = data.length; + else length = 0; + } - public char getchar() - { - if (index < length) { - return data[index]; - } - return 0; - } + public char getchar() + { + if (index < length) { + return data[index]; + } + return 0; + } - public char nextchar() - { - // faster than if - index++; - if (index < length) { - return data[index]; - } - return 0; - } - - public char prevchar() { - if (index > 0) - { - index--; - return data[index]; - } - return 0; - } + public char nextchar() + { + // faster than if + index++; + if (index < length) { + return data[index]; + } + return 0; + } + + public char prevchar() { + if (index > 0) + { + index--; + return data[index]; + } + return 0; + } - public boolean isEof() - { - return index >= length; - } + public boolean isEof() + { + return index >= length; + } - public int index; - public char data[]; - private int length; + public int index; + public char data[]; + private int length; - public char skipwhites() - { - char c = 0; - while ( index < length && ((c= data[index]) <= ' ') && c != 0) - index++; - return c; - } + public char skipwhites() + { + char c = 0; + while ( index < length && ((c= data[index]) <= ' ') && c != 0) + index++; + return c; + } - public char skipwhitestoeol() - { - char c = 0; - while ( index < length &&((c= data[index]) <= ' ') && c != '\n' && c != 0) - index++; - return c; - } + public char skipwhitestoeol() + { + char c = 0; + while ( index < length &&((c= data[index]) <= ' ') && c != '\n' && c != 0) + index++; + return c; + } - public char skiptoeol() - { - char c = 0; - while ( index < length &&(c= data[index]) != '\n' && c != 0) - index++; - return c; - } - } + public char skiptoeol() + { + char c = 0; + while ( index < length &&(c= data[index]) != '\n' && c != 0) + index++; + return c; + } + } - public static char com_token[]= new char[Defines.MAX_TOKEN_CHARS]; + public static char com_token[]= new char[Defines.MAX_TOKEN_CHARS]; - // See GameSpanw.ED_ParseEdict() to see how to use it now. - public static String Parse(ParseHelp hlp) { - int c; - int len = 0; + // See GameSpanw.ED_ParseEdict() to see how to use it now. + public static String Parse(ParseHelp hlp) { + int c; + int len = 0; - if (hlp.data == null) { - return ""; - } + if (hlp.data == null) { + return ""; + } - while (true) { - // skip whitespace - hlp.skipwhites(); - if (hlp.isEof()) { - hlp.data = null; - return ""; - } + while (true) { + // skip whitespace + hlp.skipwhites(); + if (hlp.isEof()) { + hlp.data = null; + return ""; + } - // skip // comments - if (hlp.getchar() == '/') { - if (hlp.nextchar() == '/') { - hlp.skiptoeol(); - // goto skip whitespace - continue; - } else { - hlp.prevchar(); - break; - } - } else - break; - } + // skip // comments + if (hlp.getchar() == '/') { + if (hlp.nextchar() == '/') { + hlp.skiptoeol(); + // goto skip whitespace + continue; + } else { + hlp.prevchar(); + break; + } + } else + break; + } - // handle quoted strings specially - if (hlp.getchar() == '\"') { - hlp.nextchar(); - while (true) { - c = hlp.getchar(); - hlp.nextchar(); - if (c == '\"' || c == 0) { - return new String(com_token, 0, len); - } - if (len < Defines.MAX_TOKEN_CHARS) { - com_token[len] = (char) c; - len++; - } - } - } + // handle quoted strings specially + if (hlp.getchar() == '\"') { + hlp.nextchar(); + while (true) { + c = hlp.getchar(); + hlp.nextchar(); + if (c == '\"' || c == 0) { + return new String(com_token, 0, len); + } + if (len < Defines.MAX_TOKEN_CHARS) { + com_token[len] = (char) c; + len++; + } + } + } - // parse a regular word - c = hlp.getchar(); - do { - if (len < Defines.MAX_TOKEN_CHARS) { - com_token[len] = (char) c; - len++; - } - c = hlp.nextchar(); - } while (c > 32); + // parse a regular word + c = hlp.getchar(); + do { + if (len < Defines.MAX_TOKEN_CHARS) { + com_token[len] = (char) c; + len++; + } + c = hlp.nextchar(); + } while (c > 32); - if (len == Defines.MAX_TOKEN_CHARS) { - Com.Printf("Token exceeded " + Defines.MAX_TOKEN_CHARS + " chars, discarded.\n"); - len = 0; - } + if (len == Defines.MAX_TOKEN_CHARS) { + Com.Printf("Token exceeded " + Defines.MAX_TOKEN_CHARS + " chars, discarded.\n"); + len = 0; + } - return new String(com_token, 0, len); - } + return new String(com_token, 0, len); + } - public static Runnable Error_f= () -> Error(Defines.ERR_FATAL, Cmd.Argv(1)); + public static Runnable Error_f= () -> Error(Defines.ERR_FATAL, Cmd.Argv(1)); - public static void Error(int code, String fmt) throws IllegalStateException - { - Error(code, fmt, null); - } + public static void Error(int code, String fmt) throws IllegalStateException + { + Error(code, fmt, null); + } - public static void Error(int code, String fmt, Vargs vargs) throws IllegalStateException - { - // va_list argptr; - // static char msg[MAXPRINTMSG]; + public static void Error(int code, String fmt, Vargs vargs) throws IllegalStateException + { + // va_list argptr; + // static char msg[MAXPRINTMSG]; - if (recursive) - { - Sys.Error("recursive error after: " + msg); - } - recursive= true; + if (recursive) + { + Sys.Error("recursive error after: " + msg); + } + recursive= true; - msg= sprintf(fmt, vargs); + msg= sprintf(fmt, vargs); - if (code == Defines.ERR_DISCONNECT) - { - CL.Drop(); - recursive= false; - throw new IllegalStateException(); - } - else if (code == Defines.ERR_DROP) - { - Com.Printf("********************\nERROR: " + msg + "\n********************\n"); - SV_MAIN.SV_Shutdown("Server crashed: " + msg + "\n", false); - CL.Drop(); - recursive= false; - throw new IllegalStateException(); - } - else - { - SV_MAIN.SV_Shutdown("Server fatal crashed: %s" + msg + "\n", false); - CL.Shutdown(); - } + if (code == Defines.ERR_DISCONNECT) + { + CL.Drop(); + recursive= false; + throw new IllegalStateException(); + } + else if (code == Defines.ERR_DROP) + { + Com.Printf("********************\nERROR: " + msg + "\n********************\n"); + SV_MAIN.SV_Shutdown("Server crashed: " + msg + "\n", false); + CL.Drop(); + recursive= false; + throw new IllegalStateException(); + } + else + { + SV_MAIN.SV_Shutdown("Server fatal crashed: %s" + msg + "\n", false); + CL.Shutdown(); + } - Sys.Error(msg); - } + Sys.Error(msg); + } - /** - * Com_InitArgv checks the number of command line arguments - * and copies all arguments with valid length into com_argv. - */ - static void InitArgv(String[] args) throws IllegalStateException - { + /** + * Com_InitArgv checks the number of command line arguments + * and copies all arguments with valid length into com_argv. + */ + static void InitArgv(String[] args) throws IllegalStateException + { - if (args.length > Defines.MAX_NUM_ARGVS) - { - Com.Error(Defines.ERR_FATAL, "argc > MAX_NUM_ARGVS"); - } + if (args.length > Defines.MAX_NUM_ARGVS) + { + Com.Error(Defines.ERR_FATAL, "argc > MAX_NUM_ARGVS"); + } - Com.com_argc= args.length; - for (int i= 0; i < Com.com_argc; i++) - { - if (args[i].length() >= Defines.MAX_TOKEN_CHARS) - Com.com_argv[i]= ""; - else - Com.com_argv[i]= args[i]; - } - } + Com.com_argc= args.length; + for (int i= 0; i < Com.com_argc; i++) + { + if (args[i].length() >= Defines.MAX_TOKEN_CHARS) + Com.com_argv[i]= ""; + else + Com.com_argv[i]= args[i]; + } + } - public static void DPrintf(String fmt) - { - _debugContext = debugContext; - DPrintf(fmt, null); - _debugContext = ""; - } - - public static void dprintln(String fmt) - { - DPrintf(_debugContext + fmt + "\n", null); - } + public static void DPrintf(String fmt) + { + _debugContext = debugContext; + DPrintf(fmt, null); + _debugContext = ""; + } + + public static void dprintln(String fmt) + { + DPrintf(_debugContext + fmt + "\n", null); + } - public static void Printf(String fmt) - { - Printf(_debugContext + fmt, null); - } + public static void Printf(String fmt) + { + Printf(_debugContext + fmt, null); + } - public static void DPrintf(String fmt, Vargs vargs) - { - if (Globals.developer == null || Globals.developer.value == 0) - return; // don't confuse non-developers with techie stuff... - _debugContext = debugContext; - Printf(fmt, vargs); - _debugContext=""; - } + public static void DPrintf(String fmt, Vargs vargs) + { + if (Globals.developer == null || Globals.developer.value == 0) + return; // don't confuse non-developers with techie stuff... + _debugContext = debugContext; + Printf(fmt, vargs); + _debugContext=""; + } - /** Prints out messages, which can also be redirected to a remote client. */ - public static void Printf(String fmt, Vargs vargs) - { - String msg= sprintf(_debugContext + fmt, vargs); + /** Prints out messages, which can also be redirected to a remote client. */ + public static void Printf(String fmt, Vargs vargs) + { + String msg= sprintf(_debugContext + fmt, vargs); - // also echo to debugging console - while (msg.startsWith("\n")) { msg = msg.substring(1); } - while (msg.endsWith("\n")) { msg = msg.substring(0, msg.lastIndexOf("\n")); } - while (msg.endsWith("\r")) { msg = msg.substring(0, msg.lastIndexOf("\r")); } - msg = msg.trim(); - if (!msg.isEmpty()) { - log.warn(msg); - } - } + // also echo to debugging console + while (msg.startsWith("\n")) { msg = msg.substring(1); } + while (msg.endsWith("\n")) { msg = msg.substring(0, msg.lastIndexOf("\n")); } + while (msg.endsWith("\r")) { msg = msg.substring(0, msg.lastIndexOf("\r")); } + msg = msg.trim(); + if (!msg.isEmpty()) { + log.warn(msg); + } + } - public static String sprintf(String fmt, Vargs vargs) - { - String msg= ""; - if (vargs == null || vargs.size() == 0) - { - msg= fmt; - } - else - { - msg= new PrintfFormat(fmt).sprintf(vargs.toArray()); - } - return msg; - } + public static String sprintf(String fmt, Vargs vargs) + { + String msg= ""; + if (vargs == null || vargs.size() == 0) + { + msg= fmt; + } + else + { + msg= new PrintfFormat(fmt).sprintf(vargs.toArray()); + } + return msg; + } - public static int Argc() - { - return Com.com_argc; - } + public static int Argc() + { + return Com.com_argc; + } - public static String Argv(int arg) - { - if (arg < 0 || arg >= Com.com_argc || Com.com_argv[arg].length() < 1) - return ""; - return Com.com_argv[arg]; - } + public static String Argv(int arg) + { + if (arg < 0 || arg >= Com.com_argc || Com.com_argv[arg].length() < 1) + return ""; + return Com.com_argv[arg]; + } - public static void ClearArgv(int arg) - { - if (arg < 0 || arg >= Com.com_argc || Com.com_argv[arg].length() < 1) - return; - Com.com_argv[arg]= ""; - } + public static void ClearArgv(int arg) + { + if (arg < 0 || arg >= Com.com_argc || Com.com_argv[arg].length() < 1) + return; + Com.com_argv[arg]= ""; + } - public static void Quit() - { - SV_MAIN.SV_Shutdown("Server quit\n", false); - CL.Shutdown(); + public static void Quit() + { + SV_MAIN.SV_Shutdown("Server quit\n", false); + CL.Shutdown(); - if (Globals.logfile != null) - { - try - { - Globals.logfile.close(); - } - catch (IOException e) - { - } - Globals.logfile= null; - } + if (Globals.logfile != null) + { + try + { + Globals.logfile.close(); + } + catch (IOException e) + { + } + Globals.logfile= null; + } - Sys.Quit(); - } + Sys.Quit(); + } - public static void SetServerState(int i) - { - Globals.server_state= i; - } + public static void SetServerState(int i) + { + Globals.server_state= i; + } - public static int BlockChecksum(byte[] buf, int length) - { - return MD4.Com_BlockChecksum(buf, length); - } + public static int BlockChecksum(byte[] buf, int length) + { + return MD4.Com_BlockChecksum(buf, length); + } - public static String StripExtension(String string) { - int i = string.lastIndexOf('.'); - if (i < 0) - return string; - return string.substring(0, i); - } + public static String StripExtension(String string) { + int i = string.lastIndexOf('.'); + if (i < 0) + return string; + return string.substring(0, i); + } - /** - * CRC table. - */ - static byte chktbl[] = { (byte) 0x84, (byte) 0x47, (byte) 0x51, (byte) 0xc1, + /** + * CRC table. + */ + static byte chktbl[] = { (byte) 0x84, (byte) 0x47, (byte) 0x51, (byte) 0xc1, (byte) 0x93, (byte) 0x22, (byte) 0x21, (byte) 0x24, (byte) 0x2f, (byte) 0x66, (byte) 0x60, (byte) 0x4d, (byte) 0xb0, (byte) 0x7c, (byte) 0xda, (byte) 0x88, (byte) 0x54, (byte) 0x15, (byte) 0x2b, @@ -613,41 +613,41 @@ public final class Com { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - - static byte chkb[] = new byte [60 + 4]; - - /** - * Calculates a crc checksum-sequence over an array. - */ - public static byte BlockSequenceCRCByte(byte base[], int offset, int length, int sequence) - { - if (sequence < 0) - Sys.Error("sequence < 0, this shouldn't happen\n"); + + static byte chkb[] = new byte [60 + 4]; + + /** + * Calculates a crc checksum-sequence over an array. + */ + public static byte BlockSequenceCRCByte(byte base[], int offset, int length, int sequence) + { + if (sequence < 0) + Sys.Error("sequence < 0, this shouldn't happen\n"); - //p_ndx = (sequence % (sizeof(chktbl) - 4)); - int p_ndx = (sequence % (1024 - 4)); - - //memcpy(chkb, base, length); - length = Math.min(60, length); - System.arraycopy(base, offset , chkb, 0, length); - - chkb[length] = chktbl[p_ndx + 0]; - chkb[length + 1] = chktbl[p_ndx + 1]; - chkb[length + 2] = chktbl[p_ndx + 2]; - chkb[length + 3] = chktbl[p_ndx + 3]; - - length += 4; + //p_ndx = (sequence % (sizeof(chktbl) - 4)); + int p_ndx = (sequence % (1024 - 4)); + + //memcpy(chkb, base, length); + length = Math.min(60, length); + System.arraycopy(base, offset , chkb, 0, length); + + chkb[length] = chktbl[p_ndx + 0]; + chkb[length + 1] = chktbl[p_ndx + 1]; + chkb[length + 2] = chktbl[p_ndx + 2]; + chkb[length + 3] = chktbl[p_ndx + 3]; + + length += 4; - // unsigned short - int crc = CRC.CRC_Block(chkb, length); + // unsigned short + int crc = CRC.CRC_Block(chkb, length); - int x = 0; - for (int n=0; n < length; n++) - x += chkb[n] & 0xFF; + int x = 0; + for (int n=0; n < length; n++) + x += chkb[n] & 0xFF; - crc ^= x; + crc ^= x; - return (byte)(crc & 0xFF); - } + return (byte)(crc & 0xFF); + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/qcommon/Cvar.java b/src/main/java/lwjake2/qcommon/Cvar.java index fcbeb15..167e1a7 100644 --- a/src/main/java/lwjake2/qcommon/Cvar.java +++ b/src/main/java/lwjake2/qcommon/Cvar.java @@ -157,7 +157,7 @@ public class Cvar extends Globals { cvar_t var = Cvar.FindVar(var_name); if (var == null) { - // create it + // create it return Cvar.Get(var_name, value, 0); } diff --git a/src/main/java/lwjake2/qcommon/MD4.java b/src/main/java/lwjake2/qcommon/MD4.java index 837dac6..eff4b5d 100644 --- a/src/main/java/lwjake2/qcommon/MD4.java +++ b/src/main/java/lwjake2/qcommon/MD4.java @@ -24,279 +24,279 @@ import java.security.MessageDigest; public class MD4 extends MessageDigest implements Cloneable { - // MD4 specific object variables - //........................................................................... + // MD4 specific object variables + //........................................................................... - /** - * The size in bytes of the input block to the tranformation algorithm. - */ - private static final int BLOCK_LENGTH = 64; // = 512 / 8; + /** + * The size in bytes of the input block to the tranformation algorithm. + */ + private static final int BLOCK_LENGTH = 64; // = 512 / 8; - /** - * 4 32-bit words (interim result) - */ - private int[] context = new int[4]; + /** + * 4 32-bit words (interim result) + */ + private int[] context = new int[4]; - /** - * Number of bytes processed so far mod. 2 power of 64. - */ - private long count; + /** + * Number of bytes processed so far mod. 2 power of 64. + */ + private long count; - /** - * 512 bits input buffer = 16 x 32-bit words holds until reaches 512 bits. - */ - private byte[] buffer = new byte[BLOCK_LENGTH]; + /** + * 512 bits input buffer = 16 x 32-bit words holds until reaches 512 bits. + */ + private byte[] buffer = new byte[BLOCK_LENGTH]; - /** - * 512 bits work buffer = 16 x 32-bit words - */ - private int[] X = new int[16]; + /** + * 512 bits work buffer = 16 x 32-bit words + */ + private int[] X = new int[16]; - // Constructors - //........................................................................... + // Constructors + //........................................................................... - public MD4() { - super("MD4"); - engineReset(); - } + public MD4() { + super("MD4"); + engineReset(); + } - /** - * This constructor is here to implement cloneability of this class. - */ - private MD4(MD4 md) { - this(); - context = (int[]) md.context.clone(); - buffer = (byte[]) md.buffer.clone(); - count = md.count; - } + /** + * This constructor is here to implement cloneability of this class. + */ + private MD4(MD4 md) { + this(); + context = (int[]) md.context.clone(); + buffer = (byte[]) md.buffer.clone(); + count = md.count; + } - // Cloneable method implementation - //........................................................................... + // Cloneable method implementation + //........................................................................... - /** - * Returns a copy of this MD object. - */ - public Object clone() { - return new MD4(this); - } + /** + * Returns a copy of this MD object. + */ + public Object clone() { + return new MD4(this); + } - // JCE methods - //........................................................................... + // JCE methods + //........................................................................... - /** - * Resets this object disregarding any temporary data present at the - * time of the invocation of this call. - */ - public void engineReset() { - // initial values of MD4 i.e. A, B, C, D - // as per rfc-1320; they are low-order byte first - context[0] = 0x67452301; - context[1] = 0xEFCDAB89; - context[2] = 0x98BADCFE; - context[3] = 0x10325476; - count = 0L; - for (int i = 0; i < BLOCK_LENGTH; i++) - buffer[i] = 0; - } + /** + * Resets this object disregarding any temporary data present at the + * time of the invocation of this call. + */ + public void engineReset() { + // initial values of MD4 i.e. A, B, C, D + // as per rfc-1320; they are low-order byte first + context[0] = 0x67452301; + context[1] = 0xEFCDAB89; + context[2] = 0x98BADCFE; + context[3] = 0x10325476; + count = 0L; + for (int i = 0; i < BLOCK_LENGTH; i++) + buffer[i] = 0; + } - /** - * Continues an MD4 message digest using the input byte. - */ - public void engineUpdate(byte b) { - // compute number of bytes still unhashed; ie. present in buffer - int i = (int) (count % BLOCK_LENGTH); - count++; // update number of bytes - buffer[i] = b; - if (i == BLOCK_LENGTH - 1) - transform(buffer, 0); - } + /** + * Continues an MD4 message digest using the input byte. + */ + public void engineUpdate(byte b) { + // compute number of bytes still unhashed; ie. present in buffer + int i = (int) (count % BLOCK_LENGTH); + count++; // update number of bytes + buffer[i] = b; + if (i == BLOCK_LENGTH - 1) + transform(buffer, 0); + } - /** - * MD4 block update operation. - *

- * Continues an MD4 message digest operation, by filling the buffer, - * transform(ing) data in 512-bit message block(s), updating the variables - * context and count, and leaving (buffering) the remaining bytes in buffer - * for the next update or finish. - * - * @param input input block - * @param offset start of meaningful bytes in input - * @param len count of bytes in input block to consider - */ - public void engineUpdate(byte[] input, int offset, int len) { - // make sure we don't exceed input's allocated size/length - if (offset < 0 || len < 0 || (long) offset + len > input.length) - throw new ArrayIndexOutOfBoundsException(); + /** + * MD4 block update operation. + *

+ * Continues an MD4 message digest operation, by filling the buffer, + * transform(ing) data in 512-bit message block(s), updating the variables + * context and count, and leaving (buffering) the remaining bytes in buffer + * for the next update or finish. + * + * @param input input block + * @param offset start of meaningful bytes in input + * @param len count of bytes in input block to consider + */ + public void engineUpdate(byte[] input, int offset, int len) { + // make sure we don't exceed input's allocated size/length + if (offset < 0 || len < 0 || (long) offset + len > input.length) + throw new ArrayIndexOutOfBoundsException(); - // compute number of bytes still unhashed; ie. present in buffer - int bufferNdx = (int) (count % BLOCK_LENGTH); - count += len; // update number of bytes - int partLen = BLOCK_LENGTH - bufferNdx; - int i = 0; - if (len >= partLen) { - System.arraycopy(input, offset, buffer, bufferNdx, partLen); + // compute number of bytes still unhashed; ie. present in buffer + int bufferNdx = (int) (count % BLOCK_LENGTH); + count += len; // update number of bytes + int partLen = BLOCK_LENGTH - bufferNdx; + int i = 0; + if (len >= partLen) { + System.arraycopy(input, offset, buffer, bufferNdx, partLen); - transform(buffer, 0); + transform(buffer, 0); - for (i = partLen; i + BLOCK_LENGTH - 1 < len; i += BLOCK_LENGTH) - transform(input, offset + i); - bufferNdx = 0; - } - // buffer remaining input - if (i < len) - System.arraycopy(input, offset + i, buffer, bufferNdx, len - i); - } + for (i = partLen; i + BLOCK_LENGTH - 1 < len; i += BLOCK_LENGTH) + transform(input, offset + i); + bufferNdx = 0; + } + // buffer remaining input + if (i < len) + System.arraycopy(input, offset + i, buffer, bufferNdx, len - i); + } - /** - * Completes the hash computation by performing final operations such - * as padding. At the return of this engineDigest, the MD engine is - * reset. - * - * @return the array of bytes for the resulting hash value. - */ - public byte[] engineDigest() { - // pad output to 56 mod 64; as RFC1320 puts it: congruent to 448 mod 512 - int bufferNdx = (int) (count % BLOCK_LENGTH); - int padLen = (bufferNdx < 56) ? (56 - bufferNdx) : (120 - bufferNdx); + /** + * Completes the hash computation by performing final operations such + * as padding. At the return of this engineDigest, the MD engine is + * reset. + * + * @return the array of bytes for the resulting hash value. + */ + public byte[] engineDigest() { + // pad output to 56 mod 64; as RFC1320 puts it: congruent to 448 mod 512 + int bufferNdx = (int) (count % BLOCK_LENGTH); + int padLen = (bufferNdx < 56) ? (56 - bufferNdx) : (120 - bufferNdx); - // padding is alwas binary 1 followed by binary 0s - byte[] tail = new byte[padLen + 8]; - tail[0] = (byte) 0x80; + // padding is alwas binary 1 followed by binary 0s + byte[] tail = new byte[padLen + 8]; + tail[0] = (byte) 0x80; - // append length before final transform: - // save number of bits, casting the long to an array of 8 bytes - // save low-order byte first. - for (int i = 0; i < 8; i++) - tail[padLen + i] = (byte) ((count * 8) >>> (8 * i)); + // append length before final transform: + // save number of bits, casting the long to an array of 8 bytes + // save low-order byte first. + for (int i = 0; i < 8; i++) + tail[padLen + i] = (byte) ((count * 8) >>> (8 * i)); - engineUpdate(tail, 0, tail.length); + engineUpdate(tail, 0, tail.length); - byte[] result = new byte[16]; - // cast this MD4's context (array of 4 ints) into an array of 16 bytes. - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) - result[i * 4 + j] = (byte) (context[i] >>> (8 * j)); + byte[] result = new byte[16]; + // cast this MD4's context (array of 4 ints) into an array of 16 bytes. + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + result[i * 4 + j] = (byte) (context[i] >>> (8 * j)); - // reset the engine - engineReset(); - return result; - } + // reset the engine + engineReset(); + return result; + } - // own methods - //........................................................................... + // own methods + //........................................................................... - /** - * MD4 basic transformation. - *

- * Transforms context based on 512 bits from input block starting - * from the offset'th byte. - * - * @param block input sub-array. - * @param offset starting position of sub-array. - */ - private void transform(byte[] block, int offset) { + /** + * MD4 basic transformation. + *

+ * Transforms context based on 512 bits from input block starting + * from the offset'th byte. + * + * @param block input sub-array. + * @param offset starting position of sub-array. + */ + private void transform(byte[] block, int offset) { - // encodes 64 bytes from input block into an array of 16 32-bit - // entities. Use A as a temp var. - for (int i = 0; i < 16; i++) - X[i] = - (block[offset++] & 0xFF) | (block[offset++] & 0xFF) - << 8 | (block[offset++] & 0xFF) - << 16 | (block[offset++] & 0xFF) - << 24; + // encodes 64 bytes from input block into an array of 16 32-bit + // entities. Use A as a temp var. + for (int i = 0; i < 16; i++) + X[i] = + (block[offset++] & 0xFF) | (block[offset++] & 0xFF) + << 8 | (block[offset++] & 0xFF) + << 16 | (block[offset++] & 0xFF) + << 24; - int A = context[0]; - int B = context[1]; - int C = context[2]; - int D = context[3]; + int A = context[0]; + int B = context[1]; + int C = context[2]; + int D = context[3]; - A = FF(A, B, C, D, X[0], 3); - D = FF(D, A, B, C, X[1], 7); - C = FF(C, D, A, B, X[2], 11); - B = FF(B, C, D, A, X[3], 19); - A = FF(A, B, C, D, X[4], 3); - D = FF(D, A, B, C, X[5], 7); - C = FF(C, D, A, B, X[6], 11); - B = FF(B, C, D, A, X[7], 19); - A = FF(A, B, C, D, X[8], 3); - D = FF(D, A, B, C, X[9], 7); - C = FF(C, D, A, B, X[10], 11); - B = FF(B, C, D, A, X[11], 19); - A = FF(A, B, C, D, X[12], 3); - D = FF(D, A, B, C, X[13], 7); - C = FF(C, D, A, B, X[14], 11); - B = FF(B, C, D, A, X[15], 19); + A = FF(A, B, C, D, X[0], 3); + D = FF(D, A, B, C, X[1], 7); + C = FF(C, D, A, B, X[2], 11); + B = FF(B, C, D, A, X[3], 19); + A = FF(A, B, C, D, X[4], 3); + D = FF(D, A, B, C, X[5], 7); + C = FF(C, D, A, B, X[6], 11); + B = FF(B, C, D, A, X[7], 19); + A = FF(A, B, C, D, X[8], 3); + D = FF(D, A, B, C, X[9], 7); + C = FF(C, D, A, B, X[10], 11); + B = FF(B, C, D, A, X[11], 19); + A = FF(A, B, C, D, X[12], 3); + D = FF(D, A, B, C, X[13], 7); + C = FF(C, D, A, B, X[14], 11); + B = FF(B, C, D, A, X[15], 19); - A = GG(A, B, C, D, X[0], 3); - D = GG(D, A, B, C, X[4], 5); - C = GG(C, D, A, B, X[8], 9); - B = GG(B, C, D, A, X[12], 13); - A = GG(A, B, C, D, X[1], 3); - D = GG(D, A, B, C, X[5], 5); - C = GG(C, D, A, B, X[9], 9); - B = GG(B, C, D, A, X[13], 13); - A = GG(A, B, C, D, X[2], 3); - D = GG(D, A, B, C, X[6], 5); - C = GG(C, D, A, B, X[10], 9); - B = GG(B, C, D, A, X[14], 13); - A = GG(A, B, C, D, X[3], 3); - D = GG(D, A, B, C, X[7], 5); - C = GG(C, D, A, B, X[11], 9); - B = GG(B, C, D, A, X[15], 13); + A = GG(A, B, C, D, X[0], 3); + D = GG(D, A, B, C, X[4], 5); + C = GG(C, D, A, B, X[8], 9); + B = GG(B, C, D, A, X[12], 13); + A = GG(A, B, C, D, X[1], 3); + D = GG(D, A, B, C, X[5], 5); + C = GG(C, D, A, B, X[9], 9); + B = GG(B, C, D, A, X[13], 13); + A = GG(A, B, C, D, X[2], 3); + D = GG(D, A, B, C, X[6], 5); + C = GG(C, D, A, B, X[10], 9); + B = GG(B, C, D, A, X[14], 13); + A = GG(A, B, C, D, X[3], 3); + D = GG(D, A, B, C, X[7], 5); + C = GG(C, D, A, B, X[11], 9); + B = GG(B, C, D, A, X[15], 13); - A = HH(A, B, C, D, X[0], 3); - D = HH(D, A, B, C, X[8], 9); - C = HH(C, D, A, B, X[4], 11); - B = HH(B, C, D, A, X[12], 15); - A = HH(A, B, C, D, X[2], 3); - D = HH(D, A, B, C, X[10], 9); - C = HH(C, D, A, B, X[6], 11); - B = HH(B, C, D, A, X[14], 15); - A = HH(A, B, C, D, X[1], 3); - D = HH(D, A, B, C, X[9], 9); - C = HH(C, D, A, B, X[5], 11); - B = HH(B, C, D, A, X[13], 15); - A = HH(A, B, C, D, X[3], 3); - D = HH(D, A, B, C, X[11], 9); - C = HH(C, D, A, B, X[7], 11); - B = HH(B, C, D, A, X[15], 15); + A = HH(A, B, C, D, X[0], 3); + D = HH(D, A, B, C, X[8], 9); + C = HH(C, D, A, B, X[4], 11); + B = HH(B, C, D, A, X[12], 15); + A = HH(A, B, C, D, X[2], 3); + D = HH(D, A, B, C, X[10], 9); + C = HH(C, D, A, B, X[6], 11); + B = HH(B, C, D, A, X[14], 15); + A = HH(A, B, C, D, X[1], 3); + D = HH(D, A, B, C, X[9], 9); + C = HH(C, D, A, B, X[5], 11); + B = HH(B, C, D, A, X[13], 15); + A = HH(A, B, C, D, X[3], 3); + D = HH(D, A, B, C, X[11], 9); + C = HH(C, D, A, B, X[7], 11); + B = HH(B, C, D, A, X[15], 15); - context[0] += A; - context[1] += B; - context[2] += C; - context[3] += D; - } + context[0] += A; + context[1] += B; + context[2] += C; + context[3] += D; + } - // The basic MD4 atomic functions. + // The basic MD4 atomic functions. - private int FF(int a, int b, int c, int d, int x, int s) { - int t = a + ((b & c) | (~b & d)) + x; - return t << s | t >>> (32 - s); - } - - private int GG(int a, int b, int c, int d, int x, int s) { - int t = a + ((b & (c | d)) | (c & d)) + x + 0x5A827999; - return t << s | t >>> (32 - s); - } - - private int HH(int a, int b, int c, int d, int x, int s) { - int t = a + (b ^ c ^ d) + x + 0x6ED9EBA1; - return t << s | t >>> (32 - s); - } + private int FF(int a, int b, int c, int d, int x, int s) { + int t = a + ((b & c) | (~b & d)) + x; + return t << s | t >>> (32 - s); + } + + private int GG(int a, int b, int c, int d, int x, int s) { + int t = a + ((b & (c | d)) | (c & d)) + x + 0x5A827999; + return t << s | t >>> (32 - s); + } + + private int HH(int a, int b, int c, int d, int x, int s) { + int t = a + (b ^ c ^ d) + x + 0x6ED9EBA1; + return t << s | t >>> (32 - s); + } - /** - * Bugfixed, now works prima (RST). - */ - public static int Com_BlockChecksum(byte[] buffer, int length) { - - int val; - MD4 md4 = new MD4(); + /** + * Bugfixed, now works prima (RST). + */ + public static int Com_BlockChecksum(byte[] buffer, int length) { + + int val; + MD4 md4 = new MD4(); - md4.engineUpdate(buffer, 0, length); - byte data[] = md4.engineDigest(); - ByteBuffer bb = ByteBuffer.wrap(data); - bb.order(ByteOrder.LITTLE_ENDIAN); - val = bb.getInt() ^ bb.getInt() ^ bb.getInt() ^ bb.getInt(); - return val; - } + md4.engineUpdate(buffer, 0, length); + byte data[] = md4.engineDigest(); + ByteBuffer bb = ByteBuffer.wrap(data); + bb.order(ByteOrder.LITTLE_ENDIAN); + val = bb.getInt() ^ bb.getInt() ^ bb.getInt() ^ bb.getInt(); + return val; + } } diff --git a/src/main/java/lwjake2/qcommon/PMove.java b/src/main/java/lwjake2/qcommon/PMove.java index 1530766..83acf90 100644 --- a/src/main/java/lwjake2/qcommon/PMove.java +++ b/src/main/java/lwjake2/qcommon/PMove.java @@ -151,7 +151,7 @@ public class PMove { // slide along this plane if (numplanes >= SV.MAX_CLIP_PLANES) { - // this shouldn't really happen + // this shouldn't really happen Math3D.VectorCopy(Globals.vec3_origin, pml.velocity); break; } @@ -173,9 +173,9 @@ public class PMove { } if (i != numplanes) { - // go along this plane + // go along this plane } else { - // go along the crease + // go along the crease if (numplanes != 2) { // Com.printf("clip velocity, numplanes == " + numplanes + "\n"); Math3D.VectorCopy(Globals.vec3_origin, pml.velocity); @@ -212,7 +212,7 @@ public class PMove { float[] down_o = { 0, 0, 0 }, down_v = { 0, 0, 0 }; trace_t trace; float down_dist, up_dist; - // float [] delta; + // float [] delta; float[] up = { 0, 0, 0 }, down = { 0, 0, 0 }; Math3D.VectorCopy(pml.origin, start_o); @@ -285,7 +285,7 @@ public class PMove { // apply ground friction if ((pm.groundentity != null && pml.groundsurface != null && - 0 == (pml.groundsurface.flags & Defines.SURF_SLICK)) + 0 == (pml.groundsurface.flags & Defines.SURF_SLICK)) || (pml.ladder)) { friction = pm_friction; control = speed < pm_stopspeed ? pm_stopspeed : speed; @@ -520,7 +520,7 @@ public class PMove { PM_Accelerate(wishdir, wishspeed, pm_accelerate); // PGM -- fix for negative trigger_gravity fields - // pml.velocity[2] = 0; + // pml.velocity[2] = 0; if (pm.s.gravity > 0) pml.velocity[2] = 0; else @@ -582,8 +582,8 @@ public class PMove { } if (0 == (pm.s.pm_flags & pmove_t.PMF_ON_GROUND)) { - - // just hit the ground + + // just hit the ground pm.s.pm_flags |= pmove_t.PMF_ON_GROUND; // don't do landing time if we were just going down a slope if (pml.velocity[2] < -200) { @@ -1068,12 +1068,12 @@ public class PMove { } if ((pm.s.pm_flags & pmove_t.PMF_TIME_TELEPORT) != 0) { - // teleport pause stays exaclty in place + // teleport pause stays exaclty in place } else if ((pm.s.pm_flags & pmove_t.PMF_TIME_WATERJUMP) != 0) { - // waterjump has no control, but falls + // waterjump has no control, but falls pml.velocity[2] -= pm.s.gravity * pml.frametime; if (pml.velocity[2] < 0) { - // cancel as soon as we are falling down again + // cancel as soon as we are falling down again pm.s.pm_flags &= ~(pmove_t.PMF_TIME_WATERJUMP | pmove_t.PMF_TIME_LAND | pmove_t.PMF_TIME_TELEPORT); pm.s.pm_time = 0; diff --git a/src/main/java/lwjake2/qcommon/Qcommon.java b/src/main/java/lwjake2/qcommon/Qcommon.java index 299d59d..ae284cc 100644 --- a/src/main/java/lwjake2/qcommon/Qcommon.java +++ b/src/main/java/lwjake2/qcommon/Qcommon.java @@ -39,213 +39,213 @@ import java.io.IOException; */ @Slf4j public final class Qcommon extends Globals { - private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); - public static final String BUILDSTRING = "Java " + System.getProperty("java.version");; - public static final String CPUSTRING = System.getProperty("os.arch"); + private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); + public static final String BUILDSTRING = "Java " + System.getProperty("java.version");; + public static final String CPUSTRING = System.getProperty("os.arch"); - /** - * This function initializes the different subsystems of - * the game engine. The setjmp/longjmp mechanism of the original - * was replaced with exceptions. - * @param args the original unmodified command line arguments - */ - public static void Init(String[] args) { - try { + /** + * This function initializes the different subsystems of + * the game engine. The setjmp/longjmp mechanism of the original + * was replaced with exceptions. + * @param args the original unmodified command line arguments + */ + public static void Init(String[] args) { + try { - // prepare enough of the subsystems to handle - // cvar and command buffer management - Com.InitArgv(args); + // prepare enough of the subsystems to handle + // cvar and command buffer management + Com.InitArgv(args); - Cbuf.Init(); - - Cmd.Init(); - Cvar.Init(); + Cbuf.Init(); + + Cmd.Init(); + Cvar.Init(); - Key.Init(); + Key.Init(); - // we need to add the early commands twice, because - // a basedir or cddir needs to be set before execing - // config files, but we want other parms to override - // the settings of the config files - Cbuf.AddEarlyCommands(false); - Cbuf.Execute(); - - fileSystem.init(); - - reconfigure(false); + // we need to add the early commands twice, because + // a basedir or cddir needs to be set before execing + // config files, but we want other parms to override + // the settings of the config files + Cbuf.AddEarlyCommands(false); + Cbuf.Execute(); + + fileSystem.init(); + + reconfigure(false); - fileSystem.setCDDir(); // use cddir from config.cfg - fileSystem.markBaseSearchPaths(); // mark the default search paths - fileSystem.checkOverride(); - - reconfigure(true); // reload default.cfg and config.cfg - - // - // init commands and vars - // - Cmd.AddCommand("error", Com.Error_f); + fileSystem.setCDDir(); // use cddir from config.cfg + fileSystem.markBaseSearchPaths(); // mark the default search paths + fileSystem.checkOverride(); + + reconfigure(true); // reload default.cfg and config.cfg + + // + // init commands and vars + // + Cmd.AddCommand("error", Com.Error_f); - Globals.host_speeds= Cvar.Get("host_speeds", "0", 0); - Globals.log_stats= Cvar.Get("log_stats", "0", 0); - Globals.developer= Cvar.Get("developer", "0", CVAR_ARCHIVE); - Globals.timescale= Cvar.Get("timescale", "0", 0); - Globals.fixedtime= Cvar.Get("fixedtime", "0", 0); - Globals.logfile_active= Cvar.Get("logfile", "0", 0); - Globals.showtrace= Cvar.Get("showtrace", "0", 0); - Globals.dedicated= Cvar.Get("dedicated", "0", CVAR_NOSET); - String s = Com.sprintf("%4.2f %s %s %s", - new Vargs(4) - .add(Globals.VERSION) - .add(CPUSTRING) - .add(Globals.__DATE__) - .add(BUILDSTRING)); + Globals.host_speeds= Cvar.Get("host_speeds", "0", 0); + Globals.log_stats= Cvar.Get("log_stats", "0", 0); + Globals.developer= Cvar.Get("developer", "0", CVAR_ARCHIVE); + Globals.timescale= Cvar.Get("timescale", "0", 0); + Globals.fixedtime= Cvar.Get("fixedtime", "0", 0); + Globals.logfile_active= Cvar.Get("logfile", "0", 0); + Globals.showtrace= Cvar.Get("showtrace", "0", 0); + Globals.dedicated= Cvar.Get("dedicated", "0", CVAR_NOSET); + String s = Com.sprintf("%4.2f %s %s %s", + new Vargs(4) + .add(Globals.VERSION) + .add(CPUSTRING) + .add(Globals.__DATE__) + .add(BUILDSTRING)); - Cvar.Get("version", s, CVAR_SERVERINFO | CVAR_NOSET); - - NET.Init(); //ok - Netchan.Netchan_Init(); //ok + Cvar.Get("version", s, CVAR_SERVERINFO | CVAR_NOSET); + + NET.Init(); //ok + Netchan.Netchan_Init(); //ok - SV_MAIN.SV_Init(); //ok - - CL.Init(); + SV_MAIN.SV_Init(); //ok + + CL.Init(); - // add + commands from command line - if (!Cbuf.AddLateCommands()) { - // if the user didn't give any commands, run default action - if (Globals.dedicated.value == 0) - Cbuf.AddText ("d1\n"); - else - Cbuf.AddText ("dedicated_start\n"); - - Cbuf.Execute(); - } else { - // the user asked for something explicit - // so drop the loading plaque - SCR.EndLoadingPlaque(); - } + // add + commands from command line + if (!Cbuf.AddLateCommands()) { + // if the user didn't give any commands, run default action + if (Globals.dedicated.value == 0) + Cbuf.AddText ("d1\n"); + else + Cbuf.AddText ("dedicated_start\n"); + + Cbuf.Execute(); + } else { + // the user asked for something explicit + // so drop the loading plaque + SCR.EndLoadingPlaque(); + } - log.info("====== Quake2 Initialized ======"); + log.info("====== Quake2 Initialized ======"); - // save config when configuration is completed - CL.WriteConfiguration(); + // save config when configuration is completed + CL.WriteConfiguration(); - } catch (IllegalStateException e) { - Sys.Error("Error during initialization"); - } - } + } catch (IllegalStateException e) { + Sys.Error("Error during initialization"); + } + } - /** - * Trigger generation of a frame for the given time. The setjmp/longjmp - * mechanism of the original was replaced with exceptions. - * @param msec the current game time - */ - public static void Frame(int msec) { - try { + /** + * Trigger generation of a frame for the given time. The setjmp/longjmp + * mechanism of the original was replaced with exceptions. + * @param msec the current game time + */ + public static void Frame(int msec) { + try { - if (Globals.log_stats.modified) { - Globals.log_stats.modified= false; + if (Globals.log_stats.modified) { + Globals.log_stats.modified= false; - if (Globals.log_stats.value != 0.0f) { + if (Globals.log_stats.value != 0.0f) { - try { - Globals.log_stats_file.close(); - } catch (IOException e) { - } - Globals.log_stats_file= null; + try { + Globals.log_stats_file.close(); + } catch (IOException e) { + } + Globals.log_stats_file= null; - try { - Globals.log_stats_file= new FileWriter("stats.log"); - } catch (IOException e) { - Globals.log_stats_file= null; - } - if (Globals.log_stats_file != null) { - try { - Globals.log_stats_file.write("entities,dlights,parts,frame time\n"); - } catch (IOException e) { - } - } + try { + Globals.log_stats_file= new FileWriter("stats.log"); + } catch (IOException e) { + Globals.log_stats_file= null; + } + if (Globals.log_stats_file != null) { + try { + Globals.log_stats_file.write("entities,dlights,parts,frame time\n"); + } catch (IOException e) { + } + } - } else { + } else { - if (Globals.log_stats_file != null) { - try { - Globals.log_stats_file.close(); - } catch (IOException e) { - } - Globals.log_stats_file= null; - } - } - } + if (Globals.log_stats_file != null) { + try { + Globals.log_stats_file.close(); + } catch (IOException e) { + } + Globals.log_stats_file= null; + } + } + } - if (Globals.fixedtime.value != 0.0f) { - msec= (int) Globals.fixedtime.value; - } else if (Globals.timescale.value != 0.0f) { - msec *= Globals.timescale.value; - if (msec < 1) - msec= 1; - } + if (Globals.fixedtime.value != 0.0f) { + msec= (int) Globals.fixedtime.value; + } else if (Globals.timescale.value != 0.0f) { + msec *= Globals.timescale.value; + if (msec < 1) + msec= 1; + } - if (Globals.showtrace.value != 0.0f) { - log.info(String.format("%4d traces %4d points", Globals.c_traces, Globals.c_pointcontents)); + if (Globals.showtrace.value != 0.0f) { + log.info(String.format("%4d traces %4d points", Globals.c_traces, Globals.c_pointcontents)); - - Globals.c_traces= 0; - Globals.c_brush_traces= 0; - Globals.c_pointcontents= 0; - } + + Globals.c_traces= 0; + Globals.c_brush_traces= 0; + Globals.c_pointcontents= 0; + } - Cbuf.Execute(); + Cbuf.Execute(); - int time_before= 0; - int time_between= 0; - int time_after= 0; + int time_before= 0; + int time_between= 0; + int time_after= 0; - if (Globals.host_speeds.value != 0.0f) - time_before= Timer.Milliseconds(); - - Com.debugContext = "SV:"; - SV_MAIN.SV_Frame(msec); + if (Globals.host_speeds.value != 0.0f) + time_before= Timer.Milliseconds(); + + Com.debugContext = "SV:"; + SV_MAIN.SV_Frame(msec); - if (Globals.host_speeds.value != 0.0f) - time_between= Timer.Milliseconds(); - - Com.debugContext = "CL:"; - CL.Frame(msec); + if (Globals.host_speeds.value != 0.0f) + time_between= Timer.Milliseconds(); + + Com.debugContext = "CL:"; + CL.Frame(msec); - if (Globals.host_speeds.value != 0.0f) { - time_after= Timer.Milliseconds(); + if (Globals.host_speeds.value != 0.0f) { + time_after= Timer.Milliseconds(); - int all= time_after - time_before; - int sv= time_between - time_before; - int cl= time_after - time_between; - int gm= Globals.time_after_game - Globals.time_before_game; - int rf= Globals.time_after_ref - Globals.time_before_ref; - sv -= gm; - cl -= rf; + int all= time_after - time_before; + int sv= time_between - time_before; + int cl= time_after - time_between; + int gm= Globals.time_after_game - Globals.time_before_game; + int rf= Globals.time_after_ref - Globals.time_before_ref; + sv -= gm; + cl -= rf; - log.info(String.format("all:%3d sv:%3d gm:%3d cl:%3d rf:%3d", all, sv, gm, cl, rf)); - } + log.info(String.format("all:%3d sv:%3d gm:%3d cl:%3d rf:%3d", all, sv, gm, cl, rf)); + } - } catch (IllegalStateException e) { - Com.DPrintf("lonjmp exception:" + e); - } - } + } catch (IllegalStateException e) { + Com.DPrintf("lonjmp exception:" + e); + } + } - static void reconfigure(boolean clear) { - String dir = Cvar.Get("cddir", "", CVAR_ARCHIVE).string; - Cbuf.AddText("exec default.cfg\n"); - Cbuf.AddText("bind MWHEELUP weapnext\n"); - Cbuf.AddText("bind MWHEELDOWN weapprev\n"); - Cbuf.AddText("bind w +forward\n"); - Cbuf.AddText("bind s +back\n"); - Cbuf.AddText("bind a +moveleft\n"); - Cbuf.AddText("bind d +moveright\n"); - Cbuf.Execute(); - Cvar.Set("vid_fullscreen", "0"); - Cbuf.AddText("exec config.cfg\n"); + static void reconfigure(boolean clear) { + String dir = Cvar.Get("cddir", "", CVAR_ARCHIVE).string; + Cbuf.AddText("exec default.cfg\n"); + Cbuf.AddText("bind MWHEELUP weapnext\n"); + Cbuf.AddText("bind MWHEELDOWN weapprev\n"); + Cbuf.AddText("bind w +forward\n"); + Cbuf.AddText("bind s +back\n"); + Cbuf.AddText("bind a +moveleft\n"); + Cbuf.AddText("bind d +moveright\n"); + Cbuf.Execute(); + Cvar.Set("vid_fullscreen", "0"); + Cbuf.AddText("exec config.cfg\n"); - Cbuf.AddEarlyCommands(clear); - Cbuf.Execute(); - if (!("".equals(dir))) Cvar.Set("cddir", dir); - } + Cbuf.AddEarlyCommands(clear); + Cbuf.Execute(); + if (!("".equals(dir))) Cvar.Set("cddir", dir); + } } diff --git a/src/main/java/lwjake2/qcommon/SZ.java b/src/main/java/lwjake2/qcommon/SZ.java index 67e45eb..6a00558 100644 --- a/src/main/java/lwjake2/qcommon/SZ.java +++ b/src/main/java/lwjake2/qcommon/SZ.java @@ -26,80 +26,80 @@ import lwjake2.util.Lib; */ public final class SZ { - public static void Clear(sizebuf_t buf) { - buf.clear(); - } + public static void Clear(sizebuf_t buf) { + buf.clear(); + } - //=========================================================================== - - public static void Init(sizebuf_t buf, byte data[], int length) { - // TODO check this. cwei - buf.readcount = 0; + //=========================================================================== + + public static void Init(sizebuf_t buf, byte data[], int length) { + // TODO check this. cwei + buf.readcount = 0; - buf.data = data; - buf.maxsize = length; - buf.cursize = 0; - buf.allowoverflow = buf.overflowed = false; - } + buf.data = data; + buf.maxsize = length; + buf.cursize = 0; + buf.allowoverflow = buf.overflowed = false; + } - /** Ask for the pointer using sizebuf_t.cursize (RST) */ - public static int GetSpace(sizebuf_t buf, int length) { - int oldsize; - - if (buf.cursize + length > buf.maxsize) { - if (!buf.allowoverflow) - Com.Error(Defines.ERR_FATAL, "SZ_GetSpace: overflow without allowoverflow set"); - - if (length > buf.maxsize) - Com.Error(Defines.ERR_FATAL, "SZ_GetSpace: " + length + " is > full buffer size"); - - Com.Printf("SZ_GetSpace: overflow\n"); - Clear(buf); - buf.overflowed = true; - } - - oldsize = buf.cursize; - buf.cursize += length; - - return oldsize; - } + /** Ask for the pointer using sizebuf_t.cursize (RST) */ + public static int GetSpace(sizebuf_t buf, int length) { + int oldsize; + + if (buf.cursize + length > buf.maxsize) { + if (!buf.allowoverflow) + Com.Error(Defines.ERR_FATAL, "SZ_GetSpace: overflow without allowoverflow set"); + + if (length > buf.maxsize) + Com.Error(Defines.ERR_FATAL, "SZ_GetSpace: " + length + " is > full buffer size"); + + Com.Printf("SZ_GetSpace: overflow\n"); + Clear(buf); + buf.overflowed = true; + } + + oldsize = buf.cursize; + buf.cursize += length; + + return oldsize; + } - public static void Write(sizebuf_t buf, byte data[], int length) { - //memcpy(SZ_GetSpace(buf, length), data, length); - System.arraycopy(data, 0, buf.data, GetSpace(buf, length), length); - } + public static void Write(sizebuf_t buf, byte data[], int length) { + //memcpy(SZ_GetSpace(buf, length), data, length); + System.arraycopy(data, 0, buf.data, GetSpace(buf, length), length); + } - public static void Write(sizebuf_t buf, byte data[], int offset, int length) { - System.arraycopy(data, offset, buf.data, GetSpace(buf, length), length); - } + public static void Write(sizebuf_t buf, byte data[], int offset, int length) { + System.arraycopy(data, offset, buf.data, GetSpace(buf, length), length); + } - public static void Write(sizebuf_t buf, byte data[]) { - int length = data.length; - //memcpy(SZ_GetSpace(buf, length), data, length); - System.arraycopy(data, 0, buf.data, GetSpace(buf, length), length); - } + public static void Write(sizebuf_t buf, byte data[]) { + int length = data.length; + //memcpy(SZ_GetSpace(buf, length), data, length); + System.arraycopy(data, 0, buf.data, GetSpace(buf, length), length); + } - // - public static void Print(sizebuf_t buf, String data) { - Com.dprintln("SZ.print():<" + data + ">" ); - int length = data.length(); - byte str[] = Lib.stringToBytes(data); - - if (buf.cursize != 0) { - - if (buf.data[buf.cursize - 1] != 0) { - //memcpy( SZ_GetSpace(buf, len), data, len); // no trailing 0 - System.arraycopy(str, 0, buf.data, GetSpace(buf, length+1), length); - } else { - System.arraycopy(str, 0, buf.data, GetSpace(buf, length)-1, length); - //memcpy(SZ_GetSpace(buf, len - 1) - 1, data, len); // write over trailing 0 - } - } else - // first print. - System.arraycopy(str, 0, buf.data, GetSpace(buf, length), length); - //memcpy(SZ_GetSpace(buf, len), data, len); - - buf.data[buf.cursize - 1]=0; - } + // + public static void Print(sizebuf_t buf, String data) { + Com.dprintln("SZ.print():<" + data + ">" ); + int length = data.length(); + byte str[] = Lib.stringToBytes(data); + + if (buf.cursize != 0) { + + if (buf.data[buf.cursize - 1] != 0) { + //memcpy( SZ_GetSpace(buf, len), data, len); // no trailing 0 + System.arraycopy(str, 0, buf.data, GetSpace(buf, length+1), length); + } else { + System.arraycopy(str, 0, buf.data, GetSpace(buf, length)-1, length); + //memcpy(SZ_GetSpace(buf, len - 1) - 1, data, len); // write over trailing 0 + } + } else + // first print. + System.arraycopy(str, 0, buf.data, GetSpace(buf, length), length); + //memcpy(SZ_GetSpace(buf, len), data, len); + + buf.data[buf.cursize - 1]=0; + } } diff --git a/src/main/java/lwjake2/qcommon/cmd_function_t.java b/src/main/java/lwjake2/qcommon/cmd_function_t.java index 7552dcd..ff7a3b6 100644 --- a/src/main/java/lwjake2/qcommon/cmd_function_t.java +++ b/src/main/java/lwjake2/qcommon/cmd_function_t.java @@ -22,7 +22,7 @@ package lwjake2.qcommon; * cmd_function_t */ public final class cmd_function_t { - public cmd_function_t next = null; - public String name = null; - public Runnable function; + public cmd_function_t next = null; + public String name = null; + public Runnable function; } diff --git a/src/main/java/lwjake2/qcommon/lump_t.java b/src/main/java/lwjake2/qcommon/lump_t.java index cc65368..c37e51c 100644 --- a/src/main/java/lwjake2/qcommon/lump_t.java +++ b/src/main/java/lwjake2/qcommon/lump_t.java @@ -20,11 +20,11 @@ package lwjake2.qcommon; public class lump_t { - public lump_t(int offset, int len) - { - this.fileofs = offset; - this.filelen = len; - } + public lump_t(int offset, int len) + { + this.fileofs = offset; + this.filelen = len; + } - public int fileofs, filelen; + public int fileofs, filelen; } diff --git a/src/main/java/lwjake2/qcommon/miptex_t.java b/src/main/java/lwjake2/qcommon/miptex_t.java index 0c7f5ad..74f67a0 100644 --- a/src/main/java/lwjake2/qcommon/miptex_t.java +++ b/src/main/java/lwjake2/qcommon/miptex_t.java @@ -21,18 +21,18 @@ package lwjake2.qcommon; import lwjake2.Defines; public class miptex_t { - //char name[32]; - String name=""; - - int width, height; - - //unsigned offsets[MIPLEVELS]; // four mip maps stored - int offsets[] = new int[Defines.MIPLEVELS]; // four mip maps stored - - //char animname[32]; // next frame in animation chain - String animframe=""; - - int flags; - int contents; - int value; + //char name[32]; + String name=""; + + int width, height; + + //unsigned offsets[MIPLEVELS]; // four mip maps stored + int offsets[] = new int[Defines.MIPLEVELS]; // four mip maps stored + + //char animname[32]; // next frame in animation chain + String animframe=""; + + int flags; + int contents; + int value; } diff --git a/src/main/java/lwjake2/qcommon/netadr_t.java b/src/main/java/lwjake2/qcommon/netadr_t.java index e099539..4b00544 100644 --- a/src/main/java/lwjake2/qcommon/netadr_t.java +++ b/src/main/java/lwjake2/qcommon/netadr_t.java @@ -36,7 +36,7 @@ public class netadr_t { this.type = Defines.NA_LOOPBACK; this.port = 0; // any try { - // localhost / 127.0.0.1 + // localhost / 127.0.0.1 this.ip = InetAddress.getByName(null).getAddress(); } catch (UnknownHostException e) { } @@ -47,7 +47,7 @@ public class netadr_t { case Defines.NA_BROADCAST: return InetAddress.getByName("255.255.255.255"); case Defines.NA_LOOPBACK: - // localhost / 127.0.0.1 + // localhost / 127.0.0.1 return InetAddress.getByName(null); case Defines.NA_IP: return InetAddress.getByAddress(ip); diff --git a/src/main/java/lwjake2/qcommon/netchan_t.java b/src/main/java/lwjake2/qcommon/netchan_t.java index fc2dd43..46eee70 100644 --- a/src/main/java/lwjake2/qcommon/netchan_t.java +++ b/src/main/java/lwjake2/qcommon/netchan_t.java @@ -52,7 +52,7 @@ public class netchan_t { public int last_reliable_sequence; // sequence number of last send - // reliable staging and holding areas + // reliable staging and holding areas public sizebuf_t message = new sizebuf_t(); // writing buffer to send to // server @@ -60,7 +60,7 @@ public class netchan_t { // space for // header - // message is copied to this buffer when it is first transfered + // message is copied to this buffer when it is first transfered public int reliable_length; public byte reliable_buf[] = new byte[Defines.MAX_MSGLEN - 16]; // unpcked diff --git a/src/main/java/lwjake2/qcommon/qfiles.java b/src/main/java/lwjake2/qcommon/qfiles.java index 8f97858..abdbda4 100644 --- a/src/main/java/lwjake2/qcommon/qfiles.java +++ b/src/main/java/lwjake2/qcommon/qfiles.java @@ -31,657 +31,657 @@ import java.nio.IntBuffer; * @author cwei */ public class qfiles { - // - // qfiles.h: quake file formats - // This file must be identical in the quake and utils directories - // - - /* - ======================================================================== - - The .pak files are just a linear collapse of a directory tree - - ======================================================================== - */ - - /* - ======================================================================== - - PCX files are used for as many images as possible - - ======================================================================== - */ - public static class pcx_t { - - // size of byte arrays - static final int PALETTE_SIZE = 48; - static final int FILLER_SIZE = 58; - - public byte manufacturer; - public byte version; - public byte encoding; - public byte bits_per_pixel; - public int xmin, ymin, xmax, ymax; // unsigned short - public int hres, vres; // unsigned short - public byte[] palette; //unsigned byte; size 48 - public byte reserved; - public byte color_planes; - public int bytes_per_line; // unsigned short - public int palette_type; // unsigned short - public byte[] filler; // size 58 - public ByteBuffer data; //unbounded data - - public pcx_t(byte[] dataBytes) { - this(ByteBuffer.wrap(dataBytes)); - } - - public pcx_t(ByteBuffer b) { - // is stored as little endian - b.order(ByteOrder.LITTLE_ENDIAN); - - // fill header - manufacturer = b.get(); - version = b.get(); - encoding = b.get(); - bits_per_pixel = b.get(); - xmin = b.getShort() & 0xffff; - ymin = b.getShort() & 0xffff; - xmax = b.getShort() & 0xffff; - ymax = b.getShort() & 0xffff; - hres = b.getShort() & 0xffff; - vres = b.getShort() & 0xffff; - b.get(palette = new byte[PALETTE_SIZE]); - reserved = b.get(); - color_planes = b.get(); - bytes_per_line = b.getShort() & 0xffff; - palette_type = b.getShort() & 0xffff; - b.get(filler = new byte[FILLER_SIZE]); - - // fill data - data = b.slice(); - } - } - - /* - ======================================================================== - - TGA files are used for sky planes - - ======================================================================== - */ - public static class tga_t { - - // targa header - public int id_length, colormap_type, image_type; // unsigned char - public int colormap_index, colormap_length; // unsigned short - public int colormap_size; // unsigned char - public int x_origin, y_origin, width, height; // unsigned short - public int pixel_size, attributes; // unsigned char - - public ByteBuffer data; // (un)compressed data - - public tga_t(byte[] dataBytes) { - this(ByteBuffer.wrap(dataBytes)); - } - - public tga_t(ByteBuffer b) { - // is stored as little endian - b.order(ByteOrder.LITTLE_ENDIAN); - - // fill header - id_length = b.get() & 0xFF; - colormap_type = b.get() & 0xFF; - image_type = b.get() & 0xFF; - colormap_index = b.getShort() & 0xFFFF; - colormap_length = b.getShort() & 0xFFFF; - colormap_size = b.get() & 0xFF; - x_origin = b.getShort() & 0xFFFF; - y_origin = b.getShort() & 0xFFFF; - width = b.getShort() & 0xFFFF; - height = b.getShort() & 0xFFFF; - pixel_size = b.get() & 0xFF; - attributes = b.get() & 0xFF; - - // fill data - data = b.slice(); - } - - } - - /* - ======================================================================== - - .MD2 triangle model file format - - ======================================================================== - */ - - public static final int IDALIASHEADER = (('2'<<24)+('P'<<16)+('D'<<8)+'I'); - public static final int ALIAS_VERSION = 8; - - public static final int MAX_TRIANGLES = 4096; - public static final int MAX_VERTS = 2048; - public static final int MAX_FRAMES = 512; - public static final int MAX_MD2SKINS = 32; - public static final int MAX_SKINNAME = 64; - - public static class dstvert_t { - public short s; - public short t; - - public dstvert_t(ByteBuffer b) { - s = b.getShort(); - t = b.getShort(); - } - } - - public static class dtriangle_t { - public short index_xyz[] = { 0, 0, 0 }; - public short index_st[] = { 0, 0, 0 }; - - public dtriangle_t(ByteBuffer b) { - index_xyz[0] = b.getShort(); - index_xyz[1] = b.getShort(); - index_xyz[2] = b.getShort(); - - index_st[0] = b.getShort(); - index_st[1] = b.getShort(); - index_st[2] = b.getShort(); - } - } - - public static final int DTRIVERTX_V0 = 0; - public static final int DTRIVERTX_V1 = 1; - public static final int DTRIVERTX_V2 = 2; - public static final int DTRIVERTX_LNI = 3; - public static final int DTRIVERTX_SIZE = 4; - - public static class daliasframe_t { - public float[] scale = {0, 0, 0}; // multiply byte verts by this - public float[] translate = {0, 0, 0}; // then add this - public String name; // frame name from grabbing (size 16) - public int[] verts; // variable sized - - public daliasframe_t(ByteBuffer b) { - scale[0] = b.getFloat(); scale[1] = b.getFloat(); scale[2] = b.getFloat(); - translate[0] = b.getFloat(); translate[1] = b.getFloat(); translate[2] = b.getFloat(); - byte[] nameBuf = new byte[16]; - b.get(nameBuf); - name = new String(nameBuf).trim(); - } - } - - // the glcmd format: - // a positive integer starts a tristrip command, followed by that many - // vertex structures. - // a negative integer starts a trifan command, followed by -x vertexes - // a zero indicates the end of the command list. - // a vertex consists of a floating point s, a floating point t, - // and an integer vertex index. - - public static class dmdl_t { - public int ident; - public int version; - - public int skinwidth; - public int skinheight; - public int framesize; // byte size of each frame - - public int num_skins; - public int num_xyz; - public int num_st; // greater than num_xyz for seams - public int num_tris; - public int num_glcmds; // dwords in strip/fan command list - public int num_frames; - - public int ofs_skins; // each skin is a MAX_SKINNAME string - public int ofs_st; // byte offset from start for stverts - public int ofs_tris; // offset for dtriangles - public int ofs_frames; // offset for first frame - public int ofs_glcmds; - public int ofs_end; // end of file - - // wird extra gebraucht - public String[] skinNames; - public dstvert_t[] stVerts; - public dtriangle_t[] triAngles; - public int[] glCmds; - public daliasframe_t[] aliasFrames; - - - public dmdl_t(ByteBuffer b) { - ident = b.getInt(); - version = b.getInt(); - - skinwidth = b.getInt(); - skinheight = b.getInt(); - framesize = b.getInt(); // byte size of each frame - - num_skins = b.getInt(); - num_xyz = b.getInt(); - num_st = b.getInt(); // greater than num_xyz for seams - num_tris = b.getInt(); - num_glcmds = b.getInt(); // dwords in strip/fan command list - num_frames = b.getInt(); - - ofs_skins = b.getInt(); // each skin is a MAX_SKINNAME string - ofs_st = b.getInt(); // byte offset from start for stverts - ofs_tris = b.getInt(); // offset for dtriangles - ofs_frames = b.getInt(); // offset for first frame - ofs_glcmds = b.getInt(); - ofs_end = b.getInt(); // end of file - } - - /* - * new members for vertex array handling - */ - public FloatBuffer textureCoordBuf = null; - public IntBuffer vertexIndexBuf = null; - public int[] counts = null; - public IntBuffer[] indexElements = null; - } - - /* - ======================================================================== - - .SP2 sprite file format - - ======================================================================== - */ - // little-endian "IDS2" - public static final int IDSPRITEHEADER = (('2'<<24)+('S'<<16)+('D'<<8)+'I'); - public static final int SPRITE_VERSION = 2; - - public static class dsprframe_t { - public int width, height; - public int origin_x, origin_y; // raster coordinates inside pic - public String name; // name of pcx file (MAX_SKINNAME) - - public dsprframe_t(ByteBuffer b) { - width = b.getInt(); - height = b.getInt(); - origin_x = b.getInt(); - origin_y = b.getInt(); - - byte[] nameBuf = new byte[MAX_SKINNAME]; - b.get(nameBuf); - name = new String(nameBuf).trim(); - } - } - - public static class dsprite_t { - public int ident; - public int version; - public int numframes; - public dsprframe_t frames[]; // variable sized - - public dsprite_t(ByteBuffer b) { - ident = b.getInt(); - version = b.getInt(); - numframes = b.getInt(); - - frames = new dsprframe_t[numframes]; - for (int i=0; i < numframes; i++) { - frames[i] = new dsprframe_t(b); - } - } - } - - /* - ============================================================================== - - .WAL texture file format - - ============================================================================== - */ - public static class miptex_t { - - static final int MIPLEVELS = 4; - static final int NAME_SIZE = 32; - - public String name; // char name[32]; - public int width, height; - public int[] offsets = new int[MIPLEVELS]; // 4 mip maps stored - // next frame in animation chain - public String animname; // char animname[32]; - public int flags; - public int contents; - public int value; - - public miptex_t(byte[] dataBytes) { - this(ByteBuffer.wrap(dataBytes)); - } - - public miptex_t(ByteBuffer b) { - // is stored as little endian - b.order(ByteOrder.LITTLE_ENDIAN); - - byte[] nameBuf = new byte[NAME_SIZE]; - // fill header - b.get(nameBuf); - name = new String(nameBuf).trim(); - width = b.getInt(); - height = b.getInt(); - offsets[0] = b.getInt(); - offsets[1] = b.getInt(); - offsets[2] = b.getInt(); - offsets[3] = b.getInt(); - b.get(nameBuf); - animname = new String(nameBuf).trim(); - flags = b.getInt(); - contents = b.getInt(); - value = b.getInt(); - } - - } - - /* - ============================================================================== - - .BSP file format - - ============================================================================== - */ - - public static final int IDBSPHEADER = (('P'<<24)+('S'<<16)+('B'<<8)+'I'); - - // ============================================================================= - - public static class dheader_t { - - public dheader_t(ByteBuffer bb) { - bb.order(ByteOrder.LITTLE_ENDIAN); - this.ident = bb.getInt(); - this.version = bb.getInt(); - - for (int n = 0; n < Defines.HEADER_LUMPS; n++) - lumps[n] = new lump_t(bb.getInt(), bb.getInt()); - - } - - public int ident; - public int version; - public lump_t lumps[] = new lump_t[Defines.HEADER_LUMPS]; - } - - public static class dmodel_t { - - public dmodel_t(ByteBuffer bb) { - bb.order(ByteOrder.LITTLE_ENDIAN); - - for (int j = 0; j < 3; j++) - mins[j] = bb.getFloat(); - - for (int j = 0; j < 3; j++) - maxs[j] = bb.getFloat(); - - for (int j = 0; j < 3; j++) - origin[j] = bb.getFloat(); - - headnode = bb.getInt(); - firstface = bb.getInt(); - numfaces = bb.getInt(); - } - public float mins[] = { 0, 0, 0 }; - public float maxs[] = { 0, 0, 0 }; - public float origin[] = { 0, 0, 0 }; // for sounds or lights - public int headnode; - public int firstface, numfaces; // submodels just draw faces - // without walking the bsp tree - - public static int SIZE = 3 * 4 + 3 * 4 + 3 * 4 + 4 + 8; - } - - public static class dvertex_t { - - public static final int SIZE = 3 * 4; // 3 mal 32 bit float - - public float[] point = { 0, 0, 0 }; - - public dvertex_t(ByteBuffer b) { - point[0] = b.getFloat(); - point[1] = b.getFloat(); - point[2] = b.getFloat(); - } - } - - - // planes (x&~1) and (x&~1)+1 are always opposites - public static class dplane_t { - - public dplane_t(ByteBuffer bb) { - bb.order(ByteOrder.LITTLE_ENDIAN); - - normal[0] = (bb.getFloat()); - normal[1] = (bb.getFloat()); - normal[2] = (bb.getFloat()); - - dist = (bb.getFloat()); - type = (bb.getInt()); - } - - public float normal[] = { 0, 0, 0 }; - public float dist; - public int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate - - public static final int SIZE = 3 * 4 + 4 + 4; - } - - public static class dnode_t { - - public dnode_t(ByteBuffer bb) { - - bb.order(ByteOrder.LITTLE_ENDIAN); - planenum = bb.getInt(); - - children[0] = bb.getInt(); - children[1] = bb.getInt(); - - for (int j = 0; j < 3; j++) - mins[j] = bb.getShort(); - - for (int j = 0; j < 3; j++) - maxs[j] = bb.getShort(); + // + // qfiles.h: quake file formats + // This file must be identical in the quake and utils directories + // + + /* + ======================================================================== + + The .pak files are just a linear collapse of a directory tree + + ======================================================================== + */ + + /* + ======================================================================== + + PCX files are used for as many images as possible + + ======================================================================== + */ + public static class pcx_t { + + // size of byte arrays + static final int PALETTE_SIZE = 48; + static final int FILLER_SIZE = 58; + + public byte manufacturer; + public byte version; + public byte encoding; + public byte bits_per_pixel; + public int xmin, ymin, xmax, ymax; // unsigned short + public int hres, vres; // unsigned short + public byte[] palette; //unsigned byte; size 48 + public byte reserved; + public byte color_planes; + public int bytes_per_line; // unsigned short + public int palette_type; // unsigned short + public byte[] filler; // size 58 + public ByteBuffer data; //unbounded data + + public pcx_t(byte[] dataBytes) { + this(ByteBuffer.wrap(dataBytes)); + } + + public pcx_t(ByteBuffer b) { + // is stored as little endian + b.order(ByteOrder.LITTLE_ENDIAN); + + // fill header + manufacturer = b.get(); + version = b.get(); + encoding = b.get(); + bits_per_pixel = b.get(); + xmin = b.getShort() & 0xffff; + ymin = b.getShort() & 0xffff; + xmax = b.getShort() & 0xffff; + ymax = b.getShort() & 0xffff; + hres = b.getShort() & 0xffff; + vres = b.getShort() & 0xffff; + b.get(palette = new byte[PALETTE_SIZE]); + reserved = b.get(); + color_planes = b.get(); + bytes_per_line = b.getShort() & 0xffff; + palette_type = b.getShort() & 0xffff; + b.get(filler = new byte[FILLER_SIZE]); + + // fill data + data = b.slice(); + } + } + + /* + ======================================================================== + + TGA files are used for sky planes + + ======================================================================== + */ + public static class tga_t { + + // targa header + public int id_length, colormap_type, image_type; // unsigned char + public int colormap_index, colormap_length; // unsigned short + public int colormap_size; // unsigned char + public int x_origin, y_origin, width, height; // unsigned short + public int pixel_size, attributes; // unsigned char + + public ByteBuffer data; // (un)compressed data + + public tga_t(byte[] dataBytes) { + this(ByteBuffer.wrap(dataBytes)); + } + + public tga_t(ByteBuffer b) { + // is stored as little endian + b.order(ByteOrder.LITTLE_ENDIAN); + + // fill header + id_length = b.get() & 0xFF; + colormap_type = b.get() & 0xFF; + image_type = b.get() & 0xFF; + colormap_index = b.getShort() & 0xFFFF; + colormap_length = b.getShort() & 0xFFFF; + colormap_size = b.get() & 0xFF; + x_origin = b.getShort() & 0xFFFF; + y_origin = b.getShort() & 0xFFFF; + width = b.getShort() & 0xFFFF; + height = b.getShort() & 0xFFFF; + pixel_size = b.get() & 0xFF; + attributes = b.get() & 0xFF; + + // fill data + data = b.slice(); + } + + } + + /* + ======================================================================== + + .MD2 triangle model file format + + ======================================================================== + */ + + public static final int IDALIASHEADER = (('2'<<24)+('P'<<16)+('D'<<8)+'I'); + public static final int ALIAS_VERSION = 8; + + public static final int MAX_TRIANGLES = 4096; + public static final int MAX_VERTS = 2048; + public static final int MAX_FRAMES = 512; + public static final int MAX_MD2SKINS = 32; + public static final int MAX_SKINNAME = 64; + + public static class dstvert_t { + public short s; + public short t; + + public dstvert_t(ByteBuffer b) { + s = b.getShort(); + t = b.getShort(); + } + } + + public static class dtriangle_t { + public short index_xyz[] = { 0, 0, 0 }; + public short index_st[] = { 0, 0, 0 }; + + public dtriangle_t(ByteBuffer b) { + index_xyz[0] = b.getShort(); + index_xyz[1] = b.getShort(); + index_xyz[2] = b.getShort(); + + index_st[0] = b.getShort(); + index_st[1] = b.getShort(); + index_st[2] = b.getShort(); + } + } + + public static final int DTRIVERTX_V0 = 0; + public static final int DTRIVERTX_V1 = 1; + public static final int DTRIVERTX_V2 = 2; + public static final int DTRIVERTX_LNI = 3; + public static final int DTRIVERTX_SIZE = 4; + + public static class daliasframe_t { + public float[] scale = {0, 0, 0}; // multiply byte verts by this + public float[] translate = {0, 0, 0}; // then add this + public String name; // frame name from grabbing (size 16) + public int[] verts; // variable sized + + public daliasframe_t(ByteBuffer b) { + scale[0] = b.getFloat(); scale[1] = b.getFloat(); scale[2] = b.getFloat(); + translate[0] = b.getFloat(); translate[1] = b.getFloat(); translate[2] = b.getFloat(); + byte[] nameBuf = new byte[16]; + b.get(nameBuf); + name = new String(nameBuf).trim(); + } + } + + // the glcmd format: + // a positive integer starts a tristrip command, followed by that many + // vertex structures. + // a negative integer starts a trifan command, followed by -x vertexes + // a zero indicates the end of the command list. + // a vertex consists of a floating point s, a floating point t, + // and an integer vertex index. + + public static class dmdl_t { + public int ident; + public int version; + + public int skinwidth; + public int skinheight; + public int framesize; // byte size of each frame + + public int num_skins; + public int num_xyz; + public int num_st; // greater than num_xyz for seams + public int num_tris; + public int num_glcmds; // dwords in strip/fan command list + public int num_frames; + + public int ofs_skins; // each skin is a MAX_SKINNAME string + public int ofs_st; // byte offset from start for stverts + public int ofs_tris; // offset for dtriangles + public int ofs_frames; // offset for first frame + public int ofs_glcmds; + public int ofs_end; // end of file + + // wird extra gebraucht + public String[] skinNames; + public dstvert_t[] stVerts; + public dtriangle_t[] triAngles; + public int[] glCmds; + public daliasframe_t[] aliasFrames; + + + public dmdl_t(ByteBuffer b) { + ident = b.getInt(); + version = b.getInt(); + + skinwidth = b.getInt(); + skinheight = b.getInt(); + framesize = b.getInt(); // byte size of each frame + + num_skins = b.getInt(); + num_xyz = b.getInt(); + num_st = b.getInt(); // greater than num_xyz for seams + num_tris = b.getInt(); + num_glcmds = b.getInt(); // dwords in strip/fan command list + num_frames = b.getInt(); + + ofs_skins = b.getInt(); // each skin is a MAX_SKINNAME string + ofs_st = b.getInt(); // byte offset from start for stverts + ofs_tris = b.getInt(); // offset for dtriangles + ofs_frames = b.getInt(); // offset for first frame + ofs_glcmds = b.getInt(); + ofs_end = b.getInt(); // end of file + } + + /* + * new members for vertex array handling + */ + public FloatBuffer textureCoordBuf = null; + public IntBuffer vertexIndexBuf = null; + public int[] counts = null; + public IntBuffer[] indexElements = null; + } + + /* + ======================================================================== + + .SP2 sprite file format + + ======================================================================== + */ + // little-endian "IDS2" + public static final int IDSPRITEHEADER = (('2'<<24)+('S'<<16)+('D'<<8)+'I'); + public static final int SPRITE_VERSION = 2; + + public static class dsprframe_t { + public int width, height; + public int origin_x, origin_y; // raster coordinates inside pic + public String name; // name of pcx file (MAX_SKINNAME) + + public dsprframe_t(ByteBuffer b) { + width = b.getInt(); + height = b.getInt(); + origin_x = b.getInt(); + origin_y = b.getInt(); + + byte[] nameBuf = new byte[MAX_SKINNAME]; + b.get(nameBuf); + name = new String(nameBuf).trim(); + } + } + + public static class dsprite_t { + public int ident; + public int version; + public int numframes; + public dsprframe_t frames[]; // variable sized + + public dsprite_t(ByteBuffer b) { + ident = b.getInt(); + version = b.getInt(); + numframes = b.getInt(); + + frames = new dsprframe_t[numframes]; + for (int i=0; i < numframes; i++) { + frames[i] = new dsprframe_t(b); + } + } + } + + /* + ============================================================================== + + .WAL texture file format + + ============================================================================== + */ + public static class miptex_t { + + static final int MIPLEVELS = 4; + static final int NAME_SIZE = 32; + + public String name; // char name[32]; + public int width, height; + public int[] offsets = new int[MIPLEVELS]; // 4 mip maps stored + // next frame in animation chain + public String animname; // char animname[32]; + public int flags; + public int contents; + public int value; + + public miptex_t(byte[] dataBytes) { + this(ByteBuffer.wrap(dataBytes)); + } + + public miptex_t(ByteBuffer b) { + // is stored as little endian + b.order(ByteOrder.LITTLE_ENDIAN); + + byte[] nameBuf = new byte[NAME_SIZE]; + // fill header + b.get(nameBuf); + name = new String(nameBuf).trim(); + width = b.getInt(); + height = b.getInt(); + offsets[0] = b.getInt(); + offsets[1] = b.getInt(); + offsets[2] = b.getInt(); + offsets[3] = b.getInt(); + b.get(nameBuf); + animname = new String(nameBuf).trim(); + flags = b.getInt(); + contents = b.getInt(); + value = b.getInt(); + } + + } + + /* + ============================================================================== + + .BSP file format + + ============================================================================== + */ + + public static final int IDBSPHEADER = (('P'<<24)+('S'<<16)+('B'<<8)+'I'); + + // ============================================================================= + + public static class dheader_t { + + public dheader_t(ByteBuffer bb) { + bb.order(ByteOrder.LITTLE_ENDIAN); + this.ident = bb.getInt(); + this.version = bb.getInt(); + + for (int n = 0; n < Defines.HEADER_LUMPS; n++) + lumps[n] = new lump_t(bb.getInt(), bb.getInt()); + + } + + public int ident; + public int version; + public lump_t lumps[] = new lump_t[Defines.HEADER_LUMPS]; + } + + public static class dmodel_t { + + public dmodel_t(ByteBuffer bb) { + bb.order(ByteOrder.LITTLE_ENDIAN); + + for (int j = 0; j < 3; j++) + mins[j] = bb.getFloat(); + + for (int j = 0; j < 3; j++) + maxs[j] = bb.getFloat(); + + for (int j = 0; j < 3; j++) + origin[j] = bb.getFloat(); + + headnode = bb.getInt(); + firstface = bb.getInt(); + numfaces = bb.getInt(); + } + public float mins[] = { 0, 0, 0 }; + public float maxs[] = { 0, 0, 0 }; + public float origin[] = { 0, 0, 0 }; // for sounds or lights + public int headnode; + public int firstface, numfaces; // submodels just draw faces + // without walking the bsp tree + + public static int SIZE = 3 * 4 + 3 * 4 + 3 * 4 + 4 + 8; + } + + public static class dvertex_t { + + public static final int SIZE = 3 * 4; // 3 mal 32 bit float + + public float[] point = { 0, 0, 0 }; + + public dvertex_t(ByteBuffer b) { + point[0] = b.getFloat(); + point[1] = b.getFloat(); + point[2] = b.getFloat(); + } + } + + + // planes (x&~1) and (x&~1)+1 are always opposites + public static class dplane_t { + + public dplane_t(ByteBuffer bb) { + bb.order(ByteOrder.LITTLE_ENDIAN); + + normal[0] = (bb.getFloat()); + normal[1] = (bb.getFloat()); + normal[2] = (bb.getFloat()); + + dist = (bb.getFloat()); + type = (bb.getInt()); + } + + public float normal[] = { 0, 0, 0 }; + public float dist; + public int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate + + public static final int SIZE = 3 * 4 + 4 + 4; + } + + public static class dnode_t { + + public dnode_t(ByteBuffer bb) { + + bb.order(ByteOrder.LITTLE_ENDIAN); + planenum = bb.getInt(); + + children[0] = bb.getInt(); + children[1] = bb.getInt(); + + for (int j = 0; j < 3; j++) + mins[j] = bb.getShort(); + + for (int j = 0; j < 3; j++) + maxs[j] = bb.getShort(); - firstface = bb.getShort() & 0xffff; - numfaces = bb.getShort() & 0xffff; - - } - - public int planenum; - public int children[] = { 0, 0 }; - // negative numbers are -(leafs+1), not nodes - public short mins[] = { 0, 0, 0 }; // for frustom culling - public short maxs[] = { 0, 0, 0 }; - - /* - unsigned short firstface; - unsigned short numfaces; // counting both sides - */ - - public int firstface; - public int numfaces; - - public static int SIZE = 4 + 8 + 6 + 6 + 2 + 2; // counting both sides - } - - - - // note that edge 0 is never used, because negative edge nums are used for - // counterclockwise use of the edge in a face - - public static class dedge_t { - // unsigned short v[2]; - int v[] = { 0, 0 }; - } - - public static class dface_t { - - public static final int SIZE = - 4 * Defines.SIZE_OF_SHORT - + 2 * Defines.SIZE_OF_INT - + Defines.MAXLIGHTMAPS; - - //unsigned short planenum; - public int planenum; - public short side; - - public int firstedge; // we must support > 64k edges - public short numedges; - public short texinfo; - - // lighting info - public byte styles[] = new byte[Defines.MAXLIGHTMAPS]; - public int lightofs; // start of [numstyles*surfsize] samples - - public dface_t(ByteBuffer b) { - planenum = b.getShort() & 0xFFFF; - side = b.getShort(); - firstedge = b.getInt(); - numedges = b.getShort(); - texinfo = b.getShort(); - b.get(styles); - lightofs = b.getInt(); - } - - } + firstface = bb.getShort() & 0xffff; + numfaces = bb.getShort() & 0xffff; + + } + + public int planenum; + public int children[] = { 0, 0 }; + // negative numbers are -(leafs+1), not nodes + public short mins[] = { 0, 0, 0 }; // for frustom culling + public short maxs[] = { 0, 0, 0 }; + + /* + unsigned short firstface; + unsigned short numfaces; // counting both sides + */ + + public int firstface; + public int numfaces; + + public static int SIZE = 4 + 8 + 6 + 6 + 2 + 2; // counting both sides + } + + + + // note that edge 0 is never used, because negative edge nums are used for + // counterclockwise use of the edge in a face + + public static class dedge_t { + // unsigned short v[2]; + int v[] = { 0, 0 }; + } + + public static class dface_t { + + public static final int SIZE = + 4 * Defines.SIZE_OF_SHORT + + 2 * Defines.SIZE_OF_INT + + Defines.MAXLIGHTMAPS; + + //unsigned short planenum; + public int planenum; + public short side; + + public int firstedge; // we must support > 64k edges + public short numedges; + public short texinfo; + + // lighting info + public byte styles[] = new byte[Defines.MAXLIGHTMAPS]; + public int lightofs; // start of [numstyles*surfsize] samples + + public dface_t(ByteBuffer b) { + planenum = b.getShort() & 0xFFFF; + side = b.getShort(); + firstedge = b.getInt(); + numedges = b.getShort(); + texinfo = b.getShort(); + b.get(styles); + lightofs = b.getInt(); + } + + } - public static class dleaf_t { - - public dleaf_t(byte[] cmod_base, int i, int j) { - this(ByteBuffer.wrap(cmod_base, i, j).order(ByteOrder.LITTLE_ENDIAN)); - } - - public dleaf_t(ByteBuffer bb) { - contents = bb.getInt(); - cluster = bb.getShort(); - area = bb.getShort(); - - mins[0] = bb.getShort(); - mins[1] = bb.getShort(); - mins[2] = bb.getShort(); - - maxs[0] = bb.getShort(); - maxs[1] = bb.getShort(); - maxs[2] = bb.getShort(); - - firstleafface = bb.getShort() & 0xffff; - numleaffaces = bb.getShort() & 0xffff; - - firstleafbrush = bb.getShort() & 0xffff; - numleafbrushes = bb.getShort() & 0xffff; - } - - public static final int SIZE = 4 + 8 * 2 + 4 * 2; - - public int contents; // OR of all brushes (not needed?) - - public short cluster; - public short area; - - public short mins[] = { 0, 0, 0 }; // for frustum culling - public short maxs[] = { 0, 0, 0 }; - - public int firstleafface; // unsigned short - public int numleaffaces; // unsigned short - - public int firstleafbrush; // unsigned short - public int numleafbrushes; // unsigned short - } - - public static class dbrushside_t { - - public dbrushside_t(ByteBuffer bb) { - bb.order(ByteOrder.LITTLE_ENDIAN); - - planenum = bb.getShort() & 0xffff; - texinfo = bb.getShort(); - } - - //unsigned short planenum; - int planenum; // facing out of the leaf - - short texinfo; - - public static int SIZE = 4; - } - - public static class dbrush_t { - - public dbrush_t(ByteBuffer bb) { - bb.order(ByteOrder.LITTLE_ENDIAN); - firstside = bb.getInt(); - numsides = bb.getInt(); - contents = bb.getInt(); - } - - public static int SIZE = 3 * 4; - - int firstside; - int numsides; - int contents; - } + public static class dleaf_t { + + public dleaf_t(byte[] cmod_base, int i, int j) { + this(ByteBuffer.wrap(cmod_base, i, j).order(ByteOrder.LITTLE_ENDIAN)); + } + + public dleaf_t(ByteBuffer bb) { + contents = bb.getInt(); + cluster = bb.getShort(); + area = bb.getShort(); + + mins[0] = bb.getShort(); + mins[1] = bb.getShort(); + mins[2] = bb.getShort(); + + maxs[0] = bb.getShort(); + maxs[1] = bb.getShort(); + maxs[2] = bb.getShort(); + + firstleafface = bb.getShort() & 0xffff; + numleaffaces = bb.getShort() & 0xffff; + + firstleafbrush = bb.getShort() & 0xffff; + numleafbrushes = bb.getShort() & 0xffff; + } + + public static final int SIZE = 4 + 8 * 2 + 4 * 2; + + public int contents; // OR of all brushes (not needed?) + + public short cluster; + public short area; + + public short mins[] = { 0, 0, 0 }; // for frustum culling + public short maxs[] = { 0, 0, 0 }; + + public int firstleafface; // unsigned short + public int numleaffaces; // unsigned short + + public int firstleafbrush; // unsigned short + public int numleafbrushes; // unsigned short + } + + public static class dbrushside_t { + + public dbrushside_t(ByteBuffer bb) { + bb.order(ByteOrder.LITTLE_ENDIAN); + + planenum = bb.getShort() & 0xffff; + texinfo = bb.getShort(); + } + + //unsigned short planenum; + int planenum; // facing out of the leaf + + short texinfo; + + public static int SIZE = 4; + } + + public static class dbrush_t { + + public dbrush_t(ByteBuffer bb) { + bb.order(ByteOrder.LITTLE_ENDIAN); + firstside = bb.getInt(); + numsides = bb.getInt(); + contents = bb.getInt(); + } + + public static int SIZE = 3 * 4; + + int firstside; + int numsides; + int contents; + } - // #define ANGLE_UP -1 - // #define ANGLE_DOWN -2 + // #define ANGLE_UP -1 + // #define ANGLE_DOWN -2 - // the visibility lump consists of a header with a count, then - // byte offsets for the PVS and PHS of each cluster, then the raw - // compressed bit vectors - // #define DVIS_PVS 0 - // #define DVIS_PHS 1 - - public static class dvis_t { + // the visibility lump consists of a header with a count, then + // byte offsets for the PVS and PHS of each cluster, then the raw + // compressed bit vectors + // #define DVIS_PVS 0 + // #define DVIS_PHS 1 + + public static class dvis_t { - public dvis_t(ByteBuffer bb) { - numclusters = bb.getInt(); - bitofs = new int[numclusters][2]; + public dvis_t(ByteBuffer bb) { + numclusters = bb.getInt(); + bitofs = new int[numclusters][2]; - for (int i = 0; i < numclusters; i++) { - bitofs[i][0] = bb.getInt(); - bitofs[i][1] = bb.getInt(); - } - } + for (int i = 0; i < numclusters; i++) { + bitofs[i][0] = bb.getInt(); + bitofs[i][1] = bb.getInt(); + } + } - public int numclusters; - public int bitofs[][] = new int[8][2]; // bitofs[numclusters][2] - } - - // each area has a list of portals that lead into other areas - // when portals are closed, other areas may not be visible or - // hearable even if the vis info says that it should be - - public static class dareaportal_t { + public int numclusters; + public int bitofs[][] = new int[8][2]; // bitofs[numclusters][2] + } + + // each area has a list of portals that lead into other areas + // when portals are closed, other areas may not be visible or + // hearable even if the vis info says that it should be + + public static class dareaportal_t { - public dareaportal_t() { - } + public dareaportal_t() { + } - public dareaportal_t(ByteBuffer bb) { - bb.order(ByteOrder.LITTLE_ENDIAN); - portalnum = bb.getInt(); - otherarea = bb.getInt(); - } + public dareaportal_t(ByteBuffer bb) { + bb.order(ByteOrder.LITTLE_ENDIAN); + portalnum = bb.getInt(); + otherarea = bb.getInt(); + } - int portalnum; - int otherarea; + int portalnum; + int otherarea; - public static int SIZE = 8; - } + public static int SIZE = 8; + } - public static class darea_t { + public static class darea_t { - public darea_t(ByteBuffer bb) { + public darea_t(ByteBuffer bb) { - bb.order(ByteOrder.LITTLE_ENDIAN); + bb.order(ByteOrder.LITTLE_ENDIAN); - numareaportals = bb.getInt(); - firstareaportal = bb.getInt(); + numareaportals = bb.getInt(); + firstareaportal = bb.getInt(); - } - int numareaportals; - int firstareaportal; + } + int numareaportals; + int firstareaportal; - public static int SIZE = 8; - } + public static int SIZE = 8; + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/qcommon/sizebuf_t.java b/src/main/java/lwjake2/qcommon/sizebuf_t.java index ee279b1..b984abc 100644 --- a/src/main/java/lwjake2/qcommon/sizebuf_t.java +++ b/src/main/java/lwjake2/qcommon/sizebuf_t.java @@ -24,18 +24,18 @@ import java.util.Arrays; * sizebuf_t */ public final class sizebuf_t { - public boolean allowoverflow = false; - public boolean overflowed = false; - public byte[] data = null; - public int maxsize = 0; - public int cursize = 0; - public int readcount = 0; - - public void clear() - { - if (data!=null) - Arrays.fill(data,(byte)0); - cursize = 0; - overflowed = false; - } + public boolean allowoverflow = false; + public boolean overflowed = false; + public byte[] data = null; + public int maxsize = 0; + public int cursize = 0; + public int readcount = 0; + + public void clear() + { + if (data!=null) + Arrays.fill(data,(byte)0); + cursize = 0; + overflowed = false; + } } diff --git a/src/main/java/lwjake2/qcommon/texinfo_t.java b/src/main/java/lwjake2/qcommon/texinfo_t.java index d4e4177..12ac4b3 100644 --- a/src/main/java/lwjake2/qcommon/texinfo_t.java +++ b/src/main/java/lwjake2/qcommon/texinfo_t.java @@ -25,36 +25,36 @@ import java.nio.ByteOrder; public class texinfo_t { - // works fine. - public texinfo_t(byte[] cmod_base, int o, int len) { - this(ByteBuffer.wrap(cmod_base, o, len).order(ByteOrder.LITTLE_ENDIAN)); - } + // works fine. + public texinfo_t(byte[] cmod_base, int o, int len) { + this(ByteBuffer.wrap(cmod_base, o, len).order(ByteOrder.LITTLE_ENDIAN)); + } - public texinfo_t(ByteBuffer bb) { + public texinfo_t(ByteBuffer bb) { - byte str[] = new byte[32]; + byte str[] = new byte[32]; - vecs[0] = new float[] { bb.getFloat(), bb.getFloat(), bb.getFloat(), bb.getFloat()}; - vecs[1] = new float[] { bb.getFloat(), bb.getFloat(), bb.getFloat(), bb.getFloat()}; + vecs[0] = new float[] { bb.getFloat(), bb.getFloat(), bb.getFloat(), bb.getFloat()}; + vecs[1] = new float[] { bb.getFloat(), bb.getFloat(), bb.getFloat(), bb.getFloat()}; - flags = bb.getInt(); - value = bb.getInt(); + flags = bb.getInt(); + value = bb.getInt(); - bb.get(str); - texture = new String(str, 0, Lib.strlen(str)); - nexttexinfo = bb.getInt(); - } + bb.get(str); + texture = new String(str, 0, Lib.strlen(str)); + nexttexinfo = bb.getInt(); + } - public static final int SIZE = 32 + 4 + 4 + 32 + 4; + public static final int SIZE = 32 + 4 + 4 + 32 + 4; - //float vecs[2][4]; // [s/t][xyz offset] - public float vecs[][] = { - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 } - }; - public int flags; // miptex flags + overrides - public int value; // light emission, etc - //char texture[32]; // texture name (textures/*.wal) - public String texture=""; - public int nexttexinfo; // for animations, -1 = end of chain + //float vecs[2][4]; // [s/t][xyz offset] + public float vecs[][] = { + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 } + }; + public int flags; // miptex flags + overrides + public int value; // light emission, etc + //char texture[32]; // texture name (textures/*.wal) + public String texture=""; + public int nexttexinfo; // for animations, -1 = end of chain } diff --git a/src/main/java/lwjake2/render/DummyRenderer.java b/src/main/java/lwjake2/render/DummyRenderer.java index 72511eb..6cfd66a 100644 --- a/src/main/java/lwjake2/render/DummyRenderer.java +++ b/src/main/java/lwjake2/render/DummyRenderer.java @@ -32,162 +32,162 @@ import java.awt.DisplayMode; */ public class DummyRenderer implements refexport_t { - /* (non-Javadoc) - * @see jake2.client.refexport_t#Init(int, int) - */ - public boolean Init(int vid_xpos, int vid_ypos) { - return false; - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#Init(int, int) + */ + public boolean Init(int vid_xpos, int vid_ypos) { + return false; + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#Shutdown() - */ - public void Shutdown() { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#Shutdown() + */ + public void Shutdown() { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#BeginRegistration(java.lang.String) - */ - public void BeginRegistration(String map) { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#BeginRegistration(java.lang.String) + */ + public void BeginRegistration(String map) { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#RegisterModel(java.lang.String) - */ - public model_t RegisterModel(String name) { - return null; - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#RegisterModel(java.lang.String) + */ + public model_t RegisterModel(String name) { + return null; + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#RegisterSkin(java.lang.String) - */ - public image_t RegisterSkin(String name) { - return null; - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#RegisterSkin(java.lang.String) + */ + public image_t RegisterSkin(String name) { + return null; + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#RegisterPic(java.lang.String) - */ - public image_t RegisterPic(String name) { - return null; - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#RegisterPic(java.lang.String) + */ + public image_t RegisterPic(String name) { + return null; + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#SetSky(java.lang.String, float, float[]) - */ - public void SetSky(String name, float rotate, float[] axis) { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#SetSky(java.lang.String, float, float[]) + */ + public void SetSky(String name, float rotate, float[] axis) { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#EndRegistration() - */ - public void EndRegistration() { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#EndRegistration() + */ + public void EndRegistration() { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#RenderFrame(jake2.client.refdef_t) - */ - public void RenderFrame(refdef_t fd) { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#RenderFrame(jake2.client.refdef_t) + */ + public void RenderFrame(refdef_t fd) { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#DrawGetPicSize(java.awt.Dimension, java.lang.String) - */ - public void DrawGetPicSize(Dimension dim, String name) { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#DrawGetPicSize(java.awt.Dimension, java.lang.String) + */ + public void DrawGetPicSize(Dimension dim, String name) { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#DrawPic(int, int, java.lang.String) - */ - public void DrawPic(int x, int y, String name) { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#DrawPic(int, int, java.lang.String) + */ + public void DrawPic(int x, int y, String name) { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#DrawStretchPic(int, int, int, int, java.lang.String) - */ - public void DrawStretchPic(int x, int y, int w, int h, String name) { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#DrawStretchPic(int, int, int, int, java.lang.String) + */ + public void DrawStretchPic(int x, int y, int w, int h, String name) { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#DrawChar(int, int, int) - */ - public void DrawChar(int x, int y, int num) { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#DrawChar(int, int, int) + */ + public void DrawChar(int x, int y, int num) { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#DrawTileClear(int, int, int, int, java.lang.String) - */ - public void DrawTileClear(int x, int y, int w, int h, String name) { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#DrawTileClear(int, int, int, int, java.lang.String) + */ + public void DrawTileClear(int x, int y, int w, int h, String name) { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#DrawFill(int, int, int, int, int) - */ - public void DrawFill(int x, int y, int w, int h, int c) { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#DrawFill(int, int, int, int, int) + */ + public void DrawFill(int x, int y, int w, int h, int c) { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#DrawFadeScreen() - */ - public void DrawFadeScreen() { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#DrawFadeScreen() + */ + public void DrawFadeScreen() { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#DrawStretchRaw(int, int, int, int, int, int, byte[]) - */ - public void DrawStretchRaw(int x, int y, int w, int h, int cols, int rows, byte[] data) { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#DrawStretchRaw(int, int, int, int, int, int, byte[]) + */ + public void DrawStretchRaw(int x, int y, int w, int h, int cols, int rows, byte[] data) { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#CinematicSetPalette(byte[]) - */ - public void CinematicSetPalette(byte[] palette) { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#CinematicSetPalette(byte[]) + */ + public void CinematicSetPalette(byte[] palette) { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#BeginFrame(float) - */ - public void BeginFrame(float camera_separation) { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#BeginFrame(float) + */ + public void BeginFrame(float camera_separation) { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#EndFrame() - */ - public void EndFrame() { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#EndFrame() + */ + public void EndFrame() { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#AppActivate(boolean) - */ - public void AppActivate(boolean activate) { - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#AppActivate(boolean) + */ + public void AppActivate(boolean activate) { + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#updateScreen(java.lang.Runnable) - */ - public void updateScreen(Runnable callback) { - callback.run(); - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#updateScreen(java.lang.Runnable) + */ + public void updateScreen(Runnable callback) { + callback.run(); + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#apiVersion() - */ - public int apiVersion() { - return 0; - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#apiVersion() + */ + public int apiVersion() { + return 0; + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#getModeList() - */ - public DisplayMode[] getModeList() { - return null; - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#getModeList() + */ + public DisplayMode[] getModeList() { + return null; + } - /* (non-Javadoc) - * @see jake2.client.refexport_t#getKeyboardHandler() - */ - public KBD getKeyboardHandler() { - return null; - } + /* (non-Javadoc) + * @see jake2.client.refexport_t#getKeyboardHandler() + */ + public KBD getKeyboardHandler() { + return null; + } } diff --git a/src/main/java/lwjake2/render/LWJGLRenderer.java b/src/main/java/lwjake2/render/LWJGLRenderer.java index c810e4b..47eeaa3 100644 --- a/src/main/java/lwjake2/render/LWJGLRenderer.java +++ b/src/main/java/lwjake2/render/LWJGLRenderer.java @@ -34,197 +34,197 @@ import java.awt.Dimension; * @author dsanders/cwei */ final class LWJGLRenderer extends Misc implements refexport_t, Ref { - - private LWJGLKBD kbd=new LWJGLKBD(); - - public static final String DRIVER_NAME = "lwjgl"; - - static { - Renderer.register(new LWJGLRenderer()); - }; + + private LWJGLKBD kbd=new LWJGLKBD(); + + public static final String DRIVER_NAME = "lwjgl"; + + static { + Renderer.register(new LWJGLRenderer()); + }; - private LWJGLRenderer() { - } + private LWJGLRenderer() { + } - // ============================================================================ - // public interface for Renderer implementations - // - // refexport_t (ref.h) - // ============================================================================ + // ============================================================================ + // public interface for Renderer implementations + // + // refexport_t (ref.h) + // ============================================================================ - /** - * @see jake2.client.refexport_t#Init() - */ - public boolean Init(int vid_xpos, int vid_ypos) { - - // pre init - if (!R_Init(vid_xpos, vid_ypos)) return false; - // post init - boolean ok = R_Init2(); - if (!ok) { - VID.Printf(Defines.PRINT_ALL, "Missing multi-texturing for LWJGL renderer\n"); - } - return ok; - } + /** + * @see jake2.client.refexport_t#Init() + */ + public boolean Init(int vid_xpos, int vid_ypos) { + + // pre init + if (!R_Init(vid_xpos, vid_ypos)) return false; + // post init + boolean ok = R_Init2(); + if (!ok) { + VID.Printf(Defines.PRINT_ALL, "Missing multi-texturing for LWJGL renderer\n"); + } + return ok; + } - /** - * @see jake2.client.refexport_t#Shutdown() - */ - public void Shutdown() { - R_Shutdown(); - } + /** + * @see jake2.client.refexport_t#Shutdown() + */ + public void Shutdown() { + R_Shutdown(); + } - /** - * @see jake2.client.refexport_t#BeginRegistration(java.lang.String) - */ - public final void BeginRegistration(String map) { - R_BeginRegistration(map); - } + /** + * @see jake2.client.refexport_t#BeginRegistration(java.lang.String) + */ + public final void BeginRegistration(String map) { + R_BeginRegistration(map); + } - /** - * @see jake2.client.refexport_t#RegisterModel(java.lang.String) - */ - public final model_t RegisterModel(String name) { - return R_RegisterModel(name); - } + /** + * @see jake2.client.refexport_t#RegisterModel(java.lang.String) + */ + public final model_t RegisterModel(String name) { + return R_RegisterModel(name); + } - /** - * @see jake2.client.refexport_t#RegisterSkin(java.lang.String) - */ - public final image_t RegisterSkin(String name) { - return R_RegisterSkin(name); - } - - /** - * @see jake2.client.refexport_t#RegisterPic(java.lang.String) - */ - public final image_t RegisterPic(String name) { - return Draw_FindPic(name); - } - /** - * @see jake2.client.refexport_t#SetSky(java.lang.String, float, float[]) - */ - public final void SetSky(String name, float rotate, float[] axis) { - R_SetSky(name, rotate, axis); - } + /** + * @see jake2.client.refexport_t#RegisterSkin(java.lang.String) + */ + public final image_t RegisterSkin(String name) { + return R_RegisterSkin(name); + } + + /** + * @see jake2.client.refexport_t#RegisterPic(java.lang.String) + */ + public final image_t RegisterPic(String name) { + return Draw_FindPic(name); + } + /** + * @see jake2.client.refexport_t#SetSky(java.lang.String, float, float[]) + */ + public final void SetSky(String name, float rotate, float[] axis) { + R_SetSky(name, rotate, axis); + } - /** - * @see jake2.client.refexport_t#EndRegistration() - */ - public final void EndRegistration() { - R_EndRegistration(); - } + /** + * @see jake2.client.refexport_t#EndRegistration() + */ + public final void EndRegistration() { + R_EndRegistration(); + } - /** - * @see jake2.client.refexport_t#RenderFrame(jake2.client.refdef_t) - */ - public final void RenderFrame(refdef_t fd) { - R_RenderFrame(fd); - } + /** + * @see jake2.client.refexport_t#RenderFrame(jake2.client.refdef_t) + */ + public final void RenderFrame(refdef_t fd) { + R_RenderFrame(fd); + } - /** - * @see jake2.client.refexport_t#DrawGetPicSize(java.awt.Dimension, java.lang.String) - */ - public final void DrawGetPicSize(Dimension dim, String name) { - Draw_GetPicSize(dim, name); - } + /** + * @see jake2.client.refexport_t#DrawGetPicSize(java.awt.Dimension, java.lang.String) + */ + public final void DrawGetPicSize(Dimension dim, String name) { + Draw_GetPicSize(dim, name); + } - /** - * @see jake2.client.refexport_t#DrawPic(int, int, java.lang.String) - */ - public final void DrawPic(int x, int y, String name) { - Draw_Pic(x, y, name); - } + /** + * @see jake2.client.refexport_t#DrawPic(int, int, java.lang.String) + */ + public final void DrawPic(int x, int y, String name) { + Draw_Pic(x, y, name); + } - /** - * @see jake2.client.refexport_t#DrawStretchPic(int, int, int, int, java.lang.String) - */ - public final void DrawStretchPic(int x, int y, int w, int h, String name) { - Draw_StretchPic(x, y, w, h, name); - } + /** + * @see jake2.client.refexport_t#DrawStretchPic(int, int, int, int, java.lang.String) + */ + public final void DrawStretchPic(int x, int y, int w, int h, String name) { + Draw_StretchPic(x, y, w, h, name); + } - /** - * @see jake2.client.refexport_t#DrawChar(int, int, int) - */ - public final void DrawChar(int x, int y, int num) { - Draw_Char(x, y, num); - } + /** + * @see jake2.client.refexport_t#DrawChar(int, int, int) + */ + public final void DrawChar(int x, int y, int num) { + Draw_Char(x, y, num); + } - /** - * @see jake2.client.refexport_t#DrawTileClear(int, int, int, int, java.lang.String) - */ - public final void DrawTileClear(int x, int y, int w, int h, String name) { - Draw_TileClear(x, y, w, h, name); - } + /** + * @see jake2.client.refexport_t#DrawTileClear(int, int, int, int, java.lang.String) + */ + public final void DrawTileClear(int x, int y, int w, int h, String name) { + Draw_TileClear(x, y, w, h, name); + } - /** - * @see jake2.client.refexport_t#DrawFill(int, int, int, int, int) - */ - public final void DrawFill(int x, int y, int w, int h, int c) { - Draw_Fill(x, y, w, h, c); - } + /** + * @see jake2.client.refexport_t#DrawFill(int, int, int, int, int) + */ + public final void DrawFill(int x, int y, int w, int h, int c) { + Draw_Fill(x, y, w, h, c); + } - /** - * @see jake2.client.refexport_t#DrawFadeScreen() - */ - public final void DrawFadeScreen() { - Draw_FadeScreen(); - } + /** + * @see jake2.client.refexport_t#DrawFadeScreen() + */ + public final void DrawFadeScreen() { + Draw_FadeScreen(); + } - /** - * @see jake2.client.refexport_t#DrawStretchRaw(int, int, int, int, int, int, byte[]) - */ - public final void DrawStretchRaw(int x, int y, int w, int h, int cols, int rows, byte[] data) { - Draw_StretchRaw(x, y, w, h, cols, rows, data); - } + /** + * @see jake2.client.refexport_t#DrawStretchRaw(int, int, int, int, int, int, byte[]) + */ + public final void DrawStretchRaw(int x, int y, int w, int h, int cols, int rows, byte[] data) { + Draw_StretchRaw(x, y, w, h, cols, rows, data); + } - /** - * @see jake2.client.refexport_t#CinematicSetPalette(byte[]) - */ - public final void CinematicSetPalette(byte[] palette) { - R_SetPalette(palette); - } + /** + * @see jake2.client.refexport_t#CinematicSetPalette(byte[]) + */ + public final void CinematicSetPalette(byte[] palette) { + R_SetPalette(palette); + } - /** - * @see jake2.client.refexport_t#BeginFrame(float) - */ - public final void BeginFrame(float camera_separation) { - R_BeginFrame(camera_separation); - } + /** + * @see jake2.client.refexport_t#BeginFrame(float) + */ + public final void BeginFrame(float camera_separation) { + R_BeginFrame(camera_separation); + } - /** - * @see jake2.client.refexport_t#EndFrame() - */ - public final void EndFrame() { - GLimp_EndFrame(); - } + /** + * @see jake2.client.refexport_t#EndFrame() + */ + public final void EndFrame() { + GLimp_EndFrame(); + } - /** - * @see jake2.client.refexport_t#AppActivate(boolean) - */ - public final void AppActivate(boolean activate) { - GLimp_AppActivate(activate); - } + /** + * @see jake2.client.refexport_t#AppActivate(boolean) + */ + public final void AppActivate(boolean activate) { + GLimp_AppActivate(activate); + } - public final int apiVersion() { - return Defines.API_VERSION; - } + public final int apiVersion() { + return Defines.API_VERSION; + } - // ============================================================================ - // Ref interface - // ============================================================================ + // ============================================================================ + // Ref interface + // ============================================================================ - public final String getName() { - return DRIVER_NAME; - } + public final String getName() { + return DRIVER_NAME; + } - public final String toString() { - return DRIVER_NAME; - } + public final String toString() { + return DRIVER_NAME; + } - public final refexport_t GetRefAPI() { - return this; - } - - public final KBD getKeyboardHandler() { return kbd; } + public final refexport_t GetRefAPI() { + return this; + } + + public final KBD getKeyboardHandler() { return kbd; } } \ No newline at end of file diff --git a/src/main/java/lwjake2/render/Ref.java b/src/main/java/lwjake2/render/Ref.java index 1a70248..3611f8c 100644 --- a/src/main/java/lwjake2/render/Ref.java +++ b/src/main/java/lwjake2/render/Ref.java @@ -26,10 +26,10 @@ import lwjake2.client.refexport_t; * @author cwei */ public interface Ref { - - // ============================================================================ - // extensions (cwei) - // ============================================================================ - refexport_t GetRefAPI(); - String getName(); + + // ============================================================================ + // extensions (cwei) + // ============================================================================ + refexport_t GetRefAPI(); + String getName(); } diff --git a/src/main/java/lwjake2/render/Renderer.java b/src/main/java/lwjake2/render/Renderer.java index fdbbf44..8f4465c 100644 --- a/src/main/java/lwjake2/render/Renderer.java +++ b/src/main/java/lwjake2/render/Renderer.java @@ -29,63 +29,63 @@ import java.util.Vector; */ public class Renderer { - static Vector drivers = new Vector(1); + static Vector drivers = new Vector(1); - static { - try { - try { - Class.forName("org.lwjgl.opengl.GL11"); - Class.forName("lwjake2.render.LWJGLRenderer"); - } catch (ClassNotFoundException e) { - // ignore the lwjgl driver if runtime not in classpath - } - } catch (Throwable e) { - e.printStackTrace(); - } - }; + static { + try { + try { + Class.forName("org.lwjgl.opengl.GL11"); + Class.forName("lwjake2.render.LWJGLRenderer"); + } catch (ClassNotFoundException e) { + // ignore the lwjgl driver if runtime not in classpath + } + } catch (Throwable e) { + e.printStackTrace(); + } + }; - public static void register(Ref impl) { - if (impl == null) { - throw new IllegalArgumentException("Ref implementation can't be null"); - } - if (!drivers.contains(impl)) { - drivers.add(impl); - } - } + public static void register(Ref impl) { + if (impl == null) { + throw new IllegalArgumentException("Ref implementation can't be null"); + } + if (!drivers.contains(impl)) { + drivers.add(impl); + } + } - /** - * Factory method to get the Renderer implementation. - * @return refexport_t (Renderer singleton) - */ - public static refexport_t getDriver(String driverName) { - // find a driver - Ref driver = null; - int count = drivers.size(); - for (int i = 0; i < count; i++) { - driver = drivers.get(i); - if (driver.getName().equals(driverName)) { - return driver.GetRefAPI(); - } - } - // null if driver not found - return null; - } - - public static String getDefaultName() { - return (drivers.isEmpty()) ? null : (drivers.firstElement()).getName(); - } + /** + * Factory method to get the Renderer implementation. + * @return refexport_t (Renderer singleton) + */ + public static refexport_t getDriver(String driverName) { + // find a driver + Ref driver = null; + int count = drivers.size(); + for (int i = 0; i < count; i++) { + driver = drivers.get(i); + if (driver.getName().equals(driverName)) { + return driver.GetRefAPI(); + } + } + // null if driver not found + return null; + } + + public static String getDefaultName() { + return (drivers.isEmpty()) ? null : (drivers.firstElement()).getName(); + } - public static String getPreferedName() { - return (drivers.isEmpty()) ? null : (drivers.lastElement()).getName(); - } + public static String getPreferedName() { + return (drivers.isEmpty()) ? null : (drivers.lastElement()).getName(); + } - public static String[] getDriverNames() { - if (drivers.isEmpty()) return null; - int count = drivers.size(); - String[] names = new String[count]; - for (int i = 0; i < count; i++) { - names[i] = (drivers.get(i)).getName(); - } - return names; - } + public static String[] getDriverNames() { + if (drivers.isEmpty()) return null; + int count = drivers.size(); + String[] names = new String[count]; + for (int i = 0; i < count; i++) { + names[i] = (drivers.get(i)).getName(); + } + return names; + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/render/glconfig_t.java b/src/main/java/lwjake2/render/glconfig_t.java index f8b1f45..1a793ed 100644 --- a/src/main/java/lwjake2/render/glconfig_t.java +++ b/src/main/java/lwjake2/render/glconfig_t.java @@ -20,21 +20,21 @@ package lwjake2.render; public class glconfig_t { - public int renderer; - public String renderer_string; - public String vendor_string; - public String version_string; - public String extensions_string; + public int renderer; + public String renderer_string; + public String vendor_string; + public String version_string; + public String extensions_string; - public boolean allow_cds; - - private float version = 1.1f; + public boolean allow_cds; + + private float version = 1.1f; - public void parseOpenGLVersion() { - version = Float.parseFloat(version_string.substring(0, 3)); - } - - public float getOpenGLVersion() { - return version; - } + public void parseOpenGLVersion() { + version = Float.parseFloat(version_string.substring(0, 3)); + } + + public float getOpenGLVersion() { + return version; + } } diff --git a/src/main/java/lwjake2/render/glpoly_t.java b/src/main/java/lwjake2/render/glpoly_t.java index 6769283..1b9f785 100644 --- a/src/main/java/lwjake2/render/glpoly_t.java +++ b/src/main/java/lwjake2/render/glpoly_t.java @@ -21,50 +21,50 @@ package lwjake2.render; import lwjake2.util.Lib; public abstract class glpoly_t { - public final static int STRIDE = 7; - public final static int BYTE_STRIDE = 7 * Lib.SIZEOF_FLOAT; - public final static int MAX_VERTICES = 64; - - public glpoly_t next; - public glpoly_t chain; - public int numverts; - public int flags; // for SURF_UNDERWATER (not needed anymore?) - - // the array position (glDrawArrays) - public int pos = 0; - - protected glpoly_t() { - } - - public abstract float x(int index); - - public abstract void x(int index, float value); + public final static int STRIDE = 7; + public final static int BYTE_STRIDE = 7 * Lib.SIZEOF_FLOAT; + public final static int MAX_VERTICES = 64; + + public glpoly_t next; + public glpoly_t chain; + public int numverts; + public int flags; // for SURF_UNDERWATER (not needed anymore?) + + // the array position (glDrawArrays) + public int pos = 0; + + protected glpoly_t() { + } + + public abstract float x(int index); + + public abstract void x(int index, float value); - public abstract float y(int index); - - public abstract void y(int index, float value); - - public abstract float z(int index); - - public abstract void z(int index, float value); + public abstract float y(int index); + + public abstract void y(int index, float value); + + public abstract float z(int index); + + public abstract void z(int index, float value); - public abstract float s1(int index); - - public abstract void s1(int index, float value); + public abstract float s1(int index); + + public abstract void s1(int index, float value); - public abstract float t1(int index); - - public abstract void t1(int index, float value); + public abstract float t1(int index); + + public abstract void t1(int index, float value); - public abstract float s2(int index); - - public abstract void s2(int index, float value); + public abstract float s2(int index); + + public abstract void s2(int index, float value); - public abstract float t2(int index); - - public abstract void t2(int index, float value); - - public abstract void beginScrolling(float s1); - - public abstract void endScrolling(); + public abstract float t2(int index); + + public abstract void t2(int index, float value); + + public abstract void beginScrolling(float s1); + + public abstract void endScrolling(); } \ No newline at end of file diff --git a/src/main/java/lwjake2/render/glstate_t.java b/src/main/java/lwjake2/render/glstate_t.java index 823e569..6ac331e 100644 --- a/src/main/java/lwjake2/render/glstate_t.java +++ b/src/main/java/lwjake2/render/glstate_t.java @@ -20,23 +20,23 @@ package lwjake2.render; public class glstate_t { - public float inverse_intensity; - public boolean fullscreen; + public float inverse_intensity; + public boolean fullscreen; - public int prev_mode; + public int prev_mode; - public byte d_16to8table[]; + public byte d_16to8table[]; - public int lightmap_textures; + public int lightmap_textures; - public int currenttextures[]= {0,0}; - public int currenttmu; + public int currenttextures[]= {0,0}; + public int currenttmu; - public float camera_separation; - public boolean stereo_enabled; + public float camera_separation; + public boolean stereo_enabled; - public byte originalRedGammaTable[]= new byte [256]; - public byte originalGreenGammaTable[]= new byte [256]; - public byte originalBlueGammaTable[]= new byte [256]; + public byte originalRedGammaTable[]= new byte [256]; + public byte originalGreenGammaTable[]= new byte [256]; + public byte originalBlueGammaTable[]= new byte [256]; } diff --git a/src/main/java/lwjake2/render/image_t.java b/src/main/java/lwjake2/render/image_t.java index 5d90ba0..94bfe09 100644 --- a/src/main/java/lwjake2/render/image_t.java +++ b/src/main/java/lwjake2/render/image_t.java @@ -21,53 +21,53 @@ package lwjake2.render; import lwjake2.Defines; public class image_t { - - public static final int MAX_NAME_SIZE = Defines.MAX_QPATH; - - // used to get the pos in array - // added by cwei - private int id; - - // quake 2 variables - public String name=""; // game path, including extension - // enum imagetype_t - public int type; - public int width, height; // source image - public int upload_width, upload_height; // after power of two and picmip - public int registration_sequence; // 0 = free - public msurface_t texturechain; // for sort-by-texture world drawing - public int texnum; // gl texture binding - public float sl, tl, sh, th; // 0,0 - 1,1 unless part of the scrap - public boolean scrap; - public boolean has_alpha; + + public static final int MAX_NAME_SIZE = Defines.MAX_QPATH; + + // used to get the pos in array + // added by cwei + private int id; + + // quake 2 variables + public String name=""; // game path, including extension + // enum imagetype_t + public int type; + public int width, height; // source image + public int upload_width, upload_height; // after power of two and picmip + public int registration_sequence; // 0 = free + public msurface_t texturechain; // for sort-by-texture world drawing + public int texnum; // gl texture binding + public float sl, tl, sh, th; // 0,0 - 1,1 unless part of the scrap + public boolean scrap; + public boolean has_alpha; - public boolean paletted; - - public image_t(int id) { - this.id = id; - } - - public void clear() { - // don't clear the id - // wichtig !!! - name = ""; - type = 0; - width = height = 0; - upload_width = upload_height = 0; - registration_sequence = 0; // 0 = free - texturechain = null; - texnum = 0; // gl texture binding - sl = tl = sh = th = 0; - scrap = false; - has_alpha = false; - paletted = false; - } + public boolean paletted; + + public image_t(int id) { + this.id = id; + } + + public void clear() { + // don't clear the id + // wichtig !!! + name = ""; + type = 0; + width = height = 0; + upload_width = upload_height = 0; + registration_sequence = 0; // 0 = free + texturechain = null; + texnum = 0; // gl texture binding + sl = tl = sh = th = 0; + scrap = false; + has_alpha = false; + paletted = false; + } - public int getId() { - return id; - } - - public String toString() { - return name + ":" + texnum; - } + public int getId() { + return id; + } + + public String toString() { + return name + ":" + texnum; + } } diff --git a/src/main/java/lwjake2/render/lwjgl/Anorms.java b/src/main/java/lwjake2/render/lwjgl/Anorms.java index a8acb68..78458b3 100644 --- a/src/main/java/lwjake2/render/lwjgl/Anorms.java +++ b/src/main/java/lwjake2/render/lwjgl/Anorms.java @@ -24,189 +24,189 @@ package lwjake2.render.lwjgl; * @author cwei */ public interface Anorms { - - final float[][] VERTEXNORMALS = { - {-0.525731f, 0.000000f, 0.850651f}, - {-0.442863f, 0.238856f, 0.864188f}, - {-0.295242f, 0.000000f, 0.955423f}, - {-0.309017f, 0.500000f, 0.809017f}, - {-0.162460f, 0.262866f, 0.951056f}, - {0.000000f, 0.000000f, 1.000000f}, - {0.000000f, 0.850651f, 0.525731f}, - {-0.147621f, 0.716567f, 0.681718f}, - {0.147621f, 0.716567f, 0.681718f}, - {0.000000f, 0.525731f, 0.850651f}, - {0.309017f, 0.500000f, 0.809017f}, - {0.525731f, 0.000000f, 0.850651f}, - {0.295242f, 0.000000f, 0.955423f}, - {0.442863f, 0.238856f, 0.864188f}, - {0.162460f, 0.262866f, 0.951056f}, - {-0.681718f, 0.147621f, 0.716567f}, - {-0.809017f, 0.309017f, 0.500000f}, - {-0.587785f, 0.425325f, 0.688191f}, - {-0.850651f, 0.525731f, 0.000000f}, - {-0.864188f, 0.442863f, 0.238856f}, - {-0.716567f, 0.681718f, 0.147621f}, - {-0.688191f, 0.587785f, 0.425325f}, - {-0.500000f, 0.809017f, 0.309017f}, - {-0.238856f, 0.864188f, 0.442863f}, - {-0.425325f, 0.688191f, 0.587785f}, - {-0.716567f, 0.681718f, -0.147621f}, - {-0.500000f, 0.809017f, -0.309017f}, - {-0.525731f, 0.850651f, 0.000000f}, - {0.000000f, 0.850651f, -0.525731f}, - {-0.238856f, 0.864188f, -0.442863f}, - {0.000000f, 0.955423f, -0.295242f}, - {-0.262866f, 0.951056f, -0.162460f}, - {0.000000f, 1.000000f, 0.000000f}, - {0.000000f, 0.955423f, 0.295242f}, - {-0.262866f, 0.951056f, 0.162460f}, - {0.238856f, 0.864188f, 0.442863f}, - {0.262866f, 0.951056f, 0.162460f}, - {0.500000f, 0.809017f, 0.309017f}, - {0.238856f, 0.864188f, -0.442863f}, - {0.262866f, 0.951056f, -0.162460f}, - {0.500000f, 0.809017f, -0.309017f}, - {0.850651f, 0.525731f, 0.000000f}, - {0.716567f, 0.681718f, 0.147621f}, - {0.716567f, 0.681718f, -0.147621f}, - {0.525731f, 0.850651f, 0.000000f}, - {0.425325f, 0.688191f, 0.587785f}, - {0.864188f, 0.442863f, 0.238856f}, - {0.688191f, 0.587785f, 0.425325f}, - {0.809017f, 0.309017f, 0.500000f}, - {0.681718f, 0.147621f, 0.716567f}, - {0.587785f, 0.425325f, 0.688191f}, - {0.955423f, 0.295242f, 0.000000f}, - {1.000000f, 0.000000f, 0.000000f}, - {0.951056f, 0.162460f, 0.262866f}, - {0.850651f, -0.525731f, 0.000000f}, - {0.955423f, -0.295242f, 0.000000f}, - {0.864188f, -0.442863f, 0.238856f}, - {0.951056f, -0.162460f, 0.262866f}, - {0.809017f, -0.309017f, 0.500000f}, - {0.681718f, -0.147621f, 0.716567f}, - {0.850651f, 0.000000f, 0.525731f}, - {0.864188f, 0.442863f, -0.238856f}, - {0.809017f, 0.309017f, -0.500000f}, - {0.951056f, 0.162460f, -0.262866f}, - {0.525731f, 0.000000f, -0.850651f}, - {0.681718f, 0.147621f, -0.716567f}, - {0.681718f, -0.147621f, -0.716567f}, - {0.850651f, 0.000000f, -0.525731f}, - {0.809017f, -0.309017f, -0.500000f}, - {0.864188f, -0.442863f, -0.238856f}, - {0.951056f, -0.162460f, -0.262866f}, - {0.147621f, 0.716567f, -0.681718f}, - {0.309017f, 0.500000f, -0.809017f}, - {0.425325f, 0.688191f, -0.587785f}, - {0.442863f, 0.238856f, -0.864188f}, - {0.587785f, 0.425325f, -0.688191f}, - {0.688191f, 0.587785f, -0.425325f}, - {-0.147621f, 0.716567f, -0.681718f}, - {-0.309017f, 0.500000f, -0.809017f}, - {0.000000f, 0.525731f, -0.850651f}, - {-0.525731f, 0.000000f, -0.850651f}, - {-0.442863f, 0.238856f, -0.864188f}, - {-0.295242f, 0.000000f, -0.955423f}, - {-0.162460f, 0.262866f, -0.951056f}, - {0.000000f, 0.000000f, -1.000000f}, - {0.295242f, 0.000000f, -0.955423f}, - {0.162460f, 0.262866f, -0.951056f}, - {-0.442863f, -0.238856f, -0.864188f}, - {-0.309017f, -0.500000f, -0.809017f}, - {-0.162460f, -0.262866f, -0.951056f}, - {0.000000f, -0.850651f, -0.525731f}, - {-0.147621f, -0.716567f, -0.681718f}, - {0.147621f, -0.716567f, -0.681718f}, - {0.000000f, -0.525731f, -0.850651f}, - {0.309017f, -0.500000f, -0.809017f}, - {0.442863f, -0.238856f, -0.864188f}, - {0.162460f, -0.262866f, -0.951056f}, - {0.238856f, -0.864188f, -0.442863f}, - {0.500000f, -0.809017f, -0.309017f}, - {0.425325f, -0.688191f, -0.587785f}, - {0.716567f, -0.681718f, -0.147621f}, - {0.688191f, -0.587785f, -0.425325f}, - {0.587785f, -0.425325f, -0.688191f}, - {0.000000f, -0.955423f, -0.295242f}, - {0.000000f, -1.000000f, 0.000000f}, - {0.262866f, -0.951056f, -0.162460f}, - {0.000000f, -0.850651f, 0.525731f}, - {0.000000f, -0.955423f, 0.295242f}, - {0.238856f, -0.864188f, 0.442863f}, - {0.262866f, -0.951056f, 0.162460f}, - {0.500000f, -0.809017f, 0.309017f}, - {0.716567f, -0.681718f, 0.147621f}, - {0.525731f, -0.850651f, 0.000000f}, - {-0.238856f, -0.864188f, -0.442863f}, - {-0.500000f, -0.809017f, -0.309017f}, - {-0.262866f, -0.951056f, -0.162460f}, - {-0.850651f, -0.525731f, 0.000000f}, - {-0.716567f, -0.681718f, -0.147621f}, - {-0.716567f, -0.681718f, 0.147621f}, - {-0.525731f, -0.850651f, 0.000000f}, - {-0.500000f, -0.809017f, 0.309017f}, - {-0.238856f, -0.864188f, 0.442863f}, - {-0.262866f, -0.951056f, 0.162460f}, - {-0.864188f, -0.442863f, 0.238856f}, - {-0.809017f, -0.309017f, 0.500000f}, - {-0.688191f, -0.587785f, 0.425325f}, - {-0.681718f, -0.147621f, 0.716567f}, - {-0.442863f, -0.238856f, 0.864188f}, - {-0.587785f, -0.425325f, 0.688191f}, - {-0.309017f, -0.500000f, 0.809017f}, - {-0.147621f, -0.716567f, 0.681718f}, - {-0.425325f, -0.688191f, 0.587785f}, - {-0.162460f, -0.262866f, 0.951056f}, - {0.442863f, -0.238856f, 0.864188f}, - {0.162460f, -0.262866f, 0.951056f}, - {0.309017f, -0.500000f, 0.809017f}, - {0.147621f, -0.716567f, 0.681718f}, - {0.000000f, -0.525731f, 0.850651f}, - {0.425325f, -0.688191f, 0.587785f}, - {0.587785f, -0.425325f, 0.688191f}, - {0.688191f, -0.587785f, 0.425325f}, - {-0.955423f, 0.295242f, 0.000000f}, - {-0.951056f, 0.162460f, 0.262866f}, - {-1.000000f, 0.000000f, 0.000000f}, - {-0.850651f, 0.000000f, 0.525731f}, - {-0.955423f, -0.295242f, 0.000000f}, - {-0.951056f, -0.162460f, 0.262866f}, - {-0.864188f, 0.442863f, -0.238856f}, - {-0.951056f, 0.162460f, -0.262866f}, - {-0.809017f, 0.309017f, -0.500000f}, - {-0.864188f, -0.442863f, -0.238856f}, - {-0.951056f, -0.162460f, -0.262866f}, - {-0.809017f, -0.309017f, -0.500000f}, - {-0.681718f, 0.147621f, -0.716567f}, - {-0.681718f, -0.147621f, -0.716567f}, - {-0.850651f, 0.000000f, -0.525731f}, - {-0.688191f, 0.587785f, -0.425325f}, - {-0.587785f, 0.425325f, -0.688191f}, - {-0.425325f, 0.688191f, -0.587785f}, - {-0.425325f, -0.688191f, -0.587785f}, - {-0.587785f, -0.425325f, -0.688191f}, - {-0.688191f, -0.587785f, -0.425325f} - }; - - final float[][] VERTEXNORMAL_DOTS = { - {1.23f,1.30f,1.47f,1.35f,1.56f,1.71f,1.37f,1.38f,1.59f,1.60f,1.79f,1.97f,1.88f,1.92f,1.79f,1.02f,0.93f,1.07f,0.82f,0.87f,0.88f,0.94f,0.96f,1.14f,1.11f,0.82f,0.83f,0.89f,0.89f,0.86f,0.94f,0.91f,1.00f,1.21f,0.98f,1.48f,1.30f,1.57f,0.96f,1.07f,1.14f,1.60f,1.61f,1.40f,1.37f,1.72f,1.78f,1.79f,1.93f,1.99f,1.90f,1.68f,1.71f,1.86f,1.60f,1.68f,1.78f,1.86f,1.93f,1.99f,1.97f,1.44f,1.22f,1.49f,0.93f,0.99f,0.99f,1.23f,1.22f,1.44f,1.49f,0.89f,0.89f,0.97f,0.91f,0.98f,1.19f,0.82f,0.76f,0.82f,0.71f,0.72f,0.73f,0.76f,0.79f,0.86f,0.83f,0.72f,0.76f,0.76f,0.89f,0.82f,0.89f,0.82f,0.89f,0.91f,0.83f,0.96f,1.14f,0.97f,1.40f,1.19f,0.98f,0.94f,1.00f,1.07f,1.37f,1.21f,1.48f,1.30f,1.57f,1.61f,1.37f,0.86f,0.83f,0.91f,0.82f,0.82f,0.88f,0.89f,0.96f,1.14f,0.98f,0.87f,0.93f,0.94f,1.02f,1.30f,1.07f,1.35f,1.38f,1.11f,1.56f,1.92f,1.79f,1.79f,1.59f,1.60f,1.72f,1.90f,1.79f,0.80f,0.85f,0.79f,0.93f,0.80f,0.85f,0.77f,0.74f,0.72f,0.77f,0.74f,0.72f,0.70f,0.70f,0.71f,0.76f,0.73f,0.79f,0.79f,0.73f,0.76f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.26f,1.26f,1.48f,1.23f,1.50f,1.71f,1.14f,1.19f,1.38f,1.46f,1.64f,1.94f,1.87f,1.84f,1.71f,1.02f,0.92f,1.00f,0.79f,0.85f,0.84f,0.91f,0.90f,0.98f,0.99f,0.77f,0.77f,0.83f,0.82f,0.79f,0.86f,0.84f,0.92f,0.99f,0.91f,1.24f,1.03f,1.33f,0.88f,0.94f,0.97f,1.41f,1.39f,1.18f,1.11f,1.51f,1.61f,1.59f,1.80f,1.91f,1.76f,1.54f,1.65f,1.76f,1.70f,1.70f,1.85f,1.85f,1.97f,1.99f,1.93f,1.28f,1.09f,1.39f,0.92f,0.97f,0.99f,1.18f,1.26f,1.52f,1.48f,0.83f,0.85f,0.90f,0.88f,0.93f,1.00f,0.77f,0.73f,0.78f,0.72f,0.71f,0.74f,0.75f,0.79f,0.86f,0.81f,0.75f,0.81f,0.79f,0.96f,0.88f,0.94f,0.86f,0.93f,0.92f,0.85f,1.08f,1.33f,1.05f,1.55f,1.31f,1.01f,1.05f,1.27f,1.31f,1.60f,1.47f,1.70f,1.54f,1.76f,1.76f,1.57f,0.93f,0.90f,0.99f,0.88f,0.88f,0.95f,0.97f,1.11f,1.39f,1.20f,0.92f,0.97f,1.01f,1.10f,1.39f,1.22f,1.51f,1.58f,1.32f,1.64f,1.97f,1.85f,1.91f,1.77f,1.74f,1.88f,1.99f,1.91f,0.79f,0.86f,0.80f,0.94f,0.84f,0.88f,0.74f,0.74f,0.71f,0.82f,0.77f,0.76f,0.70f,0.73f,0.72f,0.73f,0.70f,0.74f,0.85f,0.77f,0.82f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.34f,1.27f,1.53f,1.17f,1.46f,1.71f,0.98f,1.05f,1.20f,1.34f,1.48f,1.86f,1.82f,1.71f,1.62f,1.09f,0.94f,0.99f,0.79f,0.85f,0.82f,0.90f,0.87f,0.93f,0.96f,0.76f,0.74f,0.79f,0.76f,0.74f,0.79f,0.78f,0.85f,0.92f,0.85f,1.00f,0.93f,1.06f,0.81f,0.86f,0.89f,1.16f,1.12f,0.97f,0.95f,1.28f,1.38f,1.35f,1.60f,1.77f,1.57f,1.33f,1.50f,1.58f,1.69f,1.63f,1.82f,1.74f,1.91f,1.92f,1.80f,1.04f,0.97f,1.21f,0.90f,0.93f,0.97f,1.05f,1.21f,1.48f,1.37f,0.77f,0.80f,0.84f,0.85f,0.88f,0.92f,0.73f,0.71f,0.74f,0.74f,0.71f,0.75f,0.73f,0.79f,0.84f,0.78f,0.79f,0.86f,0.81f,1.05f,0.94f,0.99f,0.90f,0.95f,0.92f,0.86f,1.24f,1.44f,1.14f,1.59f,1.34f,1.02f,1.27f,1.50f,1.49f,1.80f,1.69f,1.86f,1.72f,1.87f,1.80f,1.69f,1.00f,0.98f,1.23f,0.95f,0.96f,1.09f,1.16f,1.37f,1.63f,1.46f,0.99f,1.10f,1.25f,1.24f,1.51f,1.41f,1.67f,1.77f,1.55f,1.72f,1.95f,1.89f,1.98f,1.91f,1.86f,1.97f,1.99f,1.94f,0.81f,0.89f,0.85f,0.98f,0.90f,0.94f,0.75f,0.78f,0.73f,0.89f,0.83f,0.82f,0.72f,0.77f,0.76f,0.72f,0.70f,0.71f,0.91f,0.83f,0.89f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.46f,1.34f,1.60f,1.16f,1.46f,1.71f,0.94f,0.99f,1.05f,1.26f,1.33f,1.74f,1.76f,1.57f,1.54f,1.23f,0.98f,1.05f,0.83f,0.89f,0.84f,0.92f,0.87f,0.91f,0.96f,0.78f,0.74f,0.79f,0.72f,0.72f,0.75f,0.76f,0.80f,0.88f,0.83f,0.94f,0.87f,0.95f,0.76f,0.80f,0.82f,0.97f,0.96f,0.89f,0.88f,1.08f,1.11f,1.10f,1.37f,1.59f,1.37f,1.07f,1.27f,1.34f,1.57f,1.45f,1.69f,1.55f,1.77f,1.79f,1.60f,0.93f,0.90f,0.99f,0.86f,0.87f,0.93f,0.96f,1.07f,1.35f,1.18f,0.73f,0.76f,0.77f,0.81f,0.82f,0.85f,0.70f,0.71f,0.72f,0.78f,0.73f,0.77f,0.73f,0.79f,0.82f,0.76f,0.83f,0.90f,0.84f,1.18f,0.98f,1.03f,0.92f,0.95f,0.90f,0.86f,1.32f,1.45f,1.15f,1.53f,1.27f,0.99f,1.42f,1.65f,1.58f,1.93f,1.83f,1.94f,1.81f,1.88f,1.74f,1.70f,1.19f,1.17f,1.44f,1.11f,1.15f,1.36f,1.41f,1.61f,1.81f,1.67f,1.22f,1.34f,1.50f,1.42f,1.65f,1.61f,1.82f,1.91f,1.75f,1.80f,1.89f,1.89f,1.98f,1.99f,1.94f,1.98f,1.92f,1.87f,0.86f,0.95f,0.92f,1.14f,0.98f,1.03f,0.79f,0.84f,0.77f,0.97f,0.90f,0.89f,0.76f,0.82f,0.82f,0.74f,0.72f,0.71f,0.98f,0.89f,0.97f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.60f,1.44f,1.68f,1.22f,1.49f,1.71f,0.93f,0.99f,0.99f,1.23f,1.22f,1.60f,1.68f,1.44f,1.49f,1.40f,1.14f,1.19f,0.89f,0.96f,0.89f,0.97f,0.89f,0.91f,0.98f,0.82f,0.76f,0.82f,0.71f,0.72f,0.73f,0.76f,0.79f,0.86f,0.83f,0.91f,0.83f,0.89f,0.72f,0.76f,0.76f,0.89f,0.89f,0.82f,0.82f,0.98f,0.96f,0.97f,1.14f,1.40f,1.19f,0.94f,1.00f,1.07f,1.37f,1.21f,1.48f,1.30f,1.57f,1.61f,1.37f,0.86f,0.83f,0.91f,0.82f,0.82f,0.88f,0.89f,0.96f,1.14f,0.98f,0.70f,0.72f,0.73f,0.77f,0.76f,0.79f,0.70f,0.72f,0.71f,0.82f,0.77f,0.80f,0.74f,0.79f,0.80f,0.74f,0.87f,0.93f,0.85f,1.23f,1.02f,1.02f,0.93f,0.93f,0.87f,0.85f,1.30f,1.35f,1.07f,1.38f,1.11f,0.94f,1.47f,1.71f,1.56f,1.97f,1.88f,1.92f,1.79f,1.79f,1.59f,1.60f,1.30f,1.35f,1.56f,1.37f,1.38f,1.59f,1.60f,1.79f,1.92f,1.79f,1.48f,1.57f,1.72f,1.61f,1.78f,1.79f,1.93f,1.99f,1.90f,1.86f,1.78f,1.86f,1.93f,1.99f,1.97f,1.90f,1.79f,1.72f,0.94f,1.07f,1.00f,1.37f,1.21f,1.30f,0.86f,0.91f,0.83f,1.14f,0.98f,0.96f,0.82f,0.88f,0.89f,0.79f,0.76f,0.73f,1.07f,0.94f,1.11f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.74f,1.57f,1.76f,1.33f,1.54f,1.71f,0.94f,1.05f,0.99f,1.26f,1.16f,1.46f,1.60f,1.34f,1.46f,1.59f,1.37f,1.37f,0.97f,1.11f,0.96f,1.10f,0.95f,0.94f,1.08f,0.89f,0.82f,0.88f,0.72f,0.76f,0.75f,0.80f,0.80f,0.88f,0.87f,0.91f,0.83f,0.87f,0.72f,0.76f,0.74f,0.83f,0.84f,0.78f,0.79f,0.96f,0.89f,0.92f,0.98f,1.23f,1.05f,0.86f,0.92f,0.95f,1.11f,0.98f,1.22f,1.03f,1.34f,1.42f,1.14f,0.79f,0.77f,0.84f,0.78f,0.76f,0.82f,0.82f,0.89f,0.97f,0.90f,0.70f,0.71f,0.71f,0.73f,0.72f,0.74f,0.73f,0.76f,0.72f,0.86f,0.81f,0.82f,0.76f,0.79f,0.77f,0.73f,0.90f,0.95f,0.86f,1.18f,1.03f,0.98f,0.92f,0.90f,0.83f,0.84f,1.19f,1.17f,0.98f,1.15f,0.97f,0.89f,1.42f,1.65f,1.44f,1.93f,1.83f,1.81f,1.67f,1.61f,1.36f,1.41f,1.32f,1.45f,1.58f,1.57f,1.53f,1.74f,1.70f,1.88f,1.94f,1.81f,1.69f,1.77f,1.87f,1.79f,1.89f,1.92f,1.98f,1.99f,1.98f,1.89f,1.65f,1.80f,1.82f,1.91f,1.94f,1.75f,1.61f,1.50f,1.07f,1.34f,1.27f,1.60f,1.45f,1.55f,0.93f,0.99f,0.90f,1.35f,1.18f,1.07f,0.87f,0.93f,0.96f,0.85f,0.82f,0.77f,1.15f,0.99f,1.27f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.86f,1.71f,1.82f,1.48f,1.62f,1.71f,0.98f,1.20f,1.05f,1.34f,1.17f,1.34f,1.53f,1.27f,1.46f,1.77f,1.60f,1.57f,1.16f,1.38f,1.12f,1.35f,1.06f,1.00f,1.28f,0.97f,0.89f,0.95f,0.76f,0.81f,0.79f,0.86f,0.85f,0.92f,0.93f,0.93f,0.85f,0.87f,0.74f,0.78f,0.74f,0.79f,0.82f,0.76f,0.79f,0.96f,0.85f,0.90f,0.94f,1.09f,0.99f,0.81f,0.85f,0.89f,0.95f,0.90f,0.99f,0.94f,1.10f,1.24f,0.98f,0.75f,0.73f,0.78f,0.74f,0.72f,0.77f,0.76f,0.82f,0.89f,0.83f,0.73f,0.71f,0.71f,0.71f,0.70f,0.72f,0.77f,0.80f,0.74f,0.90f,0.85f,0.84f,0.78f,0.79f,0.75f,0.73f,0.92f,0.95f,0.86f,1.05f,0.99f,0.94f,0.90f,0.86f,0.79f,0.81f,1.00f,0.98f,0.91f,0.96f,0.89f,0.83f,1.27f,1.50f,1.23f,1.80f,1.69f,1.63f,1.46f,1.37f,1.09f,1.16f,1.24f,1.44f,1.49f,1.69f,1.59f,1.80f,1.69f,1.87f,1.86f,1.72f,1.82f,1.91f,1.94f,1.92f,1.95f,1.99f,1.98f,1.91f,1.97f,1.89f,1.51f,1.72f,1.67f,1.77f,1.86f,1.55f,1.41f,1.25f,1.33f,1.58f,1.50f,1.80f,1.63f,1.74f,1.04f,1.21f,0.97f,1.48f,1.37f,1.21f,0.93f,0.97f,1.05f,0.92f,0.88f,0.84f,1.14f,1.02f,1.34f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.94f,1.84f,1.87f,1.64f,1.71f,1.71f,1.14f,1.38f,1.19f,1.46f,1.23f,1.26f,1.48f,1.26f,1.50f,1.91f,1.80f,1.76f,1.41f,1.61f,1.39f,1.59f,1.33f,1.24f,1.51f,1.18f,0.97f,1.11f,0.82f,0.88f,0.86f,0.94f,0.92f,0.99f,1.03f,0.98f,0.91f,0.90f,0.79f,0.84f,0.77f,0.79f,0.84f,0.77f,0.83f,0.99f,0.85f,0.91f,0.92f,1.02f,1.00f,0.79f,0.80f,0.86f,0.88f,0.84f,0.92f,0.88f,0.97f,1.10f,0.94f,0.74f,0.71f,0.74f,0.72f,0.70f,0.73f,0.72f,0.76f,0.82f,0.77f,0.77f,0.73f,0.74f,0.71f,0.70f,0.73f,0.83f,0.85f,0.78f,0.92f,0.88f,0.86f,0.81f,0.79f,0.74f,0.75f,0.92f,0.93f,0.85f,0.96f,0.94f,0.88f,0.86f,0.81f,0.75f,0.79f,0.93f,0.90f,0.85f,0.88f,0.82f,0.77f,1.05f,1.27f,0.99f,1.60f,1.47f,1.39f,1.20f,1.11f,0.95f,0.97f,1.08f,1.33f,1.31f,1.70f,1.55f,1.76f,1.57f,1.76f,1.70f,1.54f,1.85f,1.97f,1.91f,1.99f,1.97f,1.99f,1.91f,1.77f,1.88f,1.85f,1.39f,1.64f,1.51f,1.58f,1.74f,1.32f,1.22f,1.01f,1.54f,1.76f,1.65f,1.93f,1.70f,1.85f,1.28f,1.39f,1.09f,1.52f,1.48f,1.26f,0.97f,0.99f,1.18f,1.00f,0.93f,0.90f,1.05f,1.01f,1.31f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.97f,1.92f,1.88f,1.79f,1.79f,1.71f,1.37f,1.59f,1.38f,1.60f,1.35f,1.23f,1.47f,1.30f,1.56f,1.99f,1.93f,1.90f,1.60f,1.78f,1.61f,1.79f,1.57f,1.48f,1.72f,1.40f,1.14f,1.37f,0.89f,0.96f,0.94f,1.07f,1.00f,1.21f,1.30f,1.14f,0.98f,0.96f,0.86f,0.91f,0.83f,0.82f,0.88f,0.82f,0.89f,1.11f,0.87f,0.94f,0.93f,1.02f,1.07f,0.80f,0.79f,0.85f,0.82f,0.80f,0.87f,0.85f,0.93f,1.02f,0.93f,0.77f,0.72f,0.74f,0.71f,0.70f,0.70f,0.71f,0.72f,0.77f,0.74f,0.82f,0.76f,0.79f,0.72f,0.73f,0.76f,0.89f,0.89f,0.82f,0.93f,0.91f,0.86f,0.83f,0.79f,0.73f,0.76f,0.91f,0.89f,0.83f,0.89f,0.89f,0.82f,0.82f,0.76f,0.72f,0.76f,0.86f,0.83f,0.79f,0.82f,0.76f,0.73f,0.94f,1.00f,0.91f,1.37f,1.21f,1.14f,0.98f,0.96f,0.88f,0.89f,0.96f,1.14f,1.07f,1.60f,1.40f,1.61f,1.37f,1.57f,1.48f,1.30f,1.78f,1.93f,1.79f,1.99f,1.92f,1.90f,1.79f,1.59f,1.72f,1.79f,1.30f,1.56f,1.35f,1.38f,1.60f,1.11f,1.07f,0.94f,1.68f,1.86f,1.71f,1.97f,1.68f,1.86f,1.44f,1.49f,1.22f,1.44f,1.49f,1.22f,0.99f,0.99f,1.23f,1.19f,0.98f,0.97f,0.97f,0.98f,1.19f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.94f,1.97f,1.87f,1.91f,1.85f,1.71f,1.60f,1.77f,1.58f,1.74f,1.51f,1.26f,1.48f,1.39f,1.64f,1.99f,1.97f,1.99f,1.70f,1.85f,1.76f,1.91f,1.76f,1.70f,1.88f,1.55f,1.33f,1.57f,0.96f,1.08f,1.05f,1.31f,1.27f,1.47f,1.54f,1.39f,1.20f,1.11f,0.93f,0.99f,0.90f,0.88f,0.95f,0.88f,0.97f,1.32f,0.92f,1.01f,0.97f,1.10f,1.22f,0.84f,0.80f,0.88f,0.79f,0.79f,0.85f,0.86f,0.92f,1.02f,0.94f,0.82f,0.76f,0.77f,0.72f,0.73f,0.70f,0.72f,0.71f,0.74f,0.74f,0.88f,0.81f,0.85f,0.75f,0.77f,0.82f,0.94f,0.93f,0.86f,0.92f,0.92f,0.86f,0.85f,0.79f,0.74f,0.79f,0.88f,0.85f,0.81f,0.82f,0.83f,0.77f,0.78f,0.73f,0.71f,0.75f,0.79f,0.77f,0.74f,0.77f,0.73f,0.70f,0.86f,0.92f,0.84f,1.14f,0.99f,0.98f,0.91f,0.90f,0.84f,0.83f,0.88f,0.97f,0.94f,1.41f,1.18f,1.39f,1.11f,1.33f,1.24f,1.03f,1.61f,1.80f,1.59f,1.91f,1.84f,1.76f,1.64f,1.38f,1.51f,1.71f,1.26f,1.50f,1.23f,1.19f,1.46f,0.99f,1.00f,0.91f,1.70f,1.85f,1.65f,1.93f,1.54f,1.76f,1.52f,1.48f,1.26f,1.28f,1.39f,1.09f,0.99f,0.97f,1.18f,1.31f,1.01f,1.05f,0.90f,0.93f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.86f,1.95f,1.82f,1.98f,1.89f,1.71f,1.80f,1.91f,1.77f,1.86f,1.67f,1.34f,1.53f,1.51f,1.72f,1.92f,1.91f,1.99f,1.69f,1.82f,1.80f,1.94f,1.87f,1.86f,1.97f,1.59f,1.44f,1.69f,1.05f,1.24f,1.27f,1.49f,1.50f,1.69f,1.72f,1.63f,1.46f,1.37f,1.00f,1.23f,0.98f,0.95f,1.09f,0.96f,1.16f,1.55f,0.99f,1.25f,1.10f,1.24f,1.41f,0.90f,0.85f,0.94f,0.79f,0.81f,0.85f,0.89f,0.94f,1.09f,0.98f,0.89f,0.82f,0.83f,0.74f,0.77f,0.72f,0.76f,0.73f,0.75f,0.78f,0.94f,0.86f,0.91f,0.79f,0.83f,0.89f,0.99f,0.95f,0.90f,0.90f,0.92f,0.84f,0.86f,0.79f,0.75f,0.81f,0.85f,0.80f,0.78f,0.76f,0.77f,0.73f,0.74f,0.71f,0.71f,0.73f,0.74f,0.74f,0.71f,0.76f,0.72f,0.70f,0.79f,0.85f,0.78f,0.98f,0.92f,0.93f,0.85f,0.87f,0.82f,0.79f,0.81f,0.89f,0.86f,1.16f,0.97f,1.12f,0.95f,1.06f,1.00f,0.93f,1.38f,1.60f,1.35f,1.77f,1.71f,1.57f,1.48f,1.20f,1.28f,1.62f,1.27f,1.46f,1.17f,1.05f,1.34f,0.96f,0.99f,0.90f,1.63f,1.74f,1.50f,1.80f,1.33f,1.58f,1.48f,1.37f,1.21f,1.04f,1.21f,0.97f,0.97f,0.93f,1.05f,1.34f,1.02f,1.14f,0.84f,0.88f,0.92f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.74f,1.89f,1.76f,1.98f,1.89f,1.71f,1.93f,1.99f,1.91f,1.94f,1.82f,1.46f,1.60f,1.65f,1.80f,1.79f,1.77f,1.92f,1.57f,1.69f,1.74f,1.87f,1.88f,1.94f,1.98f,1.53f,1.45f,1.70f,1.18f,1.32f,1.42f,1.58f,1.65f,1.83f,1.81f,1.81f,1.67f,1.61f,1.19f,1.44f,1.17f,1.11f,1.36f,1.15f,1.41f,1.75f,1.22f,1.50f,1.34f,1.42f,1.61f,0.98f,0.92f,1.03f,0.83f,0.86f,0.89f,0.95f,0.98f,1.23f,1.14f,0.97f,0.89f,0.90f,0.78f,0.82f,0.76f,0.82f,0.77f,0.79f,0.84f,0.98f,0.90f,0.98f,0.83f,0.89f,0.97f,1.03f,0.95f,0.92f,0.86f,0.90f,0.82f,0.86f,0.79f,0.77f,0.84f,0.81f,0.76f,0.76f,0.72f,0.73f,0.70f,0.72f,0.71f,0.73f,0.73f,0.72f,0.74f,0.71f,0.78f,0.74f,0.72f,0.75f,0.80f,0.76f,0.94f,0.88f,0.91f,0.83f,0.87f,0.84f,0.79f,0.76f,0.82f,0.80f,0.97f,0.89f,0.96f,0.88f,0.95f,0.94f,0.87f,1.11f,1.37f,1.10f,1.59f,1.57f,1.37f,1.33f,1.05f,1.08f,1.54f,1.34f,1.46f,1.16f,0.99f,1.26f,0.96f,1.05f,0.92f,1.45f,1.55f,1.27f,1.60f,1.07f,1.34f,1.35f,1.18f,1.07f,0.93f,0.99f,0.90f,0.93f,0.87f,0.96f,1.27f,0.99f,1.15f,0.77f,0.82f,0.85f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.60f,1.78f,1.68f,1.93f,1.86f,1.71f,1.97f,1.99f,1.99f,1.97f,1.93f,1.60f,1.68f,1.78f,1.86f,1.61f,1.57f,1.79f,1.37f,1.48f,1.59f,1.72f,1.79f,1.92f,1.90f,1.38f,1.35f,1.60f,1.23f,1.30f,1.47f,1.56f,1.71f,1.88f,1.79f,1.92f,1.79f,1.79f,1.30f,1.56f,1.35f,1.37f,1.59f,1.38f,1.60f,1.90f,1.48f,1.72f,1.57f,1.61f,1.79f,1.21f,1.00f,1.30f,0.89f,0.94f,0.96f,1.07f,1.14f,1.40f,1.37f,1.14f,0.96f,0.98f,0.82f,0.88f,0.82f,0.89f,0.83f,0.86f,0.91f,1.02f,0.93f,1.07f,0.87f,0.94f,1.11f,1.02f,0.93f,0.93f,0.82f,0.87f,0.80f,0.85f,0.79f,0.80f,0.85f,0.77f,0.72f,0.74f,0.71f,0.70f,0.70f,0.71f,0.72f,0.77f,0.74f,0.72f,0.76f,0.73f,0.82f,0.79f,0.76f,0.73f,0.79f,0.76f,0.93f,0.86f,0.91f,0.83f,0.89f,0.89f,0.82f,0.72f,0.76f,0.76f,0.89f,0.82f,0.89f,0.82f,0.89f,0.91f,0.83f,0.96f,1.14f,0.97f,1.40f,1.44f,1.19f,1.22f,0.99f,0.98f,1.49f,1.44f,1.49f,1.22f,0.99f,1.23f,0.98f,1.19f,0.97f,1.21f,1.30f,1.00f,1.37f,0.94f,1.07f,1.14f,0.98f,0.96f,0.86f,0.91f,0.83f,0.88f,0.82f,0.89f,1.11f,0.94f,1.07f,0.73f,0.76f,0.79f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.46f,1.65f,1.60f,1.82f,1.80f,1.71f,1.93f,1.91f,1.99f,1.94f,1.98f,1.74f,1.76f,1.89f,1.89f,1.42f,1.34f,1.61f,1.11f,1.22f,1.36f,1.50f,1.61f,1.81f,1.75f,1.15f,1.17f,1.41f,1.18f,1.19f,1.42f,1.44f,1.65f,1.83f,1.67f,1.94f,1.81f,1.88f,1.32f,1.58f,1.45f,1.57f,1.74f,1.53f,1.70f,1.98f,1.69f,1.87f,1.77f,1.79f,1.92f,1.45f,1.27f,1.55f,0.97f,1.07f,1.11f,1.34f,1.37f,1.59f,1.60f,1.35f,1.07f,1.18f,0.86f,0.93f,0.87f,0.96f,0.90f,0.93f,0.99f,1.03f,0.95f,1.15f,0.90f,0.99f,1.27f,0.98f,0.90f,0.92f,0.78f,0.83f,0.77f,0.84f,0.79f,0.82f,0.86f,0.73f,0.71f,0.73f,0.72f,0.70f,0.73f,0.72f,0.76f,0.81f,0.76f,0.76f,0.82f,0.77f,0.89f,0.85f,0.82f,0.75f,0.80f,0.80f,0.94f,0.88f,0.94f,0.87f,0.95f,0.96f,0.88f,0.72f,0.74f,0.76f,0.83f,0.78f,0.84f,0.79f,0.87f,0.91f,0.83f,0.89f,0.98f,0.92f,1.23f,1.34f,1.05f,1.16f,0.99f,0.96f,1.46f,1.57f,1.54f,1.33f,1.05f,1.26f,1.08f,1.37f,1.10f,0.98f,1.03f,0.92f,1.14f,0.86f,0.95f,0.97f,0.90f,0.89f,0.79f,0.84f,0.77f,0.82f,0.76f,0.82f,0.97f,0.89f,0.98f,0.71f,0.72f,0.74f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.34f,1.51f,1.53f,1.67f,1.72f,1.71f,1.80f,1.77f,1.91f,1.86f,1.98f,1.86f,1.82f,1.95f,1.89f,1.24f,1.10f,1.41f,0.95f,0.99f,1.09f,1.25f,1.37f,1.63f,1.55f,0.96f,0.98f,1.16f,1.05f,1.00f,1.27f,1.23f,1.50f,1.69f,1.46f,1.86f,1.72f,1.87f,1.24f,1.49f,1.44f,1.69f,1.80f,1.59f,1.69f,1.97f,1.82f,1.94f,1.91f,1.92f,1.99f,1.63f,1.50f,1.74f,1.16f,1.33f,1.38f,1.58f,1.60f,1.77f,1.80f,1.48f,1.21f,1.37f,0.90f,0.97f,0.93f,1.05f,0.97f,1.04f,1.21f,0.99f,0.95f,1.14f,0.92f,1.02f,1.34f,0.94f,0.86f,0.90f,0.74f,0.79f,0.75f,0.81f,0.79f,0.84f,0.86f,0.71f,0.71f,0.73f,0.76f,0.73f,0.77f,0.74f,0.80f,0.85f,0.78f,0.81f,0.89f,0.84f,0.97f,0.92f,0.88f,0.79f,0.85f,0.86f,0.98f,0.92f,1.00f,0.93f,1.06f,1.12f,0.95f,0.74f,0.74f,0.78f,0.79f,0.76f,0.82f,0.79f,0.87f,0.93f,0.85f,0.85f,0.94f,0.90f,1.09f,1.27f,0.99f,1.17f,1.05f,0.96f,1.46f,1.71f,1.62f,1.48f,1.20f,1.34f,1.28f,1.57f,1.35f,0.90f,0.94f,0.85f,0.98f,0.81f,0.89f,0.89f,0.83f,0.82f,0.75f,0.78f,0.73f,0.77f,0.72f,0.76f,0.89f,0.83f,0.91f,0.71f,0.70f,0.72f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, - {1.26f,1.39f,1.48f,1.51f,1.64f,1.71f,1.60f,1.58f,1.77f,1.74f,1.91f,1.94f,1.87f,1.97f,1.85f,1.10f,0.97f,1.22f,0.88f,0.92f,0.95f,1.01f,1.11f,1.39f,1.32f,0.88f,0.90f,0.97f,0.96f,0.93f,1.05f,0.99f,1.27f,1.47f,1.20f,1.70f,1.54f,1.76f,1.08f,1.31f,1.33f,1.70f,1.76f,1.55f,1.57f,1.88f,1.85f,1.91f,1.97f,1.99f,1.99f,1.70f,1.65f,1.85f,1.41f,1.54f,1.61f,1.76f,1.80f,1.91f,1.93f,1.52f,1.26f,1.48f,0.92f,0.99f,0.97f,1.18f,1.09f,1.28f,1.39f,0.94f,0.93f,1.05f,0.92f,1.01f,1.31f,0.88f,0.81f,0.86f,0.72f,0.75f,0.74f,0.79f,0.79f,0.86f,0.85f,0.71f,0.73f,0.75f,0.82f,0.77f,0.83f,0.78f,0.85f,0.88f,0.81f,0.88f,0.97f,0.90f,1.18f,1.00f,0.93f,0.86f,0.92f,0.94f,1.14f,0.99f,1.24f,1.03f,1.33f,1.39f,1.11f,0.79f,0.77f,0.84f,0.79f,0.77f,0.84f,0.83f,0.90f,0.98f,0.91f,0.85f,0.92f,0.91f,1.02f,1.26f,1.00f,1.23f,1.19f,0.99f,1.50f,1.84f,1.71f,1.64f,1.38f,1.46f,1.51f,1.76f,1.59f,0.84f,0.88f,0.80f,0.94f,0.79f,0.86f,0.82f,0.77f,0.76f,0.74f,0.74f,0.71f,0.73f,0.70f,0.72f,0.82f,0.77f,0.85f,0.74f,0.70f,0.73f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f} - }; + + final float[][] VERTEXNORMALS = { + {-0.525731f, 0.000000f, 0.850651f}, + {-0.442863f, 0.238856f, 0.864188f}, + {-0.295242f, 0.000000f, 0.955423f}, + {-0.309017f, 0.500000f, 0.809017f}, + {-0.162460f, 0.262866f, 0.951056f}, + {0.000000f, 0.000000f, 1.000000f}, + {0.000000f, 0.850651f, 0.525731f}, + {-0.147621f, 0.716567f, 0.681718f}, + {0.147621f, 0.716567f, 0.681718f}, + {0.000000f, 0.525731f, 0.850651f}, + {0.309017f, 0.500000f, 0.809017f}, + {0.525731f, 0.000000f, 0.850651f}, + {0.295242f, 0.000000f, 0.955423f}, + {0.442863f, 0.238856f, 0.864188f}, + {0.162460f, 0.262866f, 0.951056f}, + {-0.681718f, 0.147621f, 0.716567f}, + {-0.809017f, 0.309017f, 0.500000f}, + {-0.587785f, 0.425325f, 0.688191f}, + {-0.850651f, 0.525731f, 0.000000f}, + {-0.864188f, 0.442863f, 0.238856f}, + {-0.716567f, 0.681718f, 0.147621f}, + {-0.688191f, 0.587785f, 0.425325f}, + {-0.500000f, 0.809017f, 0.309017f}, + {-0.238856f, 0.864188f, 0.442863f}, + {-0.425325f, 0.688191f, 0.587785f}, + {-0.716567f, 0.681718f, -0.147621f}, + {-0.500000f, 0.809017f, -0.309017f}, + {-0.525731f, 0.850651f, 0.000000f}, + {0.000000f, 0.850651f, -0.525731f}, + {-0.238856f, 0.864188f, -0.442863f}, + {0.000000f, 0.955423f, -0.295242f}, + {-0.262866f, 0.951056f, -0.162460f}, + {0.000000f, 1.000000f, 0.000000f}, + {0.000000f, 0.955423f, 0.295242f}, + {-0.262866f, 0.951056f, 0.162460f}, + {0.238856f, 0.864188f, 0.442863f}, + {0.262866f, 0.951056f, 0.162460f}, + {0.500000f, 0.809017f, 0.309017f}, + {0.238856f, 0.864188f, -0.442863f}, + {0.262866f, 0.951056f, -0.162460f}, + {0.500000f, 0.809017f, -0.309017f}, + {0.850651f, 0.525731f, 0.000000f}, + {0.716567f, 0.681718f, 0.147621f}, + {0.716567f, 0.681718f, -0.147621f}, + {0.525731f, 0.850651f, 0.000000f}, + {0.425325f, 0.688191f, 0.587785f}, + {0.864188f, 0.442863f, 0.238856f}, + {0.688191f, 0.587785f, 0.425325f}, + {0.809017f, 0.309017f, 0.500000f}, + {0.681718f, 0.147621f, 0.716567f}, + {0.587785f, 0.425325f, 0.688191f}, + {0.955423f, 0.295242f, 0.000000f}, + {1.000000f, 0.000000f, 0.000000f}, + {0.951056f, 0.162460f, 0.262866f}, + {0.850651f, -0.525731f, 0.000000f}, + {0.955423f, -0.295242f, 0.000000f}, + {0.864188f, -0.442863f, 0.238856f}, + {0.951056f, -0.162460f, 0.262866f}, + {0.809017f, -0.309017f, 0.500000f}, + {0.681718f, -0.147621f, 0.716567f}, + {0.850651f, 0.000000f, 0.525731f}, + {0.864188f, 0.442863f, -0.238856f}, + {0.809017f, 0.309017f, -0.500000f}, + {0.951056f, 0.162460f, -0.262866f}, + {0.525731f, 0.000000f, -0.850651f}, + {0.681718f, 0.147621f, -0.716567f}, + {0.681718f, -0.147621f, -0.716567f}, + {0.850651f, 0.000000f, -0.525731f}, + {0.809017f, -0.309017f, -0.500000f}, + {0.864188f, -0.442863f, -0.238856f}, + {0.951056f, -0.162460f, -0.262866f}, + {0.147621f, 0.716567f, -0.681718f}, + {0.309017f, 0.500000f, -0.809017f}, + {0.425325f, 0.688191f, -0.587785f}, + {0.442863f, 0.238856f, -0.864188f}, + {0.587785f, 0.425325f, -0.688191f}, + {0.688191f, 0.587785f, -0.425325f}, + {-0.147621f, 0.716567f, -0.681718f}, + {-0.309017f, 0.500000f, -0.809017f}, + {0.000000f, 0.525731f, -0.850651f}, + {-0.525731f, 0.000000f, -0.850651f}, + {-0.442863f, 0.238856f, -0.864188f}, + {-0.295242f, 0.000000f, -0.955423f}, + {-0.162460f, 0.262866f, -0.951056f}, + {0.000000f, 0.000000f, -1.000000f}, + {0.295242f, 0.000000f, -0.955423f}, + {0.162460f, 0.262866f, -0.951056f}, + {-0.442863f, -0.238856f, -0.864188f}, + {-0.309017f, -0.500000f, -0.809017f}, + {-0.162460f, -0.262866f, -0.951056f}, + {0.000000f, -0.850651f, -0.525731f}, + {-0.147621f, -0.716567f, -0.681718f}, + {0.147621f, -0.716567f, -0.681718f}, + {0.000000f, -0.525731f, -0.850651f}, + {0.309017f, -0.500000f, -0.809017f}, + {0.442863f, -0.238856f, -0.864188f}, + {0.162460f, -0.262866f, -0.951056f}, + {0.238856f, -0.864188f, -0.442863f}, + {0.500000f, -0.809017f, -0.309017f}, + {0.425325f, -0.688191f, -0.587785f}, + {0.716567f, -0.681718f, -0.147621f}, + {0.688191f, -0.587785f, -0.425325f}, + {0.587785f, -0.425325f, -0.688191f}, + {0.000000f, -0.955423f, -0.295242f}, + {0.000000f, -1.000000f, 0.000000f}, + {0.262866f, -0.951056f, -0.162460f}, + {0.000000f, -0.850651f, 0.525731f}, + {0.000000f, -0.955423f, 0.295242f}, + {0.238856f, -0.864188f, 0.442863f}, + {0.262866f, -0.951056f, 0.162460f}, + {0.500000f, -0.809017f, 0.309017f}, + {0.716567f, -0.681718f, 0.147621f}, + {0.525731f, -0.850651f, 0.000000f}, + {-0.238856f, -0.864188f, -0.442863f}, + {-0.500000f, -0.809017f, -0.309017f}, + {-0.262866f, -0.951056f, -0.162460f}, + {-0.850651f, -0.525731f, 0.000000f}, + {-0.716567f, -0.681718f, -0.147621f}, + {-0.716567f, -0.681718f, 0.147621f}, + {-0.525731f, -0.850651f, 0.000000f}, + {-0.500000f, -0.809017f, 0.309017f}, + {-0.238856f, -0.864188f, 0.442863f}, + {-0.262866f, -0.951056f, 0.162460f}, + {-0.864188f, -0.442863f, 0.238856f}, + {-0.809017f, -0.309017f, 0.500000f}, + {-0.688191f, -0.587785f, 0.425325f}, + {-0.681718f, -0.147621f, 0.716567f}, + {-0.442863f, -0.238856f, 0.864188f}, + {-0.587785f, -0.425325f, 0.688191f}, + {-0.309017f, -0.500000f, 0.809017f}, + {-0.147621f, -0.716567f, 0.681718f}, + {-0.425325f, -0.688191f, 0.587785f}, + {-0.162460f, -0.262866f, 0.951056f}, + {0.442863f, -0.238856f, 0.864188f}, + {0.162460f, -0.262866f, 0.951056f}, + {0.309017f, -0.500000f, 0.809017f}, + {0.147621f, -0.716567f, 0.681718f}, + {0.000000f, -0.525731f, 0.850651f}, + {0.425325f, -0.688191f, 0.587785f}, + {0.587785f, -0.425325f, 0.688191f}, + {0.688191f, -0.587785f, 0.425325f}, + {-0.955423f, 0.295242f, 0.000000f}, + {-0.951056f, 0.162460f, 0.262866f}, + {-1.000000f, 0.000000f, 0.000000f}, + {-0.850651f, 0.000000f, 0.525731f}, + {-0.955423f, -0.295242f, 0.000000f}, + {-0.951056f, -0.162460f, 0.262866f}, + {-0.864188f, 0.442863f, -0.238856f}, + {-0.951056f, 0.162460f, -0.262866f}, + {-0.809017f, 0.309017f, -0.500000f}, + {-0.864188f, -0.442863f, -0.238856f}, + {-0.951056f, -0.162460f, -0.262866f}, + {-0.809017f, -0.309017f, -0.500000f}, + {-0.681718f, 0.147621f, -0.716567f}, + {-0.681718f, -0.147621f, -0.716567f}, + {-0.850651f, 0.000000f, -0.525731f}, + {-0.688191f, 0.587785f, -0.425325f}, + {-0.587785f, 0.425325f, -0.688191f}, + {-0.425325f, 0.688191f, -0.587785f}, + {-0.425325f, -0.688191f, -0.587785f}, + {-0.587785f, -0.425325f, -0.688191f}, + {-0.688191f, -0.587785f, -0.425325f} + }; + + final float[][] VERTEXNORMAL_DOTS = { + {1.23f,1.30f,1.47f,1.35f,1.56f,1.71f,1.37f,1.38f,1.59f,1.60f,1.79f,1.97f,1.88f,1.92f,1.79f,1.02f,0.93f,1.07f,0.82f,0.87f,0.88f,0.94f,0.96f,1.14f,1.11f,0.82f,0.83f,0.89f,0.89f,0.86f,0.94f,0.91f,1.00f,1.21f,0.98f,1.48f,1.30f,1.57f,0.96f,1.07f,1.14f,1.60f,1.61f,1.40f,1.37f,1.72f,1.78f,1.79f,1.93f,1.99f,1.90f,1.68f,1.71f,1.86f,1.60f,1.68f,1.78f,1.86f,1.93f,1.99f,1.97f,1.44f,1.22f,1.49f,0.93f,0.99f,0.99f,1.23f,1.22f,1.44f,1.49f,0.89f,0.89f,0.97f,0.91f,0.98f,1.19f,0.82f,0.76f,0.82f,0.71f,0.72f,0.73f,0.76f,0.79f,0.86f,0.83f,0.72f,0.76f,0.76f,0.89f,0.82f,0.89f,0.82f,0.89f,0.91f,0.83f,0.96f,1.14f,0.97f,1.40f,1.19f,0.98f,0.94f,1.00f,1.07f,1.37f,1.21f,1.48f,1.30f,1.57f,1.61f,1.37f,0.86f,0.83f,0.91f,0.82f,0.82f,0.88f,0.89f,0.96f,1.14f,0.98f,0.87f,0.93f,0.94f,1.02f,1.30f,1.07f,1.35f,1.38f,1.11f,1.56f,1.92f,1.79f,1.79f,1.59f,1.60f,1.72f,1.90f,1.79f,0.80f,0.85f,0.79f,0.93f,0.80f,0.85f,0.77f,0.74f,0.72f,0.77f,0.74f,0.72f,0.70f,0.70f,0.71f,0.76f,0.73f,0.79f,0.79f,0.73f,0.76f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.26f,1.26f,1.48f,1.23f,1.50f,1.71f,1.14f,1.19f,1.38f,1.46f,1.64f,1.94f,1.87f,1.84f,1.71f,1.02f,0.92f,1.00f,0.79f,0.85f,0.84f,0.91f,0.90f,0.98f,0.99f,0.77f,0.77f,0.83f,0.82f,0.79f,0.86f,0.84f,0.92f,0.99f,0.91f,1.24f,1.03f,1.33f,0.88f,0.94f,0.97f,1.41f,1.39f,1.18f,1.11f,1.51f,1.61f,1.59f,1.80f,1.91f,1.76f,1.54f,1.65f,1.76f,1.70f,1.70f,1.85f,1.85f,1.97f,1.99f,1.93f,1.28f,1.09f,1.39f,0.92f,0.97f,0.99f,1.18f,1.26f,1.52f,1.48f,0.83f,0.85f,0.90f,0.88f,0.93f,1.00f,0.77f,0.73f,0.78f,0.72f,0.71f,0.74f,0.75f,0.79f,0.86f,0.81f,0.75f,0.81f,0.79f,0.96f,0.88f,0.94f,0.86f,0.93f,0.92f,0.85f,1.08f,1.33f,1.05f,1.55f,1.31f,1.01f,1.05f,1.27f,1.31f,1.60f,1.47f,1.70f,1.54f,1.76f,1.76f,1.57f,0.93f,0.90f,0.99f,0.88f,0.88f,0.95f,0.97f,1.11f,1.39f,1.20f,0.92f,0.97f,1.01f,1.10f,1.39f,1.22f,1.51f,1.58f,1.32f,1.64f,1.97f,1.85f,1.91f,1.77f,1.74f,1.88f,1.99f,1.91f,0.79f,0.86f,0.80f,0.94f,0.84f,0.88f,0.74f,0.74f,0.71f,0.82f,0.77f,0.76f,0.70f,0.73f,0.72f,0.73f,0.70f,0.74f,0.85f,0.77f,0.82f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.34f,1.27f,1.53f,1.17f,1.46f,1.71f,0.98f,1.05f,1.20f,1.34f,1.48f,1.86f,1.82f,1.71f,1.62f,1.09f,0.94f,0.99f,0.79f,0.85f,0.82f,0.90f,0.87f,0.93f,0.96f,0.76f,0.74f,0.79f,0.76f,0.74f,0.79f,0.78f,0.85f,0.92f,0.85f,1.00f,0.93f,1.06f,0.81f,0.86f,0.89f,1.16f,1.12f,0.97f,0.95f,1.28f,1.38f,1.35f,1.60f,1.77f,1.57f,1.33f,1.50f,1.58f,1.69f,1.63f,1.82f,1.74f,1.91f,1.92f,1.80f,1.04f,0.97f,1.21f,0.90f,0.93f,0.97f,1.05f,1.21f,1.48f,1.37f,0.77f,0.80f,0.84f,0.85f,0.88f,0.92f,0.73f,0.71f,0.74f,0.74f,0.71f,0.75f,0.73f,0.79f,0.84f,0.78f,0.79f,0.86f,0.81f,1.05f,0.94f,0.99f,0.90f,0.95f,0.92f,0.86f,1.24f,1.44f,1.14f,1.59f,1.34f,1.02f,1.27f,1.50f,1.49f,1.80f,1.69f,1.86f,1.72f,1.87f,1.80f,1.69f,1.00f,0.98f,1.23f,0.95f,0.96f,1.09f,1.16f,1.37f,1.63f,1.46f,0.99f,1.10f,1.25f,1.24f,1.51f,1.41f,1.67f,1.77f,1.55f,1.72f,1.95f,1.89f,1.98f,1.91f,1.86f,1.97f,1.99f,1.94f,0.81f,0.89f,0.85f,0.98f,0.90f,0.94f,0.75f,0.78f,0.73f,0.89f,0.83f,0.82f,0.72f,0.77f,0.76f,0.72f,0.70f,0.71f,0.91f,0.83f,0.89f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.46f,1.34f,1.60f,1.16f,1.46f,1.71f,0.94f,0.99f,1.05f,1.26f,1.33f,1.74f,1.76f,1.57f,1.54f,1.23f,0.98f,1.05f,0.83f,0.89f,0.84f,0.92f,0.87f,0.91f,0.96f,0.78f,0.74f,0.79f,0.72f,0.72f,0.75f,0.76f,0.80f,0.88f,0.83f,0.94f,0.87f,0.95f,0.76f,0.80f,0.82f,0.97f,0.96f,0.89f,0.88f,1.08f,1.11f,1.10f,1.37f,1.59f,1.37f,1.07f,1.27f,1.34f,1.57f,1.45f,1.69f,1.55f,1.77f,1.79f,1.60f,0.93f,0.90f,0.99f,0.86f,0.87f,0.93f,0.96f,1.07f,1.35f,1.18f,0.73f,0.76f,0.77f,0.81f,0.82f,0.85f,0.70f,0.71f,0.72f,0.78f,0.73f,0.77f,0.73f,0.79f,0.82f,0.76f,0.83f,0.90f,0.84f,1.18f,0.98f,1.03f,0.92f,0.95f,0.90f,0.86f,1.32f,1.45f,1.15f,1.53f,1.27f,0.99f,1.42f,1.65f,1.58f,1.93f,1.83f,1.94f,1.81f,1.88f,1.74f,1.70f,1.19f,1.17f,1.44f,1.11f,1.15f,1.36f,1.41f,1.61f,1.81f,1.67f,1.22f,1.34f,1.50f,1.42f,1.65f,1.61f,1.82f,1.91f,1.75f,1.80f,1.89f,1.89f,1.98f,1.99f,1.94f,1.98f,1.92f,1.87f,0.86f,0.95f,0.92f,1.14f,0.98f,1.03f,0.79f,0.84f,0.77f,0.97f,0.90f,0.89f,0.76f,0.82f,0.82f,0.74f,0.72f,0.71f,0.98f,0.89f,0.97f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.60f,1.44f,1.68f,1.22f,1.49f,1.71f,0.93f,0.99f,0.99f,1.23f,1.22f,1.60f,1.68f,1.44f,1.49f,1.40f,1.14f,1.19f,0.89f,0.96f,0.89f,0.97f,0.89f,0.91f,0.98f,0.82f,0.76f,0.82f,0.71f,0.72f,0.73f,0.76f,0.79f,0.86f,0.83f,0.91f,0.83f,0.89f,0.72f,0.76f,0.76f,0.89f,0.89f,0.82f,0.82f,0.98f,0.96f,0.97f,1.14f,1.40f,1.19f,0.94f,1.00f,1.07f,1.37f,1.21f,1.48f,1.30f,1.57f,1.61f,1.37f,0.86f,0.83f,0.91f,0.82f,0.82f,0.88f,0.89f,0.96f,1.14f,0.98f,0.70f,0.72f,0.73f,0.77f,0.76f,0.79f,0.70f,0.72f,0.71f,0.82f,0.77f,0.80f,0.74f,0.79f,0.80f,0.74f,0.87f,0.93f,0.85f,1.23f,1.02f,1.02f,0.93f,0.93f,0.87f,0.85f,1.30f,1.35f,1.07f,1.38f,1.11f,0.94f,1.47f,1.71f,1.56f,1.97f,1.88f,1.92f,1.79f,1.79f,1.59f,1.60f,1.30f,1.35f,1.56f,1.37f,1.38f,1.59f,1.60f,1.79f,1.92f,1.79f,1.48f,1.57f,1.72f,1.61f,1.78f,1.79f,1.93f,1.99f,1.90f,1.86f,1.78f,1.86f,1.93f,1.99f,1.97f,1.90f,1.79f,1.72f,0.94f,1.07f,1.00f,1.37f,1.21f,1.30f,0.86f,0.91f,0.83f,1.14f,0.98f,0.96f,0.82f,0.88f,0.89f,0.79f,0.76f,0.73f,1.07f,0.94f,1.11f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.74f,1.57f,1.76f,1.33f,1.54f,1.71f,0.94f,1.05f,0.99f,1.26f,1.16f,1.46f,1.60f,1.34f,1.46f,1.59f,1.37f,1.37f,0.97f,1.11f,0.96f,1.10f,0.95f,0.94f,1.08f,0.89f,0.82f,0.88f,0.72f,0.76f,0.75f,0.80f,0.80f,0.88f,0.87f,0.91f,0.83f,0.87f,0.72f,0.76f,0.74f,0.83f,0.84f,0.78f,0.79f,0.96f,0.89f,0.92f,0.98f,1.23f,1.05f,0.86f,0.92f,0.95f,1.11f,0.98f,1.22f,1.03f,1.34f,1.42f,1.14f,0.79f,0.77f,0.84f,0.78f,0.76f,0.82f,0.82f,0.89f,0.97f,0.90f,0.70f,0.71f,0.71f,0.73f,0.72f,0.74f,0.73f,0.76f,0.72f,0.86f,0.81f,0.82f,0.76f,0.79f,0.77f,0.73f,0.90f,0.95f,0.86f,1.18f,1.03f,0.98f,0.92f,0.90f,0.83f,0.84f,1.19f,1.17f,0.98f,1.15f,0.97f,0.89f,1.42f,1.65f,1.44f,1.93f,1.83f,1.81f,1.67f,1.61f,1.36f,1.41f,1.32f,1.45f,1.58f,1.57f,1.53f,1.74f,1.70f,1.88f,1.94f,1.81f,1.69f,1.77f,1.87f,1.79f,1.89f,1.92f,1.98f,1.99f,1.98f,1.89f,1.65f,1.80f,1.82f,1.91f,1.94f,1.75f,1.61f,1.50f,1.07f,1.34f,1.27f,1.60f,1.45f,1.55f,0.93f,0.99f,0.90f,1.35f,1.18f,1.07f,0.87f,0.93f,0.96f,0.85f,0.82f,0.77f,1.15f,0.99f,1.27f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.86f,1.71f,1.82f,1.48f,1.62f,1.71f,0.98f,1.20f,1.05f,1.34f,1.17f,1.34f,1.53f,1.27f,1.46f,1.77f,1.60f,1.57f,1.16f,1.38f,1.12f,1.35f,1.06f,1.00f,1.28f,0.97f,0.89f,0.95f,0.76f,0.81f,0.79f,0.86f,0.85f,0.92f,0.93f,0.93f,0.85f,0.87f,0.74f,0.78f,0.74f,0.79f,0.82f,0.76f,0.79f,0.96f,0.85f,0.90f,0.94f,1.09f,0.99f,0.81f,0.85f,0.89f,0.95f,0.90f,0.99f,0.94f,1.10f,1.24f,0.98f,0.75f,0.73f,0.78f,0.74f,0.72f,0.77f,0.76f,0.82f,0.89f,0.83f,0.73f,0.71f,0.71f,0.71f,0.70f,0.72f,0.77f,0.80f,0.74f,0.90f,0.85f,0.84f,0.78f,0.79f,0.75f,0.73f,0.92f,0.95f,0.86f,1.05f,0.99f,0.94f,0.90f,0.86f,0.79f,0.81f,1.00f,0.98f,0.91f,0.96f,0.89f,0.83f,1.27f,1.50f,1.23f,1.80f,1.69f,1.63f,1.46f,1.37f,1.09f,1.16f,1.24f,1.44f,1.49f,1.69f,1.59f,1.80f,1.69f,1.87f,1.86f,1.72f,1.82f,1.91f,1.94f,1.92f,1.95f,1.99f,1.98f,1.91f,1.97f,1.89f,1.51f,1.72f,1.67f,1.77f,1.86f,1.55f,1.41f,1.25f,1.33f,1.58f,1.50f,1.80f,1.63f,1.74f,1.04f,1.21f,0.97f,1.48f,1.37f,1.21f,0.93f,0.97f,1.05f,0.92f,0.88f,0.84f,1.14f,1.02f,1.34f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.94f,1.84f,1.87f,1.64f,1.71f,1.71f,1.14f,1.38f,1.19f,1.46f,1.23f,1.26f,1.48f,1.26f,1.50f,1.91f,1.80f,1.76f,1.41f,1.61f,1.39f,1.59f,1.33f,1.24f,1.51f,1.18f,0.97f,1.11f,0.82f,0.88f,0.86f,0.94f,0.92f,0.99f,1.03f,0.98f,0.91f,0.90f,0.79f,0.84f,0.77f,0.79f,0.84f,0.77f,0.83f,0.99f,0.85f,0.91f,0.92f,1.02f,1.00f,0.79f,0.80f,0.86f,0.88f,0.84f,0.92f,0.88f,0.97f,1.10f,0.94f,0.74f,0.71f,0.74f,0.72f,0.70f,0.73f,0.72f,0.76f,0.82f,0.77f,0.77f,0.73f,0.74f,0.71f,0.70f,0.73f,0.83f,0.85f,0.78f,0.92f,0.88f,0.86f,0.81f,0.79f,0.74f,0.75f,0.92f,0.93f,0.85f,0.96f,0.94f,0.88f,0.86f,0.81f,0.75f,0.79f,0.93f,0.90f,0.85f,0.88f,0.82f,0.77f,1.05f,1.27f,0.99f,1.60f,1.47f,1.39f,1.20f,1.11f,0.95f,0.97f,1.08f,1.33f,1.31f,1.70f,1.55f,1.76f,1.57f,1.76f,1.70f,1.54f,1.85f,1.97f,1.91f,1.99f,1.97f,1.99f,1.91f,1.77f,1.88f,1.85f,1.39f,1.64f,1.51f,1.58f,1.74f,1.32f,1.22f,1.01f,1.54f,1.76f,1.65f,1.93f,1.70f,1.85f,1.28f,1.39f,1.09f,1.52f,1.48f,1.26f,0.97f,0.99f,1.18f,1.00f,0.93f,0.90f,1.05f,1.01f,1.31f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.97f,1.92f,1.88f,1.79f,1.79f,1.71f,1.37f,1.59f,1.38f,1.60f,1.35f,1.23f,1.47f,1.30f,1.56f,1.99f,1.93f,1.90f,1.60f,1.78f,1.61f,1.79f,1.57f,1.48f,1.72f,1.40f,1.14f,1.37f,0.89f,0.96f,0.94f,1.07f,1.00f,1.21f,1.30f,1.14f,0.98f,0.96f,0.86f,0.91f,0.83f,0.82f,0.88f,0.82f,0.89f,1.11f,0.87f,0.94f,0.93f,1.02f,1.07f,0.80f,0.79f,0.85f,0.82f,0.80f,0.87f,0.85f,0.93f,1.02f,0.93f,0.77f,0.72f,0.74f,0.71f,0.70f,0.70f,0.71f,0.72f,0.77f,0.74f,0.82f,0.76f,0.79f,0.72f,0.73f,0.76f,0.89f,0.89f,0.82f,0.93f,0.91f,0.86f,0.83f,0.79f,0.73f,0.76f,0.91f,0.89f,0.83f,0.89f,0.89f,0.82f,0.82f,0.76f,0.72f,0.76f,0.86f,0.83f,0.79f,0.82f,0.76f,0.73f,0.94f,1.00f,0.91f,1.37f,1.21f,1.14f,0.98f,0.96f,0.88f,0.89f,0.96f,1.14f,1.07f,1.60f,1.40f,1.61f,1.37f,1.57f,1.48f,1.30f,1.78f,1.93f,1.79f,1.99f,1.92f,1.90f,1.79f,1.59f,1.72f,1.79f,1.30f,1.56f,1.35f,1.38f,1.60f,1.11f,1.07f,0.94f,1.68f,1.86f,1.71f,1.97f,1.68f,1.86f,1.44f,1.49f,1.22f,1.44f,1.49f,1.22f,0.99f,0.99f,1.23f,1.19f,0.98f,0.97f,0.97f,0.98f,1.19f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.94f,1.97f,1.87f,1.91f,1.85f,1.71f,1.60f,1.77f,1.58f,1.74f,1.51f,1.26f,1.48f,1.39f,1.64f,1.99f,1.97f,1.99f,1.70f,1.85f,1.76f,1.91f,1.76f,1.70f,1.88f,1.55f,1.33f,1.57f,0.96f,1.08f,1.05f,1.31f,1.27f,1.47f,1.54f,1.39f,1.20f,1.11f,0.93f,0.99f,0.90f,0.88f,0.95f,0.88f,0.97f,1.32f,0.92f,1.01f,0.97f,1.10f,1.22f,0.84f,0.80f,0.88f,0.79f,0.79f,0.85f,0.86f,0.92f,1.02f,0.94f,0.82f,0.76f,0.77f,0.72f,0.73f,0.70f,0.72f,0.71f,0.74f,0.74f,0.88f,0.81f,0.85f,0.75f,0.77f,0.82f,0.94f,0.93f,0.86f,0.92f,0.92f,0.86f,0.85f,0.79f,0.74f,0.79f,0.88f,0.85f,0.81f,0.82f,0.83f,0.77f,0.78f,0.73f,0.71f,0.75f,0.79f,0.77f,0.74f,0.77f,0.73f,0.70f,0.86f,0.92f,0.84f,1.14f,0.99f,0.98f,0.91f,0.90f,0.84f,0.83f,0.88f,0.97f,0.94f,1.41f,1.18f,1.39f,1.11f,1.33f,1.24f,1.03f,1.61f,1.80f,1.59f,1.91f,1.84f,1.76f,1.64f,1.38f,1.51f,1.71f,1.26f,1.50f,1.23f,1.19f,1.46f,0.99f,1.00f,0.91f,1.70f,1.85f,1.65f,1.93f,1.54f,1.76f,1.52f,1.48f,1.26f,1.28f,1.39f,1.09f,0.99f,0.97f,1.18f,1.31f,1.01f,1.05f,0.90f,0.93f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.86f,1.95f,1.82f,1.98f,1.89f,1.71f,1.80f,1.91f,1.77f,1.86f,1.67f,1.34f,1.53f,1.51f,1.72f,1.92f,1.91f,1.99f,1.69f,1.82f,1.80f,1.94f,1.87f,1.86f,1.97f,1.59f,1.44f,1.69f,1.05f,1.24f,1.27f,1.49f,1.50f,1.69f,1.72f,1.63f,1.46f,1.37f,1.00f,1.23f,0.98f,0.95f,1.09f,0.96f,1.16f,1.55f,0.99f,1.25f,1.10f,1.24f,1.41f,0.90f,0.85f,0.94f,0.79f,0.81f,0.85f,0.89f,0.94f,1.09f,0.98f,0.89f,0.82f,0.83f,0.74f,0.77f,0.72f,0.76f,0.73f,0.75f,0.78f,0.94f,0.86f,0.91f,0.79f,0.83f,0.89f,0.99f,0.95f,0.90f,0.90f,0.92f,0.84f,0.86f,0.79f,0.75f,0.81f,0.85f,0.80f,0.78f,0.76f,0.77f,0.73f,0.74f,0.71f,0.71f,0.73f,0.74f,0.74f,0.71f,0.76f,0.72f,0.70f,0.79f,0.85f,0.78f,0.98f,0.92f,0.93f,0.85f,0.87f,0.82f,0.79f,0.81f,0.89f,0.86f,1.16f,0.97f,1.12f,0.95f,1.06f,1.00f,0.93f,1.38f,1.60f,1.35f,1.77f,1.71f,1.57f,1.48f,1.20f,1.28f,1.62f,1.27f,1.46f,1.17f,1.05f,1.34f,0.96f,0.99f,0.90f,1.63f,1.74f,1.50f,1.80f,1.33f,1.58f,1.48f,1.37f,1.21f,1.04f,1.21f,0.97f,0.97f,0.93f,1.05f,1.34f,1.02f,1.14f,0.84f,0.88f,0.92f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.74f,1.89f,1.76f,1.98f,1.89f,1.71f,1.93f,1.99f,1.91f,1.94f,1.82f,1.46f,1.60f,1.65f,1.80f,1.79f,1.77f,1.92f,1.57f,1.69f,1.74f,1.87f,1.88f,1.94f,1.98f,1.53f,1.45f,1.70f,1.18f,1.32f,1.42f,1.58f,1.65f,1.83f,1.81f,1.81f,1.67f,1.61f,1.19f,1.44f,1.17f,1.11f,1.36f,1.15f,1.41f,1.75f,1.22f,1.50f,1.34f,1.42f,1.61f,0.98f,0.92f,1.03f,0.83f,0.86f,0.89f,0.95f,0.98f,1.23f,1.14f,0.97f,0.89f,0.90f,0.78f,0.82f,0.76f,0.82f,0.77f,0.79f,0.84f,0.98f,0.90f,0.98f,0.83f,0.89f,0.97f,1.03f,0.95f,0.92f,0.86f,0.90f,0.82f,0.86f,0.79f,0.77f,0.84f,0.81f,0.76f,0.76f,0.72f,0.73f,0.70f,0.72f,0.71f,0.73f,0.73f,0.72f,0.74f,0.71f,0.78f,0.74f,0.72f,0.75f,0.80f,0.76f,0.94f,0.88f,0.91f,0.83f,0.87f,0.84f,0.79f,0.76f,0.82f,0.80f,0.97f,0.89f,0.96f,0.88f,0.95f,0.94f,0.87f,1.11f,1.37f,1.10f,1.59f,1.57f,1.37f,1.33f,1.05f,1.08f,1.54f,1.34f,1.46f,1.16f,0.99f,1.26f,0.96f,1.05f,0.92f,1.45f,1.55f,1.27f,1.60f,1.07f,1.34f,1.35f,1.18f,1.07f,0.93f,0.99f,0.90f,0.93f,0.87f,0.96f,1.27f,0.99f,1.15f,0.77f,0.82f,0.85f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.60f,1.78f,1.68f,1.93f,1.86f,1.71f,1.97f,1.99f,1.99f,1.97f,1.93f,1.60f,1.68f,1.78f,1.86f,1.61f,1.57f,1.79f,1.37f,1.48f,1.59f,1.72f,1.79f,1.92f,1.90f,1.38f,1.35f,1.60f,1.23f,1.30f,1.47f,1.56f,1.71f,1.88f,1.79f,1.92f,1.79f,1.79f,1.30f,1.56f,1.35f,1.37f,1.59f,1.38f,1.60f,1.90f,1.48f,1.72f,1.57f,1.61f,1.79f,1.21f,1.00f,1.30f,0.89f,0.94f,0.96f,1.07f,1.14f,1.40f,1.37f,1.14f,0.96f,0.98f,0.82f,0.88f,0.82f,0.89f,0.83f,0.86f,0.91f,1.02f,0.93f,1.07f,0.87f,0.94f,1.11f,1.02f,0.93f,0.93f,0.82f,0.87f,0.80f,0.85f,0.79f,0.80f,0.85f,0.77f,0.72f,0.74f,0.71f,0.70f,0.70f,0.71f,0.72f,0.77f,0.74f,0.72f,0.76f,0.73f,0.82f,0.79f,0.76f,0.73f,0.79f,0.76f,0.93f,0.86f,0.91f,0.83f,0.89f,0.89f,0.82f,0.72f,0.76f,0.76f,0.89f,0.82f,0.89f,0.82f,0.89f,0.91f,0.83f,0.96f,1.14f,0.97f,1.40f,1.44f,1.19f,1.22f,0.99f,0.98f,1.49f,1.44f,1.49f,1.22f,0.99f,1.23f,0.98f,1.19f,0.97f,1.21f,1.30f,1.00f,1.37f,0.94f,1.07f,1.14f,0.98f,0.96f,0.86f,0.91f,0.83f,0.88f,0.82f,0.89f,1.11f,0.94f,1.07f,0.73f,0.76f,0.79f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.46f,1.65f,1.60f,1.82f,1.80f,1.71f,1.93f,1.91f,1.99f,1.94f,1.98f,1.74f,1.76f,1.89f,1.89f,1.42f,1.34f,1.61f,1.11f,1.22f,1.36f,1.50f,1.61f,1.81f,1.75f,1.15f,1.17f,1.41f,1.18f,1.19f,1.42f,1.44f,1.65f,1.83f,1.67f,1.94f,1.81f,1.88f,1.32f,1.58f,1.45f,1.57f,1.74f,1.53f,1.70f,1.98f,1.69f,1.87f,1.77f,1.79f,1.92f,1.45f,1.27f,1.55f,0.97f,1.07f,1.11f,1.34f,1.37f,1.59f,1.60f,1.35f,1.07f,1.18f,0.86f,0.93f,0.87f,0.96f,0.90f,0.93f,0.99f,1.03f,0.95f,1.15f,0.90f,0.99f,1.27f,0.98f,0.90f,0.92f,0.78f,0.83f,0.77f,0.84f,0.79f,0.82f,0.86f,0.73f,0.71f,0.73f,0.72f,0.70f,0.73f,0.72f,0.76f,0.81f,0.76f,0.76f,0.82f,0.77f,0.89f,0.85f,0.82f,0.75f,0.80f,0.80f,0.94f,0.88f,0.94f,0.87f,0.95f,0.96f,0.88f,0.72f,0.74f,0.76f,0.83f,0.78f,0.84f,0.79f,0.87f,0.91f,0.83f,0.89f,0.98f,0.92f,1.23f,1.34f,1.05f,1.16f,0.99f,0.96f,1.46f,1.57f,1.54f,1.33f,1.05f,1.26f,1.08f,1.37f,1.10f,0.98f,1.03f,0.92f,1.14f,0.86f,0.95f,0.97f,0.90f,0.89f,0.79f,0.84f,0.77f,0.82f,0.76f,0.82f,0.97f,0.89f,0.98f,0.71f,0.72f,0.74f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.34f,1.51f,1.53f,1.67f,1.72f,1.71f,1.80f,1.77f,1.91f,1.86f,1.98f,1.86f,1.82f,1.95f,1.89f,1.24f,1.10f,1.41f,0.95f,0.99f,1.09f,1.25f,1.37f,1.63f,1.55f,0.96f,0.98f,1.16f,1.05f,1.00f,1.27f,1.23f,1.50f,1.69f,1.46f,1.86f,1.72f,1.87f,1.24f,1.49f,1.44f,1.69f,1.80f,1.59f,1.69f,1.97f,1.82f,1.94f,1.91f,1.92f,1.99f,1.63f,1.50f,1.74f,1.16f,1.33f,1.38f,1.58f,1.60f,1.77f,1.80f,1.48f,1.21f,1.37f,0.90f,0.97f,0.93f,1.05f,0.97f,1.04f,1.21f,0.99f,0.95f,1.14f,0.92f,1.02f,1.34f,0.94f,0.86f,0.90f,0.74f,0.79f,0.75f,0.81f,0.79f,0.84f,0.86f,0.71f,0.71f,0.73f,0.76f,0.73f,0.77f,0.74f,0.80f,0.85f,0.78f,0.81f,0.89f,0.84f,0.97f,0.92f,0.88f,0.79f,0.85f,0.86f,0.98f,0.92f,1.00f,0.93f,1.06f,1.12f,0.95f,0.74f,0.74f,0.78f,0.79f,0.76f,0.82f,0.79f,0.87f,0.93f,0.85f,0.85f,0.94f,0.90f,1.09f,1.27f,0.99f,1.17f,1.05f,0.96f,1.46f,1.71f,1.62f,1.48f,1.20f,1.34f,1.28f,1.57f,1.35f,0.90f,0.94f,0.85f,0.98f,0.81f,0.89f,0.89f,0.83f,0.82f,0.75f,0.78f,0.73f,0.77f,0.72f,0.76f,0.89f,0.83f,0.91f,0.71f,0.70f,0.72f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f}, + {1.26f,1.39f,1.48f,1.51f,1.64f,1.71f,1.60f,1.58f,1.77f,1.74f,1.91f,1.94f,1.87f,1.97f,1.85f,1.10f,0.97f,1.22f,0.88f,0.92f,0.95f,1.01f,1.11f,1.39f,1.32f,0.88f,0.90f,0.97f,0.96f,0.93f,1.05f,0.99f,1.27f,1.47f,1.20f,1.70f,1.54f,1.76f,1.08f,1.31f,1.33f,1.70f,1.76f,1.55f,1.57f,1.88f,1.85f,1.91f,1.97f,1.99f,1.99f,1.70f,1.65f,1.85f,1.41f,1.54f,1.61f,1.76f,1.80f,1.91f,1.93f,1.52f,1.26f,1.48f,0.92f,0.99f,0.97f,1.18f,1.09f,1.28f,1.39f,0.94f,0.93f,1.05f,0.92f,1.01f,1.31f,0.88f,0.81f,0.86f,0.72f,0.75f,0.74f,0.79f,0.79f,0.86f,0.85f,0.71f,0.73f,0.75f,0.82f,0.77f,0.83f,0.78f,0.85f,0.88f,0.81f,0.88f,0.97f,0.90f,1.18f,1.00f,0.93f,0.86f,0.92f,0.94f,1.14f,0.99f,1.24f,1.03f,1.33f,1.39f,1.11f,0.79f,0.77f,0.84f,0.79f,0.77f,0.84f,0.83f,0.90f,0.98f,0.91f,0.85f,0.92f,0.91f,1.02f,1.26f,1.00f,1.23f,1.19f,0.99f,1.50f,1.84f,1.71f,1.64f,1.38f,1.46f,1.51f,1.76f,1.59f,0.84f,0.88f,0.80f,0.94f,0.79f,0.86f,0.82f,0.77f,0.76f,0.74f,0.74f,0.71f,0.73f,0.70f,0.72f,0.82f,0.77f,0.85f,0.74f,0.70f,0.73f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f,1.00f} + }; } diff --git a/src/main/java/lwjake2/render/lwjgl/Draw.java b/src/main/java/lwjake2/render/lwjgl/Draw.java index 3313075..0c893da 100644 --- a/src/main/java/lwjake2/render/lwjgl/Draw.java +++ b/src/main/java/lwjake2/render/lwjgl/Draw.java @@ -38,262 +38,262 @@ import org.lwjgl.opengl.GL11; */ public abstract class Draw extends Image { - /* - =============== - Draw_InitLocal - =============== - */ - void Draw_InitLocal() { - // load console characters (don't bilerp characters) - draw_chars = GL_FindImage("pics/conchars.pcx", it_pic); - GL_Bind(draw_chars.texnum); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); - } + /* + =============== + Draw_InitLocal + =============== + */ + void Draw_InitLocal() { + // load console characters (don't bilerp characters) + draw_chars = GL_FindImage("pics/conchars.pcx", it_pic); + GL_Bind(draw_chars.texnum); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + } - /* - ================ - Draw_Char + /* + ================ + Draw_Char - Draws one 8*8 graphics character with 0 being transparent. - It can be clipped to the top of the screen to allow the console to be - smoothly scrolled off. - ================ - */ - protected void Draw_Char(int x, int y, int num) { + Draws one 8*8 graphics character with 0 being transparent. + It can be clipped to the top of the screen to allow the console to be + smoothly scrolled off. + ================ + */ + protected void Draw_Char(int x, int y, int num) { - num &= 255; - - if ( (num&127) == 32 ) return; // space + num &= 255; + + if ( (num&127) == 32 ) return; // space - if (y <= -8) return; // totally off screen + if (y <= -8) return; // totally off screen - int row = num>>4; - int col = num&15; + int row = num>>4; + int col = num&15; - float frow = row*0.0625f; - float fcol = col*0.0625f; - float size = 0.0625f; + float frow = row*0.0625f; + float fcol = col*0.0625f; + float size = 0.0625f; - GL_Bind(draw_chars.texnum); + GL_Bind(draw_chars.texnum); - GL11.glBegin (GL11.GL_QUADS); - GL11.glTexCoord2f (fcol, frow); - GL11.glVertex2f (x, y); - GL11.glTexCoord2f (fcol + size, frow); - GL11.glVertex2f (x+8, y); - GL11.glTexCoord2f (fcol + size, frow + size); - GL11.glVertex2f (x+8, y+8); - GL11.glTexCoord2f (fcol, frow + size); - GL11.glVertex2f (x, y+8); - GL11.glEnd (); - } + GL11.glBegin (GL11.GL_QUADS); + GL11.glTexCoord2f (fcol, frow); + GL11.glVertex2f (x, y); + GL11.glTexCoord2f (fcol + size, frow); + GL11.glVertex2f (x+8, y); + GL11.glTexCoord2f (fcol + size, frow + size); + GL11.glVertex2f (x+8, y+8); + GL11.glTexCoord2f (fcol, frow + size); + GL11.glVertex2f (x, y+8); + GL11.glEnd (); + } - /* - ============= - Draw_FindPic - ============= - */ - protected image_t Draw_FindPic(String name) { - image_t image = null; - String fullname; + /* + ============= + Draw_FindPic + ============= + */ + protected image_t Draw_FindPic(String name) { + image_t image = null; + String fullname; - if (!name.startsWith("/") && !name.startsWith("\\")) - { - fullname = "pics/" + name + ".pcx"; - image = GL_FindImage(fullname, it_pic); - } else { - image = GL_FindImage(name.substring(1), it_pic); - } - return image; - } + if (!name.startsWith("/") && !name.startsWith("\\")) + { + fullname = "pics/" + name + ".pcx"; + image = GL_FindImage(fullname, it_pic); + } else { + image = GL_FindImage(name.substring(1), it_pic); + } + return image; + } - /* - ============= - Draw_GetPicSize - ============= - */ - protected void Draw_GetPicSize(Dimension dim, String pic) { + /* + ============= + Draw_GetPicSize + ============= + */ + protected void Draw_GetPicSize(Dimension dim, String pic) { - image_t image = Draw_FindPic(pic); - dim.width = (image != null) ? image.width : -1; - dim.height = (image != null) ? image.height : -1; - } + image_t image = Draw_FindPic(pic); + dim.width = (image != null) ? image.width : -1; + dim.height = (image != null) ? image.height : -1; + } - /* - ============= - Draw_StretchPic - ============= - */ - protected void Draw_StretchPic (int x, int y, int w, int h, String pic) { - - image_t image; + /* + ============= + Draw_StretchPic + ============= + */ + protected void Draw_StretchPic (int x, int y, int w, int h, String pic) { + + image_t image; - image = Draw_FindPic(pic); - if (image == null) - { - VID.Printf (Defines.PRINT_ALL, "Can't find pic: " + pic +'\n'); - return; - } + image = Draw_FindPic(pic); + if (image == null) + { + VID.Printf (Defines.PRINT_ALL, "Can't find pic: " + pic +'\n'); + return; + } - if (scrap_dirty) - Scrap_Upload(); + if (scrap_dirty) + Scrap_Upload(); - if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0) ) && !image.has_alpha) - GL11.glDisable(GL11.GL_ALPHA_TEST); + if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0) ) && !image.has_alpha) + GL11.glDisable(GL11.GL_ALPHA_TEST); - GL_Bind(image.texnum); - GL11.glBegin (GL11.GL_QUADS); - GL11.glTexCoord2f (image.sl, image.tl); - GL11.glVertex2f (x, y); - GL11.glTexCoord2f (image.sh, image.tl); - GL11.glVertex2f (x+w, y); - GL11.glTexCoord2f (image.sh, image.th); - GL11.glVertex2f (x+w, y+h); - GL11.glTexCoord2f (image.sl, image.th); - GL11.glVertex2f (x, y+h); - GL11.glEnd (); + GL_Bind(image.texnum); + GL11.glBegin (GL11.GL_QUADS); + GL11.glTexCoord2f (image.sl, image.tl); + GL11.glVertex2f (x, y); + GL11.glTexCoord2f (image.sh, image.tl); + GL11.glVertex2f (x+w, y); + GL11.glTexCoord2f (image.sh, image.th); + GL11.glVertex2f (x+w, y+h); + GL11.glTexCoord2f (image.sl, image.th); + GL11.glVertex2f (x, y+h); + GL11.glEnd (); - if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) !=0 ) ) && !image.has_alpha) - GL11.glEnable(GL11.GL_ALPHA_TEST); - } + if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) !=0 ) ) && !image.has_alpha) + GL11.glEnable(GL11.GL_ALPHA_TEST); + } - /* - ============= - Draw_Pic - ============= - */ - protected void Draw_Pic(int x, int y, String pic) - { - image_t image; + /* + ============= + Draw_Pic + ============= + */ + protected void Draw_Pic(int x, int y, String pic) + { + image_t image; - image = Draw_FindPic(pic); - if (image == null) - { - VID.Printf(Defines.PRINT_ALL, "Can't find pic: " +pic + '\n'); - return; - } - if (scrap_dirty) - Scrap_Upload(); + image = Draw_FindPic(pic); + if (image == null) + { + VID.Printf(Defines.PRINT_ALL, "Can't find pic: " +pic + '\n'); + return; + } + if (scrap_dirty) + Scrap_Upload(); - if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha) - GL11.glDisable (GL11.GL_ALPHA_TEST); + if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha) + GL11.glDisable (GL11.GL_ALPHA_TEST); - GL_Bind(image.texnum); + GL_Bind(image.texnum); - GL11.glBegin (GL11.GL_QUADS); - GL11.glTexCoord2f (image.sl, image.tl); - GL11.glVertex2f (x, y); - GL11.glTexCoord2f (image.sh, image.tl); - GL11.glVertex2f (x+image.width, y); - GL11.glTexCoord2f (image.sh, image.th); - GL11.glVertex2f (x+image.width, y+image.height); - GL11.glTexCoord2f (image.sl, image.th); - GL11.glVertex2f (x, y+image.height); - GL11.glEnd (); + GL11.glBegin (GL11.GL_QUADS); + GL11.glTexCoord2f (image.sl, image.tl); + GL11.glVertex2f (x, y); + GL11.glTexCoord2f (image.sh, image.tl); + GL11.glVertex2f (x+image.width, y); + GL11.glTexCoord2f (image.sh, image.th); + GL11.glVertex2f (x+image.width, y+image.height); + GL11.glTexCoord2f (image.sl, image.th); + GL11.glVertex2f (x, y+image.height); + GL11.glEnd (); - if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha) - GL11.glEnable (GL11.GL_ALPHA_TEST); - } + if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha) + GL11.glEnable (GL11.GL_ALPHA_TEST); + } - /* - ============= - Draw_TileClear + /* + ============= + Draw_TileClear - This repeats a 64*64 tile graphic to fill the screen around a sized down - refresh window. - ============= - */ - protected void Draw_TileClear(int x, int y, int w, int h, String pic) { - image_t image; + This repeats a 64*64 tile graphic to fill the screen around a sized down + refresh window. + ============= + */ + protected void Draw_TileClear(int x, int y, int w, int h, String pic) { + image_t image; - image = Draw_FindPic(pic); - if (image == null) - { - VID.Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n'); - return; - } + image = Draw_FindPic(pic); + if (image == null) + { + VID.Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n'); + return; + } - if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha) - GL11.glDisable(GL11.GL_ALPHA_TEST); + if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha) + GL11.glDisable(GL11.GL_ALPHA_TEST); - GL_Bind(image.texnum); - GL11.glBegin (GL11.GL_QUADS); - GL11.glTexCoord2f(x/64.0f, y/64.0f); - GL11.glVertex2f (x, y); - GL11.glTexCoord2f( (x+w)/64.0f, y/64.0f); - GL11.glVertex2f(x+w, y); - GL11.glTexCoord2f( (x+w)/64.0f, (y+h)/64.0f); - GL11.glVertex2f(x+w, y+h); - GL11.glTexCoord2f( x/64.0f, (y+h)/64.0f ); - GL11.glVertex2f (x, y+h); - GL11.glEnd (); + GL_Bind(image.texnum); + GL11.glBegin (GL11.GL_QUADS); + GL11.glTexCoord2f(x/64.0f, y/64.0f); + GL11.glVertex2f (x, y); + GL11.glTexCoord2f( (x+w)/64.0f, y/64.0f); + GL11.glVertex2f(x+w, y); + GL11.glTexCoord2f( (x+w)/64.0f, (y+h)/64.0f); + GL11.glVertex2f(x+w, y+h); + GL11.glTexCoord2f( x/64.0f, (y+h)/64.0f ); + GL11.glVertex2f (x, y+h); + GL11.glEnd (); - if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha) - GL11.glEnable(GL11.GL_ALPHA_TEST); - } + if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) && !image.has_alpha) + GL11.glEnable(GL11.GL_ALPHA_TEST); + } - /* - ============= - Draw_Fill + /* + ============= + Draw_Fill - Fills a box of pixels with a single color - ============= - */ - protected void Draw_Fill(int x, int y, int w, int h, int colorIndex) { + Fills a box of pixels with a single color + ============= + */ + protected void Draw_Fill(int x, int y, int w, int h, int colorIndex) { - if ( colorIndex > 255) - Com.Error(Defines.ERR_FATAL, "Draw_Fill: bad color"); + if ( colorIndex > 255) + Com.Error(Defines.ERR_FATAL, "Draw_Fill: bad color"); - GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_TEXTURE_2D); - int color = d_8to24table[colorIndex]; + int color = d_8to24table[colorIndex]; - GL11.glColor3ub( - (byte)((color >> 0) & 0xff), // r - (byte)((color >> 8) & 0xff), // g - (byte)((color >> 16) & 0xff) // b - ); + GL11.glColor3ub( + (byte)((color >> 0) & 0xff), // r + (byte)((color >> 8) & 0xff), // g + (byte)((color >> 16) & 0xff) // b + ); - GL11.glBegin (GL11.GL_QUADS); + GL11.glBegin (GL11.GL_QUADS); - GL11.glVertex2f(x,y); - GL11.glVertex2f(x+w, y); - GL11.glVertex2f(x+w, y+h); - GL11.glVertex2f(x, y+h); + GL11.glVertex2f(x,y); + GL11.glVertex2f(x+w, y); + GL11.glVertex2f(x+w, y+h); + GL11.glVertex2f(x, y+h); - GL11.glEnd(); - GL11.glColor3f(1,1,1); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } + GL11.glEnd(); + GL11.glColor3f(1,1,1); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } - //============================================================================= + //============================================================================= - /* - ================ - Draw_FadeScreen - ================ - */ - protected void Draw_FadeScreen() { - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glColor4f(0, 0, 0, 0.8f); - GL11.glBegin(GL11.GL_QUADS); + /* + ================ + Draw_FadeScreen + ================ + */ + protected void Draw_FadeScreen() { + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glColor4f(0, 0, 0, 0.8f); + GL11.glBegin(GL11.GL_QUADS); - GL11.glVertex2f(0,0); - GL11.glVertex2f(vid.width, 0); - GL11.glVertex2f(vid.width, vid.height); - GL11.glVertex2f(0, vid.height); + GL11.glVertex2f(0,0); + GL11.glVertex2f(vid.width, 0); + GL11.glVertex2f(vid.width, vid.height); + GL11.glVertex2f(0, vid.height); - GL11.glEnd(); - GL11.glColor4f(1,1,1,1); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - } + GL11.glEnd(); + GL11.glColor4f(1,1,1,1); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + } // ==================================================================== @@ -302,107 +302,107 @@ public abstract class Draw extends Image { // share the buffer private IntBuffer image32 = image8.asIntBuffer(); - /* - ============= - Draw_StretchRaw - ============= - */ - protected void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte[] data) - { - int i, j, trows; - int sourceIndex; - int frac, fracstep; - float hscale; - int row; - float t; + /* + ============= + Draw_StretchRaw + ============= + */ + protected void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte[] data) + { + int i, j, trows; + int sourceIndex; + int frac, fracstep; + float hscale; + int row; + float t; - GL_Bind(0); + GL_Bind(0); - if (rows<=256) - { - hscale = 1; - trows = rows; - } - else - { - hscale = rows/256.0f; - trows = 256; - } - t = rows*hscale / 256; + if (rows<=256) + { + hscale = 1; + trows = rows; + } + else + { + hscale = rows/256.0f; + trows = 256; + } + t = rows*hscale / 256; - if ( !qglColorTableEXT ) - { - //int[] image32 = new int[256*256]; - image32.clear(); - int destIndex = 0; + if ( !qglColorTableEXT ) + { + //int[] image32 = new int[256*256]; + image32.clear(); + int destIndex = 0; - for (i=0 ; i rows) - break; - sourceIndex = cols*row; - destIndex = i*256; - fracstep = cols*0x10000/256; - frac = fracstep >> 1; - for (j=0 ; j<256 ; j++) - { - image32.put(destIndex + j, r_rawpalette[data[sourceIndex + (frac>>16)] & 0xff]); - frac += fracstep; - } - } - GL11.glTexImage2D (GL11.GL_TEXTURE_2D, 0, gl_tex_solid_format, 256, 256, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, image32); - } - else - { - //byte[] image8 = new byte[256*256]; - image8.clear(); - int destIndex = 0;; + for (i=0 ; i rows) + break; + sourceIndex = cols*row; + destIndex = i*256; + fracstep = cols*0x10000/256; + frac = fracstep >> 1; + for (j=0 ; j<256 ; j++) + { + image32.put(destIndex + j, r_rawpalette[data[sourceIndex + (frac>>16)] & 0xff]); + frac += fracstep; + } + } + GL11.glTexImage2D (GL11.GL_TEXTURE_2D, 0, gl_tex_solid_format, 256, 256, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, image32); + } + else + { + //byte[] image8 = new byte[256*256]; + image8.clear(); + int destIndex = 0;; - for (i=0 ; i rows) - break; - sourceIndex = cols*row; - destIndex = i*256; - fracstep = cols*0x10000/256; - frac = fracstep >> 1; - for (j=0 ; j<256 ; j++) - { - image8.put(destIndex + j, data[sourceIndex + (frac>>16)]); - frac += fracstep; - } - } + for (i=0 ; i rows) + break; + sourceIndex = cols*row; + destIndex = i*256; + fracstep = cols*0x10000/256; + frac = fracstep >> 1; + for (j=0 ; j<256 ; j++) + { + image8.put(destIndex + j, data[sourceIndex + (frac>>16)]); + frac += fracstep; + } + } - GL11.glTexImage2D( GL11.GL_TEXTURE_2D, - 0, - GL_COLOR_INDEX8_EXT, - 256, 256, - 0, - GL11.GL_COLOR_INDEX, - GL11.GL_UNSIGNED_BYTE, - image8 ); - } - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); + GL11.glTexImage2D( GL11.GL_TEXTURE_2D, + 0, + GL_COLOR_INDEX8_EXT, + 256, 256, + 0, + GL11.GL_COLOR_INDEX, + GL11.GL_UNSIGNED_BYTE, + image8 ); + } + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); - if ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) - GL11.glDisable (GL11.GL_ALPHA_TEST); + if ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) + GL11.glDisable (GL11.GL_ALPHA_TEST); - GL11.glBegin (GL11.GL_QUADS); - GL11.glTexCoord2f (0, 0); - GL11.glVertex2f (x, y); - GL11.glTexCoord2f (1, 0); - GL11.glVertex2f (x+w, y); - GL11.glTexCoord2f (1, t); - GL11.glVertex2f (x+w, y+h); - GL11.glTexCoord2f (0, t); - GL11.glVertex2f (x, y+h); - GL11.glEnd (); + GL11.glBegin (GL11.GL_QUADS); + GL11.glTexCoord2f (0, 0); + GL11.glVertex2f (x, y); + GL11.glTexCoord2f (1, 0); + GL11.glVertex2f (x+w, y); + GL11.glTexCoord2f (1, t); + GL11.glVertex2f (x+w, y+h); + GL11.glTexCoord2f (0, t); + GL11.glVertex2f (x, y+h); + GL11.glEnd (); - if ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) - GL11.glEnable (GL11.GL_ALPHA_TEST); - } + if ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( (gl_config.renderer & GL_RENDERER_RENDITION) != 0 ) ) + GL11.glEnable (GL11.GL_ALPHA_TEST); + } } diff --git a/src/main/java/lwjake2/render/lwjgl/Image.java b/src/main/java/lwjake2/render/lwjgl/Image.java index 7d466c5..3b2f83d 100644 --- a/src/main/java/lwjake2/render/lwjgl/Image.java +++ b/src/main/java/lwjake2/render/lwjgl/Image.java @@ -48,726 +48,726 @@ import org.lwjgl.opengl.GL11; * @author cwei */ public abstract class Image extends Main { - private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); - - image_t draw_chars; - - image_t[] gltextures = new image_t[MAX_GLTEXTURES]; - //Map gltextures = new Hashtable(MAX_GLTEXTURES); // image_t - int numgltextures; - - byte[] intensitytable = new byte[256]; - byte[] gammatable = new byte[256]; - - cvar_t intensity; - - // - // qboolean GL_Upload8 (byte *data, int width, int height, qboolean mipmap, qboolean is_sky ); - // qboolean GL_Upload32 (unsigned *data, int width, int height, qboolean mipmap); - // - - int gl_solid_format = 3; - int gl_alpha_format = 4; - - int gl_tex_solid_format = 3; - int gl_tex_alpha_format = 4; - - int gl_filter_min = GL11.GL_LINEAR_MIPMAP_NEAREST; - int gl_filter_max = GL11.GL_LINEAR; - - Image() { - // init the texture cache - for (int i = 0; i < gltextures.length; i++) - { - gltextures[i] = new image_t(i); - } - numgltextures = 0; - } - - void GL_SetTexturePalette(int[] palette) { - - assert(palette != null && palette.length == 256) : "int palette[256] bug"; - - int i; - //byte[] temptable = new byte[768]; - - if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f) - { - ByteBuffer temptable=BufferUtils.createByteBuffer(768); - for (i = 0; i < 256; i++) { - temptable.put(i * 3, (byte) ((palette[i]) & 0xff)); - temptable.put(i * 3 + 1, (byte) ((palette[i] >> 8) & 0xff)); - temptable.put(i * 3 + 2, (byte) ((palette[i] >> 16) & 0xff)); - } - - ARBImaging.glColorTable(EXTSharedTexturePalette.GL_SHARED_TEXTURE_PALETTE_EXT, GL11.GL_RGB, 256, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, temptable); - } - } - - void GL_EnableMultitexture(boolean enable) { - if (enable) { - GL_SelectTexture(GL_TEXTURE1); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL_TexEnv(GL11.GL_REPLACE); - } - else { - GL_SelectTexture(GL_TEXTURE1); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL_TexEnv(GL11.GL_REPLACE); - } - GL_SelectTexture(GL_TEXTURE0); - GL_TexEnv(GL11.GL_REPLACE); - } - - void GL_SelectTexture(int texture /* GLenum */) { - int tmu; - - tmu = (texture == GL_TEXTURE0) ? 0 : 1; - - if (tmu == gl_state.currenttmu) { - return; - } - - gl_state.currenttmu = tmu; - - ARBMultitexture.glActiveTextureARB(texture); - ARBMultitexture.glClientActiveTextureARB(texture); - } - - int[] lastmodes = { -1, -1 }; - - void GL_TexEnv(int mode /* GLenum */ - ) { - - if (mode != lastmodes[gl_state.currenttmu]) { - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, mode); - lastmodes[gl_state.currenttmu] = mode; - } - } - - void GL_Bind(int texnum) { - - if ((gl_nobind.value != 0) && (draw_chars != null)) { - // performance evaluation option - texnum = draw_chars.texnum; - } - if (gl_state.currenttextures[gl_state.currenttmu] == texnum) - return; - - gl_state.currenttextures[gl_state.currenttmu] = texnum; - GL11.glBindTexture(GL11.GL_TEXTURE_2D, texnum); - } - - void GL_MBind(int target /* GLenum */, int texnum) { - GL_SelectTexture(target); - if (target == GL_TEXTURE0) { - if (gl_state.currenttextures[0] == texnum) - return; - } - else { - if (gl_state.currenttextures[1] == texnum) - return; - } - GL_Bind(texnum); - } - - // glmode_t - static class glmode_t { - String name; - int minimize, maximize; - - glmode_t(String name, int minimize, int maximze) { - this.name = name; - this.minimize = minimize; - this.maximize = maximze; - } - } - - static final glmode_t modes[] = - { - new glmode_t("GL_NEAREST", GL11.GL_NEAREST, GL11.GL_NEAREST), - new glmode_t("GL_LINEAR", GL11.GL_LINEAR, GL11.GL_LINEAR), - new glmode_t("GL_NEAREST_MIPMAP_NEAREST", GL11.GL_NEAREST_MIPMAP_NEAREST, GL11.GL_NEAREST), - new glmode_t("GL_LINEAR_MIPMAP_NEAREST", GL11.GL_LINEAR_MIPMAP_NEAREST, GL11.GL_LINEAR), - new glmode_t("GL_NEAREST_MIPMAP_LINEAR", GL11.GL_NEAREST_MIPMAP_LINEAR, GL11.GL_NEAREST), - new glmode_t("GL_LINEAR_MIPMAP_LINEAR", GL11.GL_LINEAR_MIPMAP_LINEAR, GL11.GL_LINEAR)}; - - static final int NUM_GL_MODES = modes.length; - - // gltmode_t - static class gltmode_t { - String name; - int mode; - - gltmode_t(String name, int mode) { - this.name = name; - this.mode = mode; - } - } - - static final gltmode_t[] gl_alpha_modes = - { - new gltmode_t("default", 4), - new gltmode_t("GL_RGBA", GL11.GL_RGBA), - new gltmode_t("GL_RGBA8", GL11.GL_RGBA8), - new gltmode_t("GL_RGB5_A1", GL11.GL_RGB5_A1), - new gltmode_t("GL_RGBA4", GL11.GL_RGBA4), - new gltmode_t("GL_RGBA2", GL11.GL_RGBA2), - }; - - static final int NUM_GL_ALPHA_MODES = gl_alpha_modes.length; - - static final gltmode_t[] gl_solid_modes = - { - new gltmode_t("default", 3), - new gltmode_t("GL_RGB", GL11.GL_RGB), - new gltmode_t("GL_RGB8", GL11.GL_RGB8), - new gltmode_t("GL_RGB5", GL11.GL_RGB5), - new gltmode_t("GL_RGB4", GL11.GL_RGB4), - new gltmode_t("GL_R3_G3_B2", GL11.GL_R3_G3_B2), - // #ifdef GL_RGB2_EXT - //new gltmode_t("GL_RGB2", GL.GL_RGB2_EXT) - // #endif - }; - - static final int NUM_GL_SOLID_MODES = gl_solid_modes.length; - - /* - =============== - GL_TextureMode - =============== - */ - void GL_TextureMode(String string) { - - int i; - for (i = 0; i < NUM_GL_MODES; i++) { - if (modes[i].name.equalsIgnoreCase(string)) - break; - } - - if (i == NUM_GL_MODES) { - VID.Printf(Defines.PRINT_ALL, "bad filter name: [" + string + "]\n"); - return; - } - - gl_filter_min = modes[i].minimize; - gl_filter_max = modes[i].maximize; - - image_t glt; - // change all the existing mipmap texture objects - for (i = 0; i < numgltextures; i++) { - glt = gltextures[i]; - - if (glt.type != it_pic && glt.type != it_sky) { - GL_Bind(glt.texnum); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); - } - } - } - - /* - =============== - GL_TextureAlphaMode - =============== - */ - void GL_TextureAlphaMode(String string) { - - int i; - for (i = 0; i < NUM_GL_ALPHA_MODES; i++) { - if (gl_alpha_modes[i].name.equalsIgnoreCase(string)) - break; - } - - if (i == NUM_GL_ALPHA_MODES) { - VID.Printf(Defines.PRINT_ALL, "bad alpha texture mode name: [" + string + "]\n"); - return; - } - - gl_tex_alpha_format = gl_alpha_modes[i].mode; - } - - /* - =============== - GL_TextureSolidMode - =============== - */ - void GL_TextureSolidMode(String string) { - int i; - for (i = 0; i < NUM_GL_SOLID_MODES; i++) { - if (gl_solid_modes[i].name.equalsIgnoreCase(string)) - break; - } - - if (i == NUM_GL_SOLID_MODES) { - VID.Printf(Defines.PRINT_ALL, "bad solid texture mode name: [" + string + "]\n"); - return; - } - - gl_tex_solid_format = gl_solid_modes[i].mode; - } - - /* - =============== - GL_ImageList_f - =============== - */ - void GL_ImageList_f() { - - image_t image; - int texels; - final String[] palstrings = { "RGB", "PAL" }; - - VID.Printf(Defines.PRINT_ALL, "------------------\n"); - texels = 0; - - for (int i = 0; i < numgltextures; i++) { - image = gltextures[i]; - if (image.texnum <= 0) - continue; - - texels += image.upload_width * image.upload_height; - switch (image.type) { - case it_skin : - VID.Printf(Defines.PRINT_ALL, "M"); - break; - case it_sprite : - VID.Printf(Defines.PRINT_ALL, "S"); - break; - case it_wall : - VID.Printf(Defines.PRINT_ALL, "W"); - break; - case it_pic : - VID.Printf(Defines.PRINT_ALL, "P"); - break; - default : - VID.Printf(Defines.PRINT_ALL, " "); - break; - } - - VID.Printf( - Defines.PRINT_ALL, - " %3i %3i %s: %s\n", - new Vargs(4).add(image.upload_width).add(image.upload_height).add(palstrings[(image.paletted) ? 1 : 0]).add( - image.name)); - } - VID.Printf(Defines.PRINT_ALL, "Total texel count (not counting mipmaps): " + texels + '\n'); - } - - /* - ============================================================================= - - scrap allocation - - Allocate all the little status bar objects into a single texture - to crutch up inefficient hardware / drivers - - ============================================================================= - */ - - static final int MAX_SCRAPS = 1; - static final int BLOCK_WIDTH = 256; - static final int BLOCK_HEIGHT = 256; - - int[][] scrap_allocated = new int[MAX_SCRAPS][BLOCK_WIDTH]; - byte[][] scrap_texels = new byte[MAX_SCRAPS][BLOCK_WIDTH * BLOCK_HEIGHT]; - boolean scrap_dirty; - - static class pos_t { - int x, y; - - pos_t(int x, int y) { - this.x = x; - this.y = y; - } - } - - // returns a texture number and the position inside it - int Scrap_AllocBlock(int w, int h, pos_t pos) { - int i, j; - int best, best2; - int texnum; - - for (texnum = 0; texnum < MAX_SCRAPS; texnum++) { - best = BLOCK_HEIGHT; - - for (i = 0; i < BLOCK_WIDTH - w; i++) { - best2 = 0; - - for (j = 0; j < w; j++) { - if (scrap_allocated[texnum][i + j] >= best) - break; - if (scrap_allocated[texnum][i + j] > best2) - best2 = scrap_allocated[texnum][i + j]; - } - if (j == w) { // this is a valid spot - pos.x = i; - pos.y = best = best2; - } - } - - if (best + h > BLOCK_HEIGHT) - continue; - - for (i = 0; i < w; i++) - scrap_allocated[texnum][pos.x + i] = best + h; - - return texnum; - } - - return -1; - // Sys_Error ("Scrap_AllocBlock: full"); - } - - int scrap_uploads = 0; - - void Scrap_Upload() { - scrap_uploads++; - GL_Bind(TEXNUM_SCRAPS); - GL_Upload8(scrap_texels[0], BLOCK_WIDTH, BLOCK_HEIGHT, false, false); - scrap_dirty = false; - } - - /* - ================================================================= - - PCX LOADING - - ================================================================= - */ - - /* - ============== - LoadPCX - ============== - */ - byte[] LoadPCX(String filename, byte[][] palette, Dimension dim) { - qfiles.pcx_t pcx; - - // - // load the file - // - byte[] raw = fileSystem.loadFile(filename); - - if (raw == null) { - VID.Printf(Defines.PRINT_DEVELOPER, "Bad pcx file " + filename + '\n'); - return null; - } - - // - // parse the PCX file - // - pcx = new qfiles.pcx_t(raw); - - if (pcx.manufacturer != 0x0a - || pcx.version != 5 - || pcx.encoding != 1 - || pcx.bits_per_pixel != 8 - || pcx.xmax >= 640 - || pcx.ymax >= 480) { - - VID.Printf(Defines.PRINT_ALL, "Bad pcx file " + filename + '\n'); - return null; - } - - int width = pcx.xmax - pcx.xmin + 1; - int height = pcx.ymax - pcx.ymin + 1; - - byte[] pix = new byte[width * height]; - - if (palette != null) { - palette[0] = new byte[768]; - System.arraycopy(raw, raw.length - 768, palette[0], 0, 768); - } - - if (dim != null) { - dim.width = width; - dim.height = height; - } - - // - // decode pcx - // - int count = 0; - byte dataByte; - int runLength; - int x, y; - - for (y = 0; y < height; y++) { - for (x = 0; x < width;) { - - dataByte = pcx.data.get(); - - if ((dataByte & 0xC0) == 0xC0) { - runLength = dataByte & 0x3F; - dataByte = pcx.data.get(); - // write runLength pixel - while (runLength-- > 0) { - pix[count++] = dataByte; - x++; - } - } - else { - // write one pixel - pix[count++] = dataByte; - x++; - } - } - } - return pix; - } - - private Throwable gotoBreakOut = new Throwable(); - private Throwable gotoDone = gotoBreakOut; - - // /* - // ========================================================= - // - // TARGA LOADING - // - // ========================================================= - // */ - /* - ============= - LoadTGA - ============= - */ - byte[] LoadTGA(String name, Dimension dim) { - int columns, rows, numPixels; - int pixbuf; // index into pic - int row, column; - byte[] raw; - ByteBuffer buf_p; - qfiles.tga_t targa_header; - byte[] pic; - - // - // load the file - // - raw = fileSystem.loadFile(name); - - if (raw == null) - { - VID.Printf(Defines.PRINT_DEVELOPER, "Bad tga file "+ name +'\n'); - return null; - } - - targa_header = new qfiles.tga_t(raw); - - if (targa_header.image_type != 2 && targa_header.image_type != 10) - Com.Error(Defines.ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n"); - - if (targa_header.colormap_type != 0 || (targa_header.pixel_size != 32 && targa_header.pixel_size != 24)) - Com.Error (Defines.ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n"); - - columns = targa_header.width; - rows = targa_header.height; - numPixels = columns * rows; - - if (dim != null) { - dim.width = columns; - dim.height = rows; - } - - pic = new byte[numPixels * 4]; // targa_rgba; - - if (targa_header.id_length != 0) - targa_header.data.position(targa_header.id_length); // skip TARGA image comment - - buf_p = targa_header.data; - - byte red,green,blue,alphabyte; - red = green = blue = alphabyte = 0; - int packetHeader, packetSize, j; - - if (targa_header.image_type==2) { // Uncompressed, RGB images - for(row=rows-1; row>=0; row--) { - - pixbuf = row * columns * 4; - - for(column=0; column=0; row--) { - - pixbuf = row * columns * 4; - try { - - for(column=0; column0) - row--; - else - // goto label breakOut; - throw gotoBreakOut; - - pixbuf = row * columns * 4; - } - } - } - else { // non run-length packet - for(j=0;j0) - row--; - else - // goto label breakOut; - throw gotoBreakOut; - - pixbuf = row * columns * 4; - } - } - } - } - } catch (Throwable e){ - // label breakOut: - } - } - } - return pic; - } - - /* - ==================================================================== - - IMAGE FLOOD FILLING - - ==================================================================== - */ - - /* - ================= - Mod_FloodFillSkin - - Fill background pixels so mipmapping doesn't have haloes - ================= - */ - - static class floodfill_t { - short x, y; - } - - // must be a power of 2 - static final int FLOODFILL_FIFO_SIZE = 0x1000; - static final int FLOODFILL_FIFO_MASK = FLOODFILL_FIFO_SIZE - 1; - // - // #define FLOODFILL_STEP( off, dx, dy ) \ - // { \ - // if (pos[off] == fillcolor) \ - // { \ - // pos[off] = 255; \ - // fifo[inpt].x = x + (dx), fifo[inpt].y = y + (dy); \ - // inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; \ - // } \ - // else if (pos[off] != 255) fdc = pos[off]; \ - // } - - // void FLOODFILL_STEP( int off, int dx, int dy ) - // { - // if (pos[off] == fillcolor) - // { - // pos[off] = 255; - // fifo[inpt].x = x + dx; fifo[inpt].y = y + dy; - // inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; - // } - // else if (pos[off] != 255) fdc = pos[off]; - // } - static floodfill_t[] fifo = new floodfill_t[FLOODFILL_FIFO_SIZE]; - static { - for (int j = 0; j < fifo.length; j++) { - fifo[j] = new floodfill_t(); - } - } - // TODO check this: R_FloodFillSkin( byte[] skin, int skinwidth, int skinheight) - void R_FloodFillSkin(byte[] skin, int skinwidth, int skinheight) { - // byte fillcolor = *skin; // assume this is the pixel to fill - int fillcolor = skin[0] & 0xff; -// floodfill_t[] fifo = new floodfill_t[FLOODFILL_FIFO_SIZE]; - int inpt = 0, outpt = 0; - int filledcolor; - int i; - -// for (int j = 0; j < fifo.length; j++) { -// fifo[j] = new floodfill_t(); -// } - - filledcolor = 0; - // attempt to find opaque black - for (i = 0; i < 256; ++i) + private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); + + image_t draw_chars; + + image_t[] gltextures = new image_t[MAX_GLTEXTURES]; + //Map gltextures = new Hashtable(MAX_GLTEXTURES); // image_t + int numgltextures; + + byte[] intensitytable = new byte[256]; + byte[] gammatable = new byte[256]; + + cvar_t intensity; + + // + // qboolean GL_Upload8 (byte *data, int width, int height, qboolean mipmap, qboolean is_sky ); + // qboolean GL_Upload32 (unsigned *data, int width, int height, qboolean mipmap); + // + + int gl_solid_format = 3; + int gl_alpha_format = 4; + + int gl_tex_solid_format = 3; + int gl_tex_alpha_format = 4; + + int gl_filter_min = GL11.GL_LINEAR_MIPMAP_NEAREST; + int gl_filter_max = GL11.GL_LINEAR; + + Image() { + // init the texture cache + for (int i = 0; i < gltextures.length; i++) + { + gltextures[i] = new image_t(i); + } + numgltextures = 0; + } + + void GL_SetTexturePalette(int[] palette) { + + assert(palette != null && palette.length == 256) : "int palette[256] bug"; + + int i; + //byte[] temptable = new byte[768]; + + if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f) + { + ByteBuffer temptable=BufferUtils.createByteBuffer(768); + for (i = 0; i < 256; i++) { + temptable.put(i * 3, (byte) ((palette[i]) & 0xff)); + temptable.put(i * 3 + 1, (byte) ((palette[i] >> 8) & 0xff)); + temptable.put(i * 3 + 2, (byte) ((palette[i] >> 16) & 0xff)); + } + + ARBImaging.glColorTable(EXTSharedTexturePalette.GL_SHARED_TEXTURE_PALETTE_EXT, GL11.GL_RGB, 256, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, temptable); + } + } + + void GL_EnableMultitexture(boolean enable) { + if (enable) { + GL_SelectTexture(GL_TEXTURE1); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL_TexEnv(GL11.GL_REPLACE); + } + else { + GL_SelectTexture(GL_TEXTURE1); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL_TexEnv(GL11.GL_REPLACE); + } + GL_SelectTexture(GL_TEXTURE0); + GL_TexEnv(GL11.GL_REPLACE); + } + + void GL_SelectTexture(int texture /* GLenum */) { + int tmu; + + tmu = (texture == GL_TEXTURE0) ? 0 : 1; + + if (tmu == gl_state.currenttmu) { + return; + } + + gl_state.currenttmu = tmu; + + ARBMultitexture.glActiveTextureARB(texture); + ARBMultitexture.glClientActiveTextureARB(texture); + } + + int[] lastmodes = { -1, -1 }; + + void GL_TexEnv(int mode /* GLenum */ + ) { + + if (mode != lastmodes[gl_state.currenttmu]) { + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, mode); + lastmodes[gl_state.currenttmu] = mode; + } + } + + void GL_Bind(int texnum) { + + if ((gl_nobind.value != 0) && (draw_chars != null)) { + // performance evaluation option + texnum = draw_chars.texnum; + } + if (gl_state.currenttextures[gl_state.currenttmu] == texnum) + return; + + gl_state.currenttextures[gl_state.currenttmu] = texnum; + GL11.glBindTexture(GL11.GL_TEXTURE_2D, texnum); + } + + void GL_MBind(int target /* GLenum */, int texnum) { + GL_SelectTexture(target); + if (target == GL_TEXTURE0) { + if (gl_state.currenttextures[0] == texnum) + return; + } + else { + if (gl_state.currenttextures[1] == texnum) + return; + } + GL_Bind(texnum); + } + + // glmode_t + static class glmode_t { + String name; + int minimize, maximize; + + glmode_t(String name, int minimize, int maximze) { + this.name = name; + this.minimize = minimize; + this.maximize = maximze; + } + } + + static final glmode_t modes[] = + { + new glmode_t("GL_NEAREST", GL11.GL_NEAREST, GL11.GL_NEAREST), + new glmode_t("GL_LINEAR", GL11.GL_LINEAR, GL11.GL_LINEAR), + new glmode_t("GL_NEAREST_MIPMAP_NEAREST", GL11.GL_NEAREST_MIPMAP_NEAREST, GL11.GL_NEAREST), + new glmode_t("GL_LINEAR_MIPMAP_NEAREST", GL11.GL_LINEAR_MIPMAP_NEAREST, GL11.GL_LINEAR), + new glmode_t("GL_NEAREST_MIPMAP_LINEAR", GL11.GL_NEAREST_MIPMAP_LINEAR, GL11.GL_NEAREST), + new glmode_t("GL_LINEAR_MIPMAP_LINEAR", GL11.GL_LINEAR_MIPMAP_LINEAR, GL11.GL_LINEAR)}; + + static final int NUM_GL_MODES = modes.length; + + // gltmode_t + static class gltmode_t { + String name; + int mode; + + gltmode_t(String name, int mode) { + this.name = name; + this.mode = mode; + } + } + + static final gltmode_t[] gl_alpha_modes = + { + new gltmode_t("default", 4), + new gltmode_t("GL_RGBA", GL11.GL_RGBA), + new gltmode_t("GL_RGBA8", GL11.GL_RGBA8), + new gltmode_t("GL_RGB5_A1", GL11.GL_RGB5_A1), + new gltmode_t("GL_RGBA4", GL11.GL_RGBA4), + new gltmode_t("GL_RGBA2", GL11.GL_RGBA2), + }; + + static final int NUM_GL_ALPHA_MODES = gl_alpha_modes.length; + + static final gltmode_t[] gl_solid_modes = + { + new gltmode_t("default", 3), + new gltmode_t("GL_RGB", GL11.GL_RGB), + new gltmode_t("GL_RGB8", GL11.GL_RGB8), + new gltmode_t("GL_RGB5", GL11.GL_RGB5), + new gltmode_t("GL_RGB4", GL11.GL_RGB4), + new gltmode_t("GL_R3_G3_B2", GL11.GL_R3_G3_B2), + // #ifdef GL_RGB2_EXT + //new gltmode_t("GL_RGB2", GL.GL_RGB2_EXT) + // #endif + }; + + static final int NUM_GL_SOLID_MODES = gl_solid_modes.length; + + /* + =============== + GL_TextureMode + =============== + */ + void GL_TextureMode(String string) { + + int i; + for (i = 0; i < NUM_GL_MODES; i++) { + if (modes[i].name.equalsIgnoreCase(string)) + break; + } + + if (i == NUM_GL_MODES) { + VID.Printf(Defines.PRINT_ALL, "bad filter name: [" + string + "]\n"); + return; + } + + gl_filter_min = modes[i].minimize; + gl_filter_max = modes[i].maximize; + + image_t glt; + // change all the existing mipmap texture objects + for (i = 0; i < numgltextures; i++) { + glt = gltextures[i]; + + if (glt.type != it_pic && glt.type != it_sky) { + GL_Bind(glt.texnum); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); + } + } + } + + /* + =============== + GL_TextureAlphaMode + =============== + */ + void GL_TextureAlphaMode(String string) { + + int i; + for (i = 0; i < NUM_GL_ALPHA_MODES; i++) { + if (gl_alpha_modes[i].name.equalsIgnoreCase(string)) + break; + } + + if (i == NUM_GL_ALPHA_MODES) { + VID.Printf(Defines.PRINT_ALL, "bad alpha texture mode name: [" + string + "]\n"); + return; + } + + gl_tex_alpha_format = gl_alpha_modes[i].mode; + } + + /* + =============== + GL_TextureSolidMode + =============== + */ + void GL_TextureSolidMode(String string) { + int i; + for (i = 0; i < NUM_GL_SOLID_MODES; i++) { + if (gl_solid_modes[i].name.equalsIgnoreCase(string)) + break; + } + + if (i == NUM_GL_SOLID_MODES) { + VID.Printf(Defines.PRINT_ALL, "bad solid texture mode name: [" + string + "]\n"); + return; + } + + gl_tex_solid_format = gl_solid_modes[i].mode; + } + + /* + =============== + GL_ImageList_f + =============== + */ + void GL_ImageList_f() { + + image_t image; + int texels; + final String[] palstrings = { "RGB", "PAL" }; + + VID.Printf(Defines.PRINT_ALL, "------------------\n"); + texels = 0; + + for (int i = 0; i < numgltextures; i++) { + image = gltextures[i]; + if (image.texnum <= 0) + continue; + + texels += image.upload_width * image.upload_height; + switch (image.type) { + case it_skin : + VID.Printf(Defines.PRINT_ALL, "M"); + break; + case it_sprite : + VID.Printf(Defines.PRINT_ALL, "S"); + break; + case it_wall : + VID.Printf(Defines.PRINT_ALL, "W"); + break; + case it_pic : + VID.Printf(Defines.PRINT_ALL, "P"); + break; + default : + VID.Printf(Defines.PRINT_ALL, " "); + break; + } + + VID.Printf( + Defines.PRINT_ALL, + " %3i %3i %s: %s\n", + new Vargs(4).add(image.upload_width).add(image.upload_height).add(palstrings[(image.paletted) ? 1 : 0]).add( + image.name)); + } + VID.Printf(Defines.PRINT_ALL, "Total texel count (not counting mipmaps): " + texels + '\n'); + } + + /* + ============================================================================= + + scrap allocation + + Allocate all the little status bar objects into a single texture + to crutch up inefficient hardware / drivers + + ============================================================================= + */ + + static final int MAX_SCRAPS = 1; + static final int BLOCK_WIDTH = 256; + static final int BLOCK_HEIGHT = 256; + + int[][] scrap_allocated = new int[MAX_SCRAPS][BLOCK_WIDTH]; + byte[][] scrap_texels = new byte[MAX_SCRAPS][BLOCK_WIDTH * BLOCK_HEIGHT]; + boolean scrap_dirty; + + static class pos_t { + int x, y; + + pos_t(int x, int y) { + this.x = x; + this.y = y; + } + } + + // returns a texture number and the position inside it + int Scrap_AllocBlock(int w, int h, pos_t pos) { + int i, j; + int best, best2; + int texnum; + + for (texnum = 0; texnum < MAX_SCRAPS; texnum++) { + best = BLOCK_HEIGHT; + + for (i = 0; i < BLOCK_WIDTH - w; i++) { + best2 = 0; + + for (j = 0; j < w; j++) { + if (scrap_allocated[texnum][i + j] >= best) + break; + if (scrap_allocated[texnum][i + j] > best2) + best2 = scrap_allocated[texnum][i + j]; + } + if (j == w) { // this is a valid spot + pos.x = i; + pos.y = best = best2; + } + } + + if (best + h > BLOCK_HEIGHT) + continue; + + for (i = 0; i < w; i++) + scrap_allocated[texnum][pos.x + i] = best + h; + + return texnum; + } + + return -1; + // Sys_Error ("Scrap_AllocBlock: full"); + } + + int scrap_uploads = 0; + + void Scrap_Upload() { + scrap_uploads++; + GL_Bind(TEXNUM_SCRAPS); + GL_Upload8(scrap_texels[0], BLOCK_WIDTH, BLOCK_HEIGHT, false, false); + scrap_dirty = false; + } + + /* + ================================================================= + + PCX LOADING + + ================================================================= + */ + + /* + ============== + LoadPCX + ============== + */ + byte[] LoadPCX(String filename, byte[][] palette, Dimension dim) { + qfiles.pcx_t pcx; + + // + // load the file + // + byte[] raw = fileSystem.loadFile(filename); + + if (raw == null) { + VID.Printf(Defines.PRINT_DEVELOPER, "Bad pcx file " + filename + '\n'); + return null; + } + + // + // parse the PCX file + // + pcx = new qfiles.pcx_t(raw); + + if (pcx.manufacturer != 0x0a + || pcx.version != 5 + || pcx.encoding != 1 + || pcx.bits_per_pixel != 8 + || pcx.xmax >= 640 + || pcx.ymax >= 480) { + + VID.Printf(Defines.PRINT_ALL, "Bad pcx file " + filename + '\n'); + return null; + } + + int width = pcx.xmax - pcx.xmin + 1; + int height = pcx.ymax - pcx.ymin + 1; + + byte[] pix = new byte[width * height]; + + if (palette != null) { + palette[0] = new byte[768]; + System.arraycopy(raw, raw.length - 768, palette[0], 0, 768); + } + + if (dim != null) { + dim.width = width; + dim.height = height; + } + + // + // decode pcx + // + int count = 0; + byte dataByte; + int runLength; + int x, y; + + for (y = 0; y < height; y++) { + for (x = 0; x < width;) { + + dataByte = pcx.data.get(); + + if ((dataByte & 0xC0) == 0xC0) { + runLength = dataByte & 0x3F; + dataByte = pcx.data.get(); + // write runLength pixel + while (runLength-- > 0) { + pix[count++] = dataByte; + x++; + } + } + else { + // write one pixel + pix[count++] = dataByte; + x++; + } + } + } + return pix; + } + + private Throwable gotoBreakOut = new Throwable(); + private Throwable gotoDone = gotoBreakOut; + + // /* + // ========================================================= + // + // TARGA LOADING + // + // ========================================================= + // */ + /* + ============= + LoadTGA + ============= + */ + byte[] LoadTGA(String name, Dimension dim) { + int columns, rows, numPixels; + int pixbuf; // index into pic + int row, column; + byte[] raw; + ByteBuffer buf_p; + qfiles.tga_t targa_header; + byte[] pic; + + // + // load the file + // + raw = fileSystem.loadFile(name); + + if (raw == null) + { + VID.Printf(Defines.PRINT_DEVELOPER, "Bad tga file "+ name +'\n'); + return null; + } + + targa_header = new qfiles.tga_t(raw); + + if (targa_header.image_type != 2 && targa_header.image_type != 10) + Com.Error(Defines.ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n"); + + if (targa_header.colormap_type != 0 || (targa_header.pixel_size != 32 && targa_header.pixel_size != 24)) + Com.Error (Defines.ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n"); + + columns = targa_header.width; + rows = targa_header.height; + numPixels = columns * rows; + + if (dim != null) { + dim.width = columns; + dim.height = rows; + } + + pic = new byte[numPixels * 4]; // targa_rgba; + + if (targa_header.id_length != 0) + targa_header.data.position(targa_header.id_length); // skip TARGA image comment + + buf_p = targa_header.data; + + byte red,green,blue,alphabyte; + red = green = blue = alphabyte = 0; + int packetHeader, packetSize, j; + + if (targa_header.image_type==2) { // Uncompressed, RGB images + for(row=rows-1; row>=0; row--) { + + pixbuf = row * columns * 4; + + for(column=0; column=0; row--) { + + pixbuf = row * columns * 4; + try { + + for(column=0; column0) + row--; + else + // goto label breakOut; + throw gotoBreakOut; + + pixbuf = row * columns * 4; + } + } + } + else { // non run-length packet + for(j=0;j0) + row--; + else + // goto label breakOut; + throw gotoBreakOut; + + pixbuf = row * columns * 4; + } + } + } + } + } catch (Throwable e){ + // label breakOut: + } + } + } + return pic; + } + + /* + ==================================================================== + + IMAGE FLOOD FILLING + + ==================================================================== + */ + + /* + ================= + Mod_FloodFillSkin + + Fill background pixels so mipmapping doesn't have haloes + ================= + */ + + static class floodfill_t { + short x, y; + } + + // must be a power of 2 + static final int FLOODFILL_FIFO_SIZE = 0x1000; + static final int FLOODFILL_FIFO_MASK = FLOODFILL_FIFO_SIZE - 1; + // + // #define FLOODFILL_STEP( off, dx, dy ) \ + // { \ + // if (pos[off] == fillcolor) \ + // { \ + // pos[off] = 255; \ + // fifo[inpt].x = x + (dx), fifo[inpt].y = y + (dy); \ + // inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; \ + // } \ + // else if (pos[off] != 255) fdc = pos[off]; \ + // } + + // void FLOODFILL_STEP( int off, int dx, int dy ) + // { + // if (pos[off] == fillcolor) + // { + // pos[off] = 255; + // fifo[inpt].x = x + dx; fifo[inpt].y = y + dy; + // inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; + // } + // else if (pos[off] != 255) fdc = pos[off]; + // } + static floodfill_t[] fifo = new floodfill_t[FLOODFILL_FIFO_SIZE]; + static { + for (int j = 0; j < fifo.length; j++) { + fifo[j] = new floodfill_t(); + } + } + // TODO check this: R_FloodFillSkin( byte[] skin, int skinwidth, int skinheight) + void R_FloodFillSkin(byte[] skin, int skinwidth, int skinheight) { + // byte fillcolor = *skin; // assume this is the pixel to fill + int fillcolor = skin[0] & 0xff; +// floodfill_t[] fifo = new floodfill_t[FLOODFILL_FIFO_SIZE]; + int inpt = 0, outpt = 0; + int filledcolor; + int i; + +// for (int j = 0; j < fifo.length; j++) { +// fifo[j] = new floodfill_t(); +// } + + filledcolor = 0; + // attempt to find opaque black + for (i = 0; i < 256; ++i) // TODO check this if (d_8to24table[i] == 0xFF000000) { // alpha 1.0 //if (d_8to24table[i] == (255 << 0)) // alpha 1.0 @@ -775,896 +775,896 @@ public abstract class Image extends Main { break; } - // can't fill to filled color or to transparent color (used as visited marker) - if ((fillcolor == filledcolor) || (fillcolor == 255)) { - return; - } - - fifo[inpt].x = 0; - fifo[inpt].y = 0; - inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; - - while (outpt != inpt) { - int x = fifo[outpt].x; - int y = fifo[outpt].y; - int fdc = filledcolor; - // byte *pos = &skin[x + skinwidth * y]; - int pos = x + skinwidth * y; - // - outpt = (outpt + 1) & FLOODFILL_FIFO_MASK; - - int off, dx, dy; - - if (x > 0) { - // FLOODFILL_STEP( -1, -1, 0 ); - off = -1; - dx = -1; - dy = 0; - if (skin[pos + off] == (byte) fillcolor) { - skin[pos + off] = (byte) 255; - fifo[inpt].x = (short) (x + dx); - fifo[inpt].y = (short) (y + dy); - inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; - } - else if (skin[pos + off] != (byte) 255) - fdc = skin[pos + off] & 0xff; - } - - if (x < skinwidth - 1) { - // FLOODFILL_STEP( 1, 1, 0 ); - off = 1; - dx = 1; - dy = 0; - if (skin[pos + off] == (byte) fillcolor) { - skin[pos + off] = (byte) 255; - fifo[inpt].x = (short) (x + dx); - fifo[inpt].y = (short) (y + dy); - inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; - } - else if (skin[pos + off] != (byte) 255) - fdc = skin[pos + off] & 0xff; - } - - if (y > 0) { - // FLOODFILL_STEP( -skinwidth, 0, -1 ); - off = -skinwidth; - dx = 0; - dy = -1; - if (skin[pos + off] == (byte) fillcolor) { - skin[pos + off] = (byte) 255; - fifo[inpt].x = (short) (x + dx); - fifo[inpt].y = (short) (y + dy); - inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; - } - else if (skin[pos + off] != (byte) 255) - fdc = skin[pos + off] & 0xff; - } - - if (y < skinheight - 1) { - // FLOODFILL_STEP( skinwidth, 0, 1 ); - off = skinwidth; - dx = 0; - dy = 1; - if (skin[pos + off] == (byte) fillcolor) { - skin[pos + off] = (byte) 255; - fifo[inpt].x = (short) (x + dx); - fifo[inpt].y = (short) (y + dy); - inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; - } - else if (skin[pos + off] != (byte) 255) - fdc = skin[pos + off] & 0xff; - - } - - skin[x + skinwidth * y] = (byte) fdc; - } - } - - // ======================================================= - - /* - ================ - GL_ResampleTexture - ================ - */ - // cwei :-) - void GL_ResampleTexture(int[] in, int inwidth, int inheight, int[] out, int outwidth, int outheight) { - // int i, j; - // unsigned *inrow, *inrow2; - // int frac, fracstep; - // int[] p1 = new int[1024]; - // int[] p2 = new int[1024]; - // - - // *** this source do the same *** - BufferedImage image = new BufferedImage(inwidth, inheight, BufferedImage.TYPE_INT_ARGB); - - image.setRGB(0, 0, inwidth, inheight, in, 0, inwidth); - - AffineTransformOp op = - new AffineTransformOp( - AffineTransform.getScaleInstance(outwidth * 1.0 / inwidth, outheight * 1.0 / inheight), - AffineTransformOp.TYPE_NEAREST_NEIGHBOR); - BufferedImage tmp = op.filter(image, null); - - tmp.getRGB(0, 0, outwidth, outheight, out, 0, outwidth); - - // *** end *** - - // byte *pix1, *pix2, *pix3, *pix4; - // - // fracstep = inwidth*0x10000/outwidth; - // - // frac = fracstep>>2; - // for (i=0 ; i>16); - // frac += fracstep; - // } - // frac = 3*(fracstep>>2); - // for (i=0 ; i>16); - // frac += fracstep; - // } - // - // for (i=0 ; i> 1; - // for (j=0 ; j>2; - // ((byte *)(out+j))[1] = (pix1[1] + pix2[1] + pix3[1] + pix4[1])>>2; - // ((byte *)(out+j))[2] = (pix1[2] + pix2[2] + pix3[2] + pix4[2])>>2; - // ((byte *)(out+j))[3] = (pix1[3] + pix2[3] + pix3[3] + pix4[3])>>2; - // } - // } - } - - /* - ================ - GL_LightScaleTexture - - Scale up the pixel values in a texture to increase the - lighting range - ================ - */ - void GL_LightScaleTexture(int[] in, int inwidth, int inheight, boolean only_gamma) { - if (only_gamma) { - int i, c; - int r, g, b, color; - - c = inwidth * inheight; - for (i = 0; i < c; i++) { - color = in[i]; - r = (color) & 0xFF; - g = (color >> 8) & 0xFF; - b = (color >> 16) & 0xFF; - - r = gammatable[r] & 0xFF; - g = gammatable[g] & 0xFF; - b = gammatable[b] & 0xFF; - - in[i] = (r) | (g << 8) | (b << 16) | (color & 0xFF000000); - } - } - else { - int i, c; - int r, g, b, color; - - c = inwidth * inheight; - for (i = 0; i < c; i++) { - color = in[i]; - r = (color) & 0xFF; - g = (color >> 8) & 0xFF; - b = (color >> 16) & 0xFF; - - r = gammatable[intensitytable[r] & 0xFF] & 0xFF; - g = gammatable[intensitytable[g] & 0xFF] & 0xFF; - b = gammatable[intensitytable[b] & 0xFF] & 0xFF; - - in[i] = (r) | (g << 8) | (b << 16) | (color & 0xFF000000); - } - - } - } - - /* - ================ - GL_MipMap - - Operates in place, quartering the size of the texture - ================ - */ - void GL_MipMap(int[] in, int width, int height) { - int i, j; - int[] out; - - out = in; - - int inIndex = 0; - int outIndex = 0; - - int r, g, b, a; - int p1, p2, p3, p4; - - for (i = 0; i < height; i += 2, inIndex += width) { - for (j = 0; j < width; j += 2, outIndex += 1, inIndex += 2) { - - p1 = in[inIndex]; - p2 = in[inIndex + 1]; - p3 = in[inIndex + width]; - p4 = in[inIndex + width + 1]; - - r = (((p1) & 0xFF) + ((p2) & 0xFF) + ((p3) & 0xFF) + ((p4) & 0xFF)) >> 2; - g = (((p1 >> 8) & 0xFF) + ((p2 >> 8) & 0xFF) + ((p3 >> 8) & 0xFF) + ((p4 >> 8) & 0xFF)) >> 2; - b = (((p1 >> 16) & 0xFF) + ((p2 >> 16) & 0xFF) + ((p3 >> 16) & 0xFF) + ((p4 >> 16) & 0xFF)) >> 2; - a = (((p1 >> 24) & 0xFF) + ((p2 >> 24) & 0xFF) + ((p3 >> 24) & 0xFF) + ((p4 >> 24) & 0xFF)) >> 2; - - out[outIndex] = (r) | (g << 8) | (b << 16) | (a << 24); - } - } - } - - /* - =============== - GL_Upload32 - - Returns has_alpha - =============== - */ - void GL_BuildPalettedTexture(ByteBuffer paletted_texture, int[] scaled, int scaled_width, int scaled_height) { - - int r, g, b, c; - int size = scaled_width * scaled_height; - - for (int i = 0; i < size; i++) { - - r = (scaled[i] >> 3) & 31; - g = (scaled[i] >> 10) & 63; - b = (scaled[i] >> 19) & 31; - - c = r | (g << 5) | (b << 11); - - paletted_texture.put(i, gl_state.d_16to8table[c]); - } - } - - int upload_width, upload_height; - boolean uploaded_paletted; - - /* - =============== - GL_Upload32 - - Returns has_alpha - =============== - */ - int[] scaled = new int[256 * 256]; - //byte[] paletted_texture = new byte[256 * 256]; - ByteBuffer paletted_texture=BufferUtils.createByteBuffer(256*256); - IntBuffer tex = Lib.newIntBuffer(512 * 256, ByteOrder.LITTLE_ENDIAN); - - boolean GL_Upload32(int[] data, int width, int height, boolean mipmap) { - int samples; - int scaled_width, scaled_height; - int i, c; - int comp; - - Arrays.fill(scaled, 0); - // Arrays.fill(paletted_texture, (byte)0); - paletted_texture.clear(); - for (int j=0; j<256*256; j++) paletted_texture.put(j,(byte)0); - - uploaded_paletted = false; - - for (scaled_width = 1; scaled_width < width; scaled_width <<= 1); - if (gl_round_down.value > 0.0f && scaled_width > width && mipmap) - scaled_width >>= 1; - for (scaled_height = 1; scaled_height < height; scaled_height <<= 1); - if (gl_round_down.value > 0.0f && scaled_height > height && mipmap) - scaled_height >>= 1; - - // let people sample down the world textures for speed - if (mipmap) { - scaled_width >>= (int) gl_picmip.value; - scaled_height >>= (int) gl_picmip.value; - } - - // don't ever bother with >256 textures - if (scaled_width > 256) - scaled_width = 256; - if (scaled_height > 256) - scaled_height = 256; - - if (scaled_width < 1) - scaled_width = 1; - if (scaled_height < 1) - scaled_height = 1; - - upload_width = scaled_width; - upload_height = scaled_height; - - if (scaled_width * scaled_height > 256 * 256) - Com.Error(Defines.ERR_DROP, "GL_Upload32: too big"); - - // scan the texture for any non-255 alpha - c = width * height; - samples = gl_solid_format; - - for (i = 0; i < c; i++) { - if ((data[i] & 0xff000000) != 0xff000000) { - samples = gl_alpha_format; - break; - } - } - - if (samples == gl_solid_format) - comp = gl_tex_solid_format; - else if (samples == gl_alpha_format) - comp = gl_tex_alpha_format; - else { - VID.Printf(Defines.PRINT_ALL, "Unknown number of texture components " + samples + '\n'); - comp = samples; - } - - // simulates a goto - try { - if (scaled_width == width && scaled_height == height) { - if (!mipmap) { - if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && samples == gl_solid_format) { - uploaded_paletted = true; - GL_BuildPalettedTexture(paletted_texture, data, scaled_width, scaled_height); - GL11.glTexImage2D( - GL11.GL_TEXTURE_2D, - 0, - GL_COLOR_INDEX8_EXT, - scaled_width, - scaled_height, - 0, - GL11.GL_COLOR_INDEX, - GL11.GL_UNSIGNED_BYTE, - paletted_texture); - } - else { - tex.rewind(); tex.put(data); tex.rewind(); - GL11.glTexImage2D( - GL11.GL_TEXTURE_2D, - 0, - comp, - scaled_width, - scaled_height, - 0, - GL11.GL_RGBA, - GL11.GL_UNSIGNED_BYTE, - tex); - } - //goto done; - throw gotoDone; - } - //memcpy (scaled, data, width*height*4); were bytes - System.arraycopy(data, 0, scaled, 0, width * height); - } - else - GL_ResampleTexture(data, width, height, scaled, scaled_width, scaled_height); - - GL_LightScaleTexture(scaled, scaled_width, scaled_height, !mipmap); - - if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && (samples == gl_solid_format)) { - uploaded_paletted = true; - GL_BuildPalettedTexture(paletted_texture, scaled, scaled_width, scaled_height); - GL11.glTexImage2D( - GL11.GL_TEXTURE_2D, - 0, - GL_COLOR_INDEX8_EXT, - scaled_width, - scaled_height, - 0, - GL11.GL_COLOR_INDEX, - GL11.GL_UNSIGNED_BYTE, - paletted_texture); - } - else { - tex.rewind(); tex.put(scaled); tex.rewind(); - GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, tex); - } - - if (mipmap) { - int miplevel; - miplevel = 0; - while (scaled_width > 1 || scaled_height > 1) { - GL_MipMap(scaled, scaled_width, scaled_height); - scaled_width >>= 1; - scaled_height >>= 1; - if (scaled_width < 1) - scaled_width = 1; - if (scaled_height < 1) - scaled_height = 1; - - miplevel++; - if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && samples == gl_solid_format) { - uploaded_paletted = true; - GL_BuildPalettedTexture(paletted_texture, scaled, scaled_width, scaled_height); - GL11.glTexImage2D( - GL11.GL_TEXTURE_2D, - miplevel, - GL_COLOR_INDEX8_EXT, - scaled_width, - scaled_height, - 0, - GL11.GL_COLOR_INDEX, - GL11.GL_UNSIGNED_BYTE, - paletted_texture); - } - else { - tex.rewind(); tex.put(scaled); tex.rewind(); - GL11.glTexImage2D( - GL11.GL_TEXTURE_2D, - miplevel, - comp, - scaled_width, - scaled_height, - 0, - GL11.GL_RGBA, - GL11.GL_UNSIGNED_BYTE, - tex); - } - } - } - // label done: - } - catch (Throwable e) { - // replaces label done - } - - if (mipmap) { - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); - } - else { - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_max); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); - } - - return (samples == gl_alpha_format); - } - - /* - =============== - GL_Upload8 - - Returns has_alpha - =============== - */ - - int[] trans = new int[512 * 256]; - - boolean GL_Upload8(byte[] data, int width, int height, boolean mipmap, boolean is_sky) { - - Arrays.fill(trans, 0); - - int s = width * height; - - if (s > trans.length) - Com.Error(Defines.ERR_DROP, "GL_Upload8: too large"); - - if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && is_sky) { - GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, width, height, 0, GL11.GL_COLOR_INDEX, GL11.GL_UNSIGNED_BYTE, ByteBuffer.wrap(data)); - - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_max); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); - - // TODO check this - return false; - } - else { - int p; - for (int i = 0; i < s; i++) { - p = data[i] & 0xff; - trans[i] = d_8to24table[p]; - - if (p == 255) { // transparent, so scan around for another color - // to avoid alpha fringes - // FIXME: do a full flood fill so mips work... - if (i > width && (data[i - width] & 0xff) != 255) - p = data[i - width] & 0xff; - else if (i < s - width && (data[i + width] & 0xff) != 255) - p = data[i + width] & 0xff; - else if (i > 0 && (data[i - 1] & 0xff) != 255) - p = data[i - 1] & 0xff; - else if (i < s - 1 && (data[i + 1] & 0xff) != 255) - p = data[i + 1] & 0xff; - else - p = 0; - // copy rgb components - - // ((byte *)&trans[i])[0] = ((byte *)&d_8to24table[p])[0]; - // ((byte *)&trans[i])[1] = ((byte *)&d_8to24table[p])[1]; - // ((byte *)&trans[i])[2] = ((byte *)&d_8to24table[p])[2]; - - trans[i] = d_8to24table[p] & 0x00FFFFFF; // only rgb - } - } - - return GL_Upload32(trans, width, height, mipmap); - } - } - - /* - ================ - GL_LoadPic - - This is also used as an entry point for the generated r_notexture - ================ - */ - image_t GL_LoadPic(String name, byte[] pic, int width, int height, int type, int bits) { - image_t image; - int i; - - // find a free image_t - for (i = 0; i Defines.MAX_QPATH) - Com.Error(Defines.ERR_DROP, "Draw_LoadPic: \"" + name + "\" is too long"); - - image.name = name; - image.registration_sequence = registration_sequence; - - image.width = width; - image.height = height; - image.type = type; - - - if (type == it_skin && bits == 8) - R_FloodFillSkin(pic, width, height); - - // load little pics into the scrap - if (image.type == it_pic && bits == 8 && image.width < 64 && image.height < 64) { - pos_t pos = new pos_t(0, 0); - int j, k; - - int texnum = Scrap_AllocBlock(image.width, image.height, pos); - - if (texnum == -1) { - // replace goto nonscrap - - image.scrap = false; - - image.texnum = TEXNUM_IMAGES + image.getId(); // image pos in array - GL_Bind(image.texnum); - - image.has_alpha = + // can't fill to filled color or to transparent color (used as visited marker) + if ((fillcolor == filledcolor) || (fillcolor == 255)) { + return; + } + + fifo[inpt].x = 0; + fifo[inpt].y = 0; + inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; + + while (outpt != inpt) { + int x = fifo[outpt].x; + int y = fifo[outpt].y; + int fdc = filledcolor; + // byte *pos = &skin[x + skinwidth * y]; + int pos = x + skinwidth * y; + // + outpt = (outpt + 1) & FLOODFILL_FIFO_MASK; + + int off, dx, dy; + + if (x > 0) { + // FLOODFILL_STEP( -1, -1, 0 ); + off = -1; + dx = -1; + dy = 0; + if (skin[pos + off] == (byte) fillcolor) { + skin[pos + off] = (byte) 255; + fifo[inpt].x = (short) (x + dx); + fifo[inpt].y = (short) (y + dy); + inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; + } + else if (skin[pos + off] != (byte) 255) + fdc = skin[pos + off] & 0xff; + } + + if (x < skinwidth - 1) { + // FLOODFILL_STEP( 1, 1, 0 ); + off = 1; + dx = 1; + dy = 0; + if (skin[pos + off] == (byte) fillcolor) { + skin[pos + off] = (byte) 255; + fifo[inpt].x = (short) (x + dx); + fifo[inpt].y = (short) (y + dy); + inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; + } + else if (skin[pos + off] != (byte) 255) + fdc = skin[pos + off] & 0xff; + } + + if (y > 0) { + // FLOODFILL_STEP( -skinwidth, 0, -1 ); + off = -skinwidth; + dx = 0; + dy = -1; + if (skin[pos + off] == (byte) fillcolor) { + skin[pos + off] = (byte) 255; + fifo[inpt].x = (short) (x + dx); + fifo[inpt].y = (short) (y + dy); + inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; + } + else if (skin[pos + off] != (byte) 255) + fdc = skin[pos + off] & 0xff; + } + + if (y < skinheight - 1) { + // FLOODFILL_STEP( skinwidth, 0, 1 ); + off = skinwidth; + dx = 0; + dy = 1; + if (skin[pos + off] == (byte) fillcolor) { + skin[pos + off] = (byte) 255; + fifo[inpt].x = (short) (x + dx); + fifo[inpt].y = (short) (y + dy); + inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; + } + else if (skin[pos + off] != (byte) 255) + fdc = skin[pos + off] & 0xff; + + } + + skin[x + skinwidth * y] = (byte) fdc; + } + } + + // ======================================================= + + /* + ================ + GL_ResampleTexture + ================ + */ + // cwei :-) + void GL_ResampleTexture(int[] in, int inwidth, int inheight, int[] out, int outwidth, int outheight) { + // int i, j; + // unsigned *inrow, *inrow2; + // int frac, fracstep; + // int[] p1 = new int[1024]; + // int[] p2 = new int[1024]; + // + + // *** this source do the same *** + BufferedImage image = new BufferedImage(inwidth, inheight, BufferedImage.TYPE_INT_ARGB); + + image.setRGB(0, 0, inwidth, inheight, in, 0, inwidth); + + AffineTransformOp op = + new AffineTransformOp( + AffineTransform.getScaleInstance(outwidth * 1.0 / inwidth, outheight * 1.0 / inheight), + AffineTransformOp.TYPE_NEAREST_NEIGHBOR); + BufferedImage tmp = op.filter(image, null); + + tmp.getRGB(0, 0, outwidth, outheight, out, 0, outwidth); + + // *** end *** + + // byte *pix1, *pix2, *pix3, *pix4; + // + // fracstep = inwidth*0x10000/outwidth; + // + // frac = fracstep>>2; + // for (i=0 ; i>16); + // frac += fracstep; + // } + // frac = 3*(fracstep>>2); + // for (i=0 ; i>16); + // frac += fracstep; + // } + // + // for (i=0 ; i> 1; + // for (j=0 ; j>2; + // ((byte *)(out+j))[1] = (pix1[1] + pix2[1] + pix3[1] + pix4[1])>>2; + // ((byte *)(out+j))[2] = (pix1[2] + pix2[2] + pix3[2] + pix4[2])>>2; + // ((byte *)(out+j))[3] = (pix1[3] + pix2[3] + pix3[3] + pix4[3])>>2; + // } + // } + } + + /* + ================ + GL_LightScaleTexture + + Scale up the pixel values in a texture to increase the + lighting range + ================ + */ + void GL_LightScaleTexture(int[] in, int inwidth, int inheight, boolean only_gamma) { + if (only_gamma) { + int i, c; + int r, g, b, color; + + c = inwidth * inheight; + for (i = 0; i < c; i++) { + color = in[i]; + r = (color) & 0xFF; + g = (color >> 8) & 0xFF; + b = (color >> 16) & 0xFF; + + r = gammatable[r] & 0xFF; + g = gammatable[g] & 0xFF; + b = gammatable[b] & 0xFF; + + in[i] = (r) | (g << 8) | (b << 16) | (color & 0xFF000000); + } + } + else { + int i, c; + int r, g, b, color; + + c = inwidth * inheight; + for (i = 0; i < c; i++) { + color = in[i]; + r = (color) & 0xFF; + g = (color >> 8) & 0xFF; + b = (color >> 16) & 0xFF; + + r = gammatable[intensitytable[r] & 0xFF] & 0xFF; + g = gammatable[intensitytable[g] & 0xFF] & 0xFF; + b = gammatable[intensitytable[b] & 0xFF] & 0xFF; + + in[i] = (r) | (g << 8) | (b << 16) | (color & 0xFF000000); + } + + } + } + + /* + ================ + GL_MipMap + + Operates in place, quartering the size of the texture + ================ + */ + void GL_MipMap(int[] in, int width, int height) { + int i, j; + int[] out; + + out = in; + + int inIndex = 0; + int outIndex = 0; + + int r, g, b, a; + int p1, p2, p3, p4; + + for (i = 0; i < height; i += 2, inIndex += width) { + for (j = 0; j < width; j += 2, outIndex += 1, inIndex += 2) { + + p1 = in[inIndex]; + p2 = in[inIndex + 1]; + p3 = in[inIndex + width]; + p4 = in[inIndex + width + 1]; + + r = (((p1) & 0xFF) + ((p2) & 0xFF) + ((p3) & 0xFF) + ((p4) & 0xFF)) >> 2; + g = (((p1 >> 8) & 0xFF) + ((p2 >> 8) & 0xFF) + ((p3 >> 8) & 0xFF) + ((p4 >> 8) & 0xFF)) >> 2; + b = (((p1 >> 16) & 0xFF) + ((p2 >> 16) & 0xFF) + ((p3 >> 16) & 0xFF) + ((p4 >> 16) & 0xFF)) >> 2; + a = (((p1 >> 24) & 0xFF) + ((p2 >> 24) & 0xFF) + ((p3 >> 24) & 0xFF) + ((p4 >> 24) & 0xFF)) >> 2; + + out[outIndex] = (r) | (g << 8) | (b << 16) | (a << 24); + } + } + } + + /* + =============== + GL_Upload32 + + Returns has_alpha + =============== + */ + void GL_BuildPalettedTexture(ByteBuffer paletted_texture, int[] scaled, int scaled_width, int scaled_height) { + + int r, g, b, c; + int size = scaled_width * scaled_height; + + for (int i = 0; i < size; i++) { + + r = (scaled[i] >> 3) & 31; + g = (scaled[i] >> 10) & 63; + b = (scaled[i] >> 19) & 31; + + c = r | (g << 5) | (b << 11); + + paletted_texture.put(i, gl_state.d_16to8table[c]); + } + } + + int upload_width, upload_height; + boolean uploaded_paletted; + + /* + =============== + GL_Upload32 + + Returns has_alpha + =============== + */ + int[] scaled = new int[256 * 256]; + //byte[] paletted_texture = new byte[256 * 256]; + ByteBuffer paletted_texture=BufferUtils.createByteBuffer(256*256); + IntBuffer tex = Lib.newIntBuffer(512 * 256, ByteOrder.LITTLE_ENDIAN); + + boolean GL_Upload32(int[] data, int width, int height, boolean mipmap) { + int samples; + int scaled_width, scaled_height; + int i, c; + int comp; + + Arrays.fill(scaled, 0); + // Arrays.fill(paletted_texture, (byte)0); + paletted_texture.clear(); + for (int j=0; j<256*256; j++) paletted_texture.put(j,(byte)0); + + uploaded_paletted = false; + + for (scaled_width = 1; scaled_width < width; scaled_width <<= 1); + if (gl_round_down.value > 0.0f && scaled_width > width && mipmap) + scaled_width >>= 1; + for (scaled_height = 1; scaled_height < height; scaled_height <<= 1); + if (gl_round_down.value > 0.0f && scaled_height > height && mipmap) + scaled_height >>= 1; + + // let people sample down the world textures for speed + if (mipmap) { + scaled_width >>= (int) gl_picmip.value; + scaled_height >>= (int) gl_picmip.value; + } + + // don't ever bother with >256 textures + if (scaled_width > 256) + scaled_width = 256; + if (scaled_height > 256) + scaled_height = 256; + + if (scaled_width < 1) + scaled_width = 1; + if (scaled_height < 1) + scaled_height = 1; + + upload_width = scaled_width; + upload_height = scaled_height; + + if (scaled_width * scaled_height > 256 * 256) + Com.Error(Defines.ERR_DROP, "GL_Upload32: too big"); + + // scan the texture for any non-255 alpha + c = width * height; + samples = gl_solid_format; + + for (i = 0; i < c; i++) { + if ((data[i] & 0xff000000) != 0xff000000) { + samples = gl_alpha_format; + break; + } + } + + if (samples == gl_solid_format) + comp = gl_tex_solid_format; + else if (samples == gl_alpha_format) + comp = gl_tex_alpha_format; + else { + VID.Printf(Defines.PRINT_ALL, "Unknown number of texture components " + samples + '\n'); + comp = samples; + } + + // simulates a goto + try { + if (scaled_width == width && scaled_height == height) { + if (!mipmap) { + if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && samples == gl_solid_format) { + uploaded_paletted = true; + GL_BuildPalettedTexture(paletted_texture, data, scaled_width, scaled_height); + GL11.glTexImage2D( + GL11.GL_TEXTURE_2D, + 0, + GL_COLOR_INDEX8_EXT, + scaled_width, + scaled_height, + 0, + GL11.GL_COLOR_INDEX, + GL11.GL_UNSIGNED_BYTE, + paletted_texture); + } + else { + tex.rewind(); tex.put(data); tex.rewind(); + GL11.glTexImage2D( + GL11.GL_TEXTURE_2D, + 0, + comp, + scaled_width, + scaled_height, + 0, + GL11.GL_RGBA, + GL11.GL_UNSIGNED_BYTE, + tex); + } + //goto done; + throw gotoDone; + } + //memcpy (scaled, data, width*height*4); were bytes + System.arraycopy(data, 0, scaled, 0, width * height); + } + else + GL_ResampleTexture(data, width, height, scaled, scaled_width, scaled_height); + + GL_LightScaleTexture(scaled, scaled_width, scaled_height, !mipmap); + + if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && (samples == gl_solid_format)) { + uploaded_paletted = true; + GL_BuildPalettedTexture(paletted_texture, scaled, scaled_width, scaled_height); + GL11.glTexImage2D( + GL11.GL_TEXTURE_2D, + 0, + GL_COLOR_INDEX8_EXT, + scaled_width, + scaled_height, + 0, + GL11.GL_COLOR_INDEX, + GL11.GL_UNSIGNED_BYTE, + paletted_texture); + } + else { + tex.rewind(); tex.put(scaled); tex.rewind(); + GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, tex); + } + + if (mipmap) { + int miplevel; + miplevel = 0; + while (scaled_width > 1 || scaled_height > 1) { + GL_MipMap(scaled, scaled_width, scaled_height); + scaled_width >>= 1; + scaled_height >>= 1; + if (scaled_width < 1) + scaled_width = 1; + if (scaled_height < 1) + scaled_height = 1; + + miplevel++; + if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && samples == gl_solid_format) { + uploaded_paletted = true; + GL_BuildPalettedTexture(paletted_texture, scaled, scaled_width, scaled_height); + GL11.glTexImage2D( + GL11.GL_TEXTURE_2D, + miplevel, + GL_COLOR_INDEX8_EXT, + scaled_width, + scaled_height, + 0, + GL11.GL_COLOR_INDEX, + GL11.GL_UNSIGNED_BYTE, + paletted_texture); + } + else { + tex.rewind(); tex.put(scaled); tex.rewind(); + GL11.glTexImage2D( + GL11.GL_TEXTURE_2D, + miplevel, + comp, + scaled_width, + scaled_height, + 0, + GL11.GL_RGBA, + GL11.GL_UNSIGNED_BYTE, + tex); + } + } + } + // label done: + } + catch (Throwable e) { + // replaces label done + } + + if (mipmap) { + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); + } + else { + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_max); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); + } + + return (samples == gl_alpha_format); + } + + /* + =============== + GL_Upload8 + + Returns has_alpha + =============== + */ + + int[] trans = new int[512 * 256]; + + boolean GL_Upload8(byte[] data, int width, int height, boolean mipmap, boolean is_sky) { + + Arrays.fill(trans, 0); + + int s = width * height; + + if (s > trans.length) + Com.Error(Defines.ERR_DROP, "GL_Upload8: too large"); + + if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && is_sky) { + GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, width, height, 0, GL11.GL_COLOR_INDEX, GL11.GL_UNSIGNED_BYTE, ByteBuffer.wrap(data)); + + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_max); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); + + // TODO check this + return false; + } + else { + int p; + for (int i = 0; i < s; i++) { + p = data[i] & 0xff; + trans[i] = d_8to24table[p]; + + if (p == 255) { // transparent, so scan around for another color + // to avoid alpha fringes + // FIXME: do a full flood fill so mips work... + if (i > width && (data[i - width] & 0xff) != 255) + p = data[i - width] & 0xff; + else if (i < s - width && (data[i + width] & 0xff) != 255) + p = data[i + width] & 0xff; + else if (i > 0 && (data[i - 1] & 0xff) != 255) + p = data[i - 1] & 0xff; + else if (i < s - 1 && (data[i + 1] & 0xff) != 255) + p = data[i + 1] & 0xff; + else + p = 0; + // copy rgb components + + // ((byte *)&trans[i])[0] = ((byte *)&d_8to24table[p])[0]; + // ((byte *)&trans[i])[1] = ((byte *)&d_8to24table[p])[1]; + // ((byte *)&trans[i])[2] = ((byte *)&d_8to24table[p])[2]; + + trans[i] = d_8to24table[p] & 0x00FFFFFF; // only rgb + } + } + + return GL_Upload32(trans, width, height, mipmap); + } + } + + /* + ================ + GL_LoadPic + + This is also used as an entry point for the generated r_notexture + ================ + */ + image_t GL_LoadPic(String name, byte[] pic, int width, int height, int type, int bits) { + image_t image; + int i; + + // find a free image_t + for (i = 0; i Defines.MAX_QPATH) + Com.Error(Defines.ERR_DROP, "Draw_LoadPic: \"" + name + "\" is too long"); + + image.name = name; + image.registration_sequence = registration_sequence; + + image.width = width; + image.height = height; + image.type = type; + + + if (type == it_skin && bits == 8) + R_FloodFillSkin(pic, width, height); + + // load little pics into the scrap + if (image.type == it_pic && bits == 8 && image.width < 64 && image.height < 64) { + pos_t pos = new pos_t(0, 0); + int j, k; + + int texnum = Scrap_AllocBlock(image.width, image.height, pos); + + if (texnum == -1) { + // replace goto nonscrap + + image.scrap = false; + + image.texnum = TEXNUM_IMAGES + image.getId(); // image pos in array + GL_Bind(image.texnum); + + image.has_alpha = GL_Upload8(pic, width, height, (image.type != it_pic && image.type != it_sky), image.type == it_sky); - image.upload_width = upload_width; // after power of 2 and scales - image.upload_height = upload_height; - image.paletted = uploaded_paletted; - image.sl = 0; - image.sh = 1; - image.tl = 0; - image.th = 1; + image.upload_width = upload_width; // after power of 2 and scales + image.upload_height = upload_height; + image.paletted = uploaded_paletted; + image.sl = 0; + image.sh = 1; + image.tl = 0; + image.th = 1; - return image; - } + return image; + } - scrap_dirty = true; + scrap_dirty = true; - // copy the texels into the scrap block - k = 0; - for (i = 0; i < image.height; i++) - for (j = 0; j < image.width; j++, k++) - scrap_texels[texnum][(pos.y + i) * BLOCK_WIDTH + pos.x + j] = pic[k]; + // copy the texels into the scrap block + k = 0; + for (i = 0; i < image.height; i++) + for (j = 0; j < image.width; j++, k++) + scrap_texels[texnum][(pos.y + i) * BLOCK_WIDTH + pos.x + j] = pic[k]; - image.texnum = TEXNUM_SCRAPS + texnum; - image.scrap = true; - image.has_alpha = true; - image.sl = (pos.x + 0.01f) / (float) BLOCK_WIDTH; - image.sh = (pos.x + image.width - 0.01f) / (float) BLOCK_WIDTH; - image.tl = (pos.y + 0.01f) / (float) BLOCK_WIDTH; - image.th = (pos.y + image.height - 0.01f) / (float) BLOCK_WIDTH; + image.texnum = TEXNUM_SCRAPS + texnum; + image.scrap = true; + image.has_alpha = true; + image.sl = (pos.x + 0.01f) / (float) BLOCK_WIDTH; + image.sh = (pos.x + image.width - 0.01f) / (float) BLOCK_WIDTH; + image.tl = (pos.y + 0.01f) / (float) BLOCK_WIDTH; + image.th = (pos.y + image.height - 0.01f) / (float) BLOCK_WIDTH; - } - else { - // this was label nonscrap + } + else { + // this was label nonscrap - image.scrap = false; + image.scrap = false; - image.texnum = TEXNUM_IMAGES + image.getId(); //image pos in array - GL_Bind(image.texnum); + image.texnum = TEXNUM_IMAGES + image.getId(); //image pos in array + GL_Bind(image.texnum); - if (bits == 8) { - image.has_alpha = GL_Upload8(pic, width, height, (image.type != it_pic && image.type != it_sky), image.type == it_sky); - } - else { - int[] tmp = new int[pic.length / 4]; + if (bits == 8) { + image.has_alpha = GL_Upload8(pic, width, height, (image.type != it_pic && image.type != it_sky), image.type == it_sky); + } + else { + int[] tmp = new int[pic.length / 4]; - for (i = 0; i < tmp.length; i++) { - tmp[i] = ((pic[4 * i] & 0xFF)); // & 0x000000FF; - tmp[i] |= ((pic[4 * i + 1] & 0xFF) << 8); // & 0x0000FF00; - tmp[i] |= ((pic[4 * i + 2] & 0xFF) << 16); // & 0x00FF0000; - tmp[i] |= ((pic[4 * i + 3] & 0xFF) << 24); // & 0xFF000000; - } + for (i = 0; i < tmp.length; i++) { + tmp[i] = ((pic[4 * i] & 0xFF)); // & 0x000000FF; + tmp[i] |= ((pic[4 * i + 1] & 0xFF) << 8); // & 0x0000FF00; + tmp[i] |= ((pic[4 * i + 2] & 0xFF) << 16); // & 0x00FF0000; + tmp[i] |= ((pic[4 * i + 3] & 0xFF) << 24); // & 0xFF000000; + } - image.has_alpha = GL_Upload32(tmp, width, height, (image.type != it_pic && image.type != it_sky)); - } - image.upload_width = upload_width; // after power of 2 and scales - image.upload_height = upload_height; - image.paletted = uploaded_paletted; - image.sl = 0; - image.sh = 1; - image.tl = 0; - image.th = 1; - } - return image; - } + image.has_alpha = GL_Upload32(tmp, width, height, (image.type != it_pic && image.type != it_sky)); + } + image.upload_width = upload_width; // after power of 2 and scales + image.upload_height = upload_height; + image.paletted = uploaded_paletted; + image.sl = 0; + image.sh = 1; + image.tl = 0; + image.th = 1; + } + return image; + } - /* - ================ - GL_LoadWal - ================ - */ - image_t GL_LoadWal(String name) { + /* + ================ + GL_LoadWal + ================ + */ + image_t GL_LoadWal(String name) { - image_t image; + image_t image; - byte[] raw = fileSystem.loadFile(name); - if (raw == null) { - VID.Printf(Defines.PRINT_ALL, "GL_FindImage: can't load " + name + '\n'); - return r_notexture; - } + byte[] raw = fileSystem.loadFile(name); + if (raw == null) { + VID.Printf(Defines.PRINT_ALL, "GL_FindImage: can't load " + name + '\n'); + return r_notexture; + } - qfiles.miptex_t mt = new qfiles.miptex_t(raw); + qfiles.miptex_t mt = new qfiles.miptex_t(raw); - byte[] pix = new byte[mt.width * mt.height]; - System.arraycopy(raw, mt.offsets[0], pix, 0, pix.length); + byte[] pix = new byte[mt.width * mt.height]; + System.arraycopy(raw, mt.offsets[0], pix, 0, pix.length); - image = GL_LoadPic(name, pix, mt.width, mt.height, it_wall, 8); + image = GL_LoadPic(name, pix, mt.width, mt.height, it_wall, 8); - return image; - } + return image; + } - /* - =============== - GL_FindImage - - Finds or loads the given image - =============== - */ - image_t GL_FindImage(String name, int type) { - image_t image; + /* + =============== + GL_FindImage + + Finds or loads the given image + =============== + */ + image_t GL_FindImage(String name, int type) { + image_t image; -// // TODO loest das grossschreibungs problem -// name = name.toLowerCase(); -// // bughack for bad strings (fuck \0) -// int index = name.indexOf('\0'); -// if (index != -1) -// name = name.substring(0, index); +// // TODO loest das grossschreibungs problem +// name = name.toLowerCase(); +// // bughack for bad strings (fuck \0) +// int index = name.indexOf('\0'); +// if (index != -1) +// name = name.substring(0, index); - if (name == null || name.length() < 5) - return null; // Com.Error (ERR_DROP, "GL_FindImage: NULL name"); - // Com.Error (ERR_DROP, "GL_FindImage: bad name: %s", name); + if (name == null || name.length() < 5) + return null; // Com.Error (ERR_DROP, "GL_FindImage: NULL name"); + // Com.Error (ERR_DROP, "GL_FindImage: bad name: %s", name); - // look for it - for (int i = 0; i < numgltextures; i++) - { - image = gltextures[i]; - if (name.equals(image.name)) - { - image.registration_sequence = registration_sequence; - return image; - } - } + // look for it + for (int i = 0; i < numgltextures; i++) + { + image = gltextures[i]; + if (name.equals(image.name)) + { + image.registration_sequence = registration_sequence; + return image; + } + } - // - // load the pic from disk - // - image = null; - byte[] pic; - Dimension dim = new Dimension(); + // + // load the pic from disk + // + image = null; + byte[] pic; + Dimension dim = new Dimension(); - if (name.endsWith(".pcx")) { + if (name.endsWith(".pcx")) { - pic = LoadPCX(name, null, dim); - if (pic == null) - return null; - image = GL_LoadPic(name, pic, dim.width, dim.height, type, 8); + pic = LoadPCX(name, null, dim); + if (pic == null) + return null; + image = GL_LoadPic(name, pic, dim.width, dim.height, type, 8); - } - else if (name.endsWith(".wal")) { + } + else if (name.endsWith(".wal")) { - image = GL_LoadWal(name); + image = GL_LoadWal(name); - } - else if (name.endsWith(".tga")) { + } + else if (name.endsWith(".tga")) { - pic = LoadTGA(name, dim); + pic = LoadTGA(name, dim); - if (pic == null) - return null; + if (pic == null) + return null; - image = GL_LoadPic(name, pic, dim.width, dim.height, type, 32); + image = GL_LoadPic(name, pic, dim.width, dim.height, type, 32); - } + } - return image; - } + return image; + } - /* - =============== - R_RegisterSkin - =============== - */ - protected image_t R_RegisterSkin(String name) { - return GL_FindImage(name, it_skin); - } + /* + =============== + R_RegisterSkin + =============== + */ + protected image_t R_RegisterSkin(String name) { + return GL_FindImage(name, it_skin); + } - IntBuffer texnumBuffer=BufferUtils.createIntBuffer(1); - - /* - ================ - GL_FreeUnusedImages - - Any image that was not touched on this registration sequence - will be freed. - ================ - */ - void GL_FreeUnusedImages() { + IntBuffer texnumBuffer=BufferUtils.createIntBuffer(1); + + /* + ================ + GL_FreeUnusedImages + + Any image that was not touched on this registration sequence + will be freed. + ================ + */ + void GL_FreeUnusedImages() { - // never free r_notexture or particle texture - r_notexture.registration_sequence = registration_sequence; - r_particletexture.registration_sequence = registration_sequence; + // never free r_notexture or particle texture + r_notexture.registration_sequence = registration_sequence; + r_particletexture.registration_sequence = registration_sequence; - image_t image; + image_t image; - for (int i = 0; i < numgltextures; i++) { - image = gltextures[i]; - // used this sequence - if (image.registration_sequence == registration_sequence) - continue; - // free image_t slot - if (image.registration_sequence == 0) - continue; - // don't free pics - if (image.type == it_pic) - continue; + for (int i = 0; i < numgltextures; i++) { + image = gltextures[i]; + // used this sequence + if (image.registration_sequence == registration_sequence) + continue; + // free image_t slot + if (image.registration_sequence == 0) + continue; + // don't free pics + if (image.type == it_pic) + continue; - // free it - // TODO jogl bug - texnumBuffer.clear(); - texnumBuffer.put(0,image.texnum); - GL11.glDeleteTextures(texnumBuffer); - image.clear(); - } - } + // free it + // TODO jogl bug + texnumBuffer.clear(); + texnumBuffer.put(0,image.texnum); + GL11.glDeleteTextures(texnumBuffer); + image.clear(); + } + } - /* - =============== - Draw_GetPalette - =============== - */ - protected void Draw_GetPalette() { - int r, g, b; - byte[][] palette = new byte[1][]; //new byte[768]; + /* + =============== + Draw_GetPalette + =============== + */ + protected void Draw_GetPalette() { + int r, g, b; + byte[][] palette = new byte[1][]; //new byte[768]; - // get the palette + // get the palette - LoadPCX("pics/colormap.pcx", palette, new Dimension()); + LoadPCX("pics/colormap.pcx", palette, new Dimension()); - if (palette[0] == null || palette[0].length != 768) - Com.Error(Defines.ERR_FATAL, "Couldn't load pics/colormap.pcx"); + if (palette[0] == null || palette[0].length != 768) + Com.Error(Defines.ERR_FATAL, "Couldn't load pics/colormap.pcx"); - byte[] pal = palette[0]; + byte[] pal = palette[0]; - int j = 0; - for (int i = 0; i < 256; i++) { - r = pal[j++] & 0xFF; - g = pal[j++] & 0xFF; - b = pal[j++] & 0xFF; + int j = 0; + for (int i = 0; i < 256; i++) { + r = pal[j++] & 0xFF; + g = pal[j++] & 0xFF; + b = pal[j++] & 0xFF; - d_8to24table[i] = (255 << 24) | (b << 16) | (g << 8) | (r); - } + d_8to24table[i] = (255 << 24) | (b << 16) | (g << 8) | (r); + } - d_8to24table[255] &= 0x00FFFFFF; // 255 is transparent + d_8to24table[255] &= 0x00FFFFFF; // 255 is transparent - particle_t.setColorPalette(d_8to24table); - } + particle_t.setColorPalette(d_8to24table); + } - /* - =============== - GL_InitImages - =============== - */ - void GL_InitImages() { - int i, j; - float g = vid_gamma.value; + /* + =============== + GL_InitImages + =============== + */ + void GL_InitImages() { + int i, j; + float g = vid_gamma.value; - registration_sequence = 1; + registration_sequence = 1; - // init intensity conversions - intensity = Cvar.Get("intensity", "2", 0); + // init intensity conversions + intensity = Cvar.Get("intensity", "2", 0); - if (intensity.value <= 1) - Cvar.Set("intensity", "1"); + if (intensity.value <= 1) + Cvar.Set("intensity", "1"); - gl_state.inverse_intensity = 1 / intensity.value; + gl_state.inverse_intensity = 1 / intensity.value; - Draw_GetPalette(); + Draw_GetPalette(); - if (qglColorTableEXT) { - gl_state.d_16to8table = fileSystem.loadFile("pics/16to8.dat"); - if (gl_state.d_16to8table == null) - Com.Error(Defines.ERR_FATAL, "Couldn't load pics/16to8.pcx"); - } + if (qglColorTableEXT) { + gl_state.d_16to8table = fileSystem.loadFile("pics/16to8.dat"); + if (gl_state.d_16to8table == null) + Com.Error(Defines.ERR_FATAL, "Couldn't load pics/16to8.pcx"); + } - if ((gl_config.renderer & (GL_RENDERER_VOODOO | GL_RENDERER_VOODOO2)) != 0) { - g = 1.0F; - } + if ((gl_config.renderer & (GL_RENDERER_VOODOO | GL_RENDERER_VOODOO2)) != 0) { + g = 1.0F; + } - for (i = 0; i < 256; i++) { + for (i = 0; i < 256; i++) { - if (g == 1.0f) { - gammatable[i] = (byte) i; - } - else { + if (g == 1.0f) { + gammatable[i] = (byte) i; + } + else { - int inf = (int) (255.0f * Math.pow((i + 0.5) / 255.5, g) + 0.5); - if (inf < 0) - inf = 0; - if (inf > 255) - inf = 255; - gammatable[i] = (byte) inf; - } - } + int inf = (int) (255.0f * Math.pow((i + 0.5) / 255.5, g) + 0.5); + if (inf < 0) + inf = 0; + if (inf > 255) + inf = 255; + gammatable[i] = (byte) inf; + } + } - for (i = 0; i < 256; i++) { - j = (int) (i * intensity.value); - if (j > 255) - j = 255; - intensitytable[i] = (byte) j; - } - } + for (i = 0; i < 256; i++) { + j = (int) (i * intensity.value); + if (j > 255) + j = 255; + intensitytable[i] = (byte) j; + } + } - /* - =============== - GL_ShutdownImages - =============== - */ - void GL_ShutdownImages() { - image_t image; - - for (int i=0; i < numgltextures ; i++) - { - image = gltextures[i]; - - if (image.registration_sequence == 0) - continue; // free image_t slot - // free it - // TODO jogl bug - texnumBuffer.clear(); - texnumBuffer.put(0,image.texnum); - GL11.glDeleteTextures(texnumBuffer); - image.clear(); - } - } + /* + =============== + GL_ShutdownImages + =============== + */ + void GL_ShutdownImages() { + image_t image; + + for (int i=0; i < numgltextures ; i++) + { + image = gltextures[i]; + + if (image.registration_sequence == 0) + continue; // free image_t slot + // free it + // TODO jogl bug + texnumBuffer.clear(); + texnumBuffer.put(0,image.texnum); + GL11.glDeleteTextures(texnumBuffer); + image.clear(); + } + } } diff --git a/src/main/java/lwjake2/render/lwjgl/LWJGLBase.java b/src/main/java/lwjake2/render/lwjgl/LWJGLBase.java index 397d367..b829579 100644 --- a/src/main/java/lwjake2/render/lwjgl/LWJGLBase.java +++ b/src/main/java/lwjake2/render/lwjgl/LWJGLBase.java @@ -40,311 +40,311 @@ import org.lwjgl.opengl.GL11; */ @Slf4j public abstract class LWJGLBase { - // IMPORTED FUNCTIONS - protected DisplayMode oldDisplayMode; + // IMPORTED FUNCTIONS + protected DisplayMode oldDisplayMode; - - // window position on the screen - int window_xpos, window_ypos; - protected viddef_t vid = new viddef_t(); + + // window position on the screen + int window_xpos, window_ypos; + protected viddef_t vid = new viddef_t(); - // handles the post initialization with LWJGLRenderer - protected abstract boolean R_Init2(); - - protected cvar_t vid_fullscreen; + // handles the post initialization with LWJGLRenderer + protected abstract boolean R_Init2(); + + protected cvar_t vid_fullscreen; - // enum rserr_t - protected static final int rserr_ok = 0; - protected static final int rserr_invalid_fullscreen = 1; - protected static final int rserr_invalid_mode = 2; - protected static final int rserr_unknown = 3; - - private java.awt.DisplayMode toAwtDisplayMode(DisplayMode m) - { - return new java.awt.DisplayMode(m.getWidth(),m.getHeight(),m.getBitsPerPixel(),m.getFrequency()); - } + // enum rserr_t + protected static final int rserr_ok = 0; + protected static final int rserr_invalid_fullscreen = 1; + protected static final int rserr_invalid_mode = 2; + protected static final int rserr_unknown = 3; + + private java.awt.DisplayMode toAwtDisplayMode(DisplayMode m) + { + return new java.awt.DisplayMode(m.getWidth(),m.getHeight(),m.getBitsPerPixel(),m.getFrequency()); + } - public java.awt.DisplayMode[] getModeList() - { - try { - DisplayMode[] modes; - - modes = Display.getAvailableDisplayModes(); - - LinkedList l = new LinkedList(); - l.add(toAwtDisplayMode(oldDisplayMode)); - - for (int i = 0; i < modes.length; i++) { - DisplayMode m = modes[i]; - - if (m.getBitsPerPixel() != oldDisplayMode.getBitsPerPixel()) continue; - if (m.getFrequency() > oldDisplayMode.getFrequency()) continue; - if (m.getHeight() < 240 || m.getWidth() < 320) continue; - - int j = 0; - java.awt.DisplayMode ml = null; - for (j = 0; j < l.size(); j++) { - ml = (java.awt.DisplayMode)l.get(j); - if (ml.getWidth() > m.getWidth()) break; - if (ml.getWidth() == m.getWidth() && ml.getHeight() >= m.getHeight()) break; - } - if (j == l.size()) { - l.addLast(toAwtDisplayMode(m)); - } else if (ml.getWidth() > m.getWidth() || ml.getHeight() > m.getHeight()) { - l.add(j, toAwtDisplayMode(m)); - } else if (m.getFrequency() > ml.getRefreshRate()){ - l.remove(j); - l.add(j, toAwtDisplayMode(m)); - } - } - java.awt.DisplayMode[] ma = new java.awt.DisplayMode[l.size()]; - l.toArray(ma); - return ma; - } catch (LWJGLException e) { - e.printStackTrace(); - System.exit(0); - } - return null; - } - - public DisplayMode[] getLWJGLModeList() { - try { - // Return value storage. - ArrayList displayModes; - - // Get all possible display modes. - DisplayMode[] allDisplayModes = Display.getAvailableDisplayModes(); - - // Cut down all the ones with a height below 240. - displayModes = new ArrayList(); - for (int x = 0; x < allDisplayModes.length; x++) { - if (allDisplayModes[x].getHeight() >= 240) - displayModes.add(allDisplayModes[x]); - } - - // Gnome sort the display modes by height, width, and refresh rate. - int currentSpot = 0; - boolean needSwap = false; - DisplayMode tempStore; - while (currentSpot < displayModes.size() - 1) { - // Check DisplayMode heights. - if (displayModes.get(currentSpot).getHeight() > displayModes.get(currentSpot + 1).getHeight()) - needSwap = true; - else if (displayModes.get(currentSpot).getHeight() == displayModes.get(currentSpot + 1).getHeight()) { - // Check DisplayMode widths. - if (displayModes.get(currentSpot).getWidth() > displayModes.get(currentSpot + 1).getWidth()) - needSwap = true; - else if (displayModes.get(currentSpot).getWidth() == displayModes.get(currentSpot + 1).getWidth()) - // Doesn't sort frequencies, but removes the lesser ones entirely. - if (displayModes.get(currentSpot).getFrequency() < displayModes.get(currentSpot + 1).getFrequency()) { - displayModes.remove(currentSpot); - currentSpot--; - } - else if (displayModes.get(currentSpot).getFrequency() > displayModes.get(currentSpot + 1).getFrequency()) { - displayModes.remove(currentSpot + 1); - currentSpot--; - } - } - if (needSwap) { - needSwap = false; - tempStore = displayModes.get(currentSpot); - displayModes.set(currentSpot, displayModes.get(currentSpot + 1)); - displayModes.set(currentSpot + 1, tempStore); - if (currentSpot > 0) - currentSpot--; - } - else - currentSpot++; - } - - // Return the array. - return displayModes.toArray(new DisplayMode[displayModes.size()]); - - } catch (LWJGLException e) { - e.printStackTrace(); - System.exit(0); - } - return null; - } - - private DisplayMode findDisplayMode(Dimension dim) { - DisplayMode mode = null; - DisplayMode m = null; - DisplayMode[] modes = getLWJGLModeList(); - int w = dim.width; - int h = dim.height; - - for (int i = 0; i < modes.length; i++) { - m = modes[i]; - if (m.getWidth() == w && m.getHeight() == h) { - mode = m; - break; - } - } - if (mode == null) mode = oldDisplayMode; - return mode; - } - - String getModeString(DisplayMode m) { - StringBuffer sb = new StringBuffer(); - sb.append(m.getWidth()); - sb.append('x'); - sb.append(m.getHeight()); - sb.append('x'); - sb.append(m.getBitsPerPixel()); - sb.append('@'); - sb.append(m.getFrequency()); - sb.append("Hz"); - return sb.toString(); - } + public java.awt.DisplayMode[] getModeList() + { + try { + DisplayMode[] modes; + + modes = Display.getAvailableDisplayModes(); + + LinkedList l = new LinkedList(); + l.add(toAwtDisplayMode(oldDisplayMode)); + + for (int i = 0; i < modes.length; i++) { + DisplayMode m = modes[i]; + + if (m.getBitsPerPixel() != oldDisplayMode.getBitsPerPixel()) continue; + if (m.getFrequency() > oldDisplayMode.getFrequency()) continue; + if (m.getHeight() < 240 || m.getWidth() < 320) continue; + + int j = 0; + java.awt.DisplayMode ml = null; + for (j = 0; j < l.size(); j++) { + ml = (java.awt.DisplayMode)l.get(j); + if (ml.getWidth() > m.getWidth()) break; + if (ml.getWidth() == m.getWidth() && ml.getHeight() >= m.getHeight()) break; + } + if (j == l.size()) { + l.addLast(toAwtDisplayMode(m)); + } else if (ml.getWidth() > m.getWidth() || ml.getHeight() > m.getHeight()) { + l.add(j, toAwtDisplayMode(m)); + } else if (m.getFrequency() > ml.getRefreshRate()){ + l.remove(j); + l.add(j, toAwtDisplayMode(m)); + } + } + java.awt.DisplayMode[] ma = new java.awt.DisplayMode[l.size()]; + l.toArray(ma); + return ma; + } catch (LWJGLException e) { + e.printStackTrace(); + System.exit(0); + } + return null; + } + + public DisplayMode[] getLWJGLModeList() { + try { + // Return value storage. + ArrayList displayModes; + + // Get all possible display modes. + DisplayMode[] allDisplayModes = Display.getAvailableDisplayModes(); + + // Cut down all the ones with a height below 240. + displayModes = new ArrayList(); + for (int x = 0; x < allDisplayModes.length; x++) { + if (allDisplayModes[x].getHeight() >= 240) + displayModes.add(allDisplayModes[x]); + } + + // Gnome sort the display modes by height, width, and refresh rate. + int currentSpot = 0; + boolean needSwap = false; + DisplayMode tempStore; + while (currentSpot < displayModes.size() - 1) { + // Check DisplayMode heights. + if (displayModes.get(currentSpot).getHeight() > displayModes.get(currentSpot + 1).getHeight()) + needSwap = true; + else if (displayModes.get(currentSpot).getHeight() == displayModes.get(currentSpot + 1).getHeight()) { + // Check DisplayMode widths. + if (displayModes.get(currentSpot).getWidth() > displayModes.get(currentSpot + 1).getWidth()) + needSwap = true; + else if (displayModes.get(currentSpot).getWidth() == displayModes.get(currentSpot + 1).getWidth()) + // Doesn't sort frequencies, but removes the lesser ones entirely. + if (displayModes.get(currentSpot).getFrequency() < displayModes.get(currentSpot + 1).getFrequency()) { + displayModes.remove(currentSpot); + currentSpot--; + } + else if (displayModes.get(currentSpot).getFrequency() > displayModes.get(currentSpot + 1).getFrequency()) { + displayModes.remove(currentSpot + 1); + currentSpot--; + } + } + if (needSwap) { + needSwap = false; + tempStore = displayModes.get(currentSpot); + displayModes.set(currentSpot, displayModes.get(currentSpot + 1)); + displayModes.set(currentSpot + 1, tempStore); + if (currentSpot > 0) + currentSpot--; + } + else + currentSpot++; + } + + // Return the array. + return displayModes.toArray(new DisplayMode[displayModes.size()]); + + } catch (LWJGLException e) { + e.printStackTrace(); + System.exit(0); + } + return null; + } + + private DisplayMode findDisplayMode(Dimension dim) { + DisplayMode mode = null; + DisplayMode m = null; + DisplayMode[] modes = getLWJGLModeList(); + int w = dim.width; + int h = dim.height; + + for (int i = 0; i < modes.length; i++) { + m = modes[i]; + if (m.getWidth() == w && m.getHeight() == h) { + mode = m; + break; + } + } + if (mode == null) mode = oldDisplayMode; + return mode; + } + + String getModeString(DisplayMode m) { + StringBuffer sb = new StringBuffer(); + sb.append(m.getWidth()); + sb.append('x'); + sb.append(m.getHeight()); + sb.append('x'); + sb.append(m.getBitsPerPixel()); + sb.append('@'); + sb.append(m.getFrequency()); + sb.append("Hz"); + return sb.toString(); + } - /** - * @param dim - * @param mode - * @param fullscreen - * @return enum rserr_t - */ - protected int GLimp_SetMode(Dimension dim, int mode, boolean fullscreen) { + /** + * @param dim + * @param mode + * @param fullscreen + * @return enum rserr_t + */ + protected int GLimp_SetMode(Dimension dim, int mode, boolean fullscreen) { - Dimension newDim = new Dimension(); + Dimension newDim = new Dimension(); - log.info("Initializing OpenGL display"); + log.info("Initializing OpenGL display"); - /* - * fullscreen handling - */ - if (oldDisplayMode == null) { - oldDisplayMode = Display.getDisplayMode(); - } + /* + * fullscreen handling + */ + if (oldDisplayMode == null) { + oldDisplayMode = Display.getDisplayMode(); + } - if (!VID.GetModeInfo(newDim, mode)) { - log.warn("...setting mode {}: invalid mode", mode); - return rserr_invalid_mode; - } + if (!VID.GetModeInfo(newDim, mode)) { + log.warn("...setting mode {}: invalid mode", mode); + return rserr_invalid_mode; + } - log.info("...setting mode {}: {} {}", mode, newDim.width, newDim.height); + log.info("...setting mode {}: {} {}", mode, newDim.width, newDim.height); - // destroy the existing window - GLimp_Shutdown(); + // destroy the existing window + GLimp_Shutdown(); - Display.setTitle("LWJake2"); + Display.setTitle("LWJake2"); - DisplayMode displayMode = findDisplayMode(newDim); - newDim.width = displayMode.getWidth(); - newDim.height = displayMode.getHeight(); - - if (fullscreen) - { - try { - Display.setDisplayMode(displayMode); - } - catch (LWJGLException e) - { - return rserr_invalid_mode; - } - - Display.setLocation(0,0); + DisplayMode displayMode = findDisplayMode(newDim); + newDim.width = displayMode.getWidth(); + newDim.height = displayMode.getHeight(); + + if (fullscreen) + { + try { + Display.setDisplayMode(displayMode); + } + catch (LWJGLException e) + { + return rserr_invalid_mode; + } + + Display.setLocation(0,0); - try { - Display.setFullscreen(true); - } - catch (LWJGLException e) - { - return rserr_invalid_fullscreen; - } + try { + Display.setFullscreen(true); + } + catch (LWJGLException e) + { + return rserr_invalid_fullscreen; + } - log.info("...setting fullscreen {}", getModeString(displayMode)); + log.info("...setting fullscreen {}", getModeString(displayMode)); - } - else - { - try { - Display.setFullscreen(false); - } - catch (LWJGLException e) - { - return rserr_invalid_fullscreen; - } - - try - { - Display.setDisplayMode(displayMode); - } - catch (LWJGLException e) - { - return rserr_invalid_mode; - } - Display.setLocation(window_xpos, window_ypos); - } + } + else + { + try { + Display.setFullscreen(false); + } + catch (LWJGLException e) + { + return rserr_invalid_fullscreen; + } + + try + { + Display.setDisplayMode(displayMode); + } + catch (LWJGLException e) + { + return rserr_invalid_mode; + } + Display.setLocation(window_xpos, window_ypos); + } - vid.width = newDim.width; - vid.height = newDim.height; - - try - { - Display.create(); - } - catch (LWJGLException e) - { - return rserr_unknown; - } - - // let the sound and input subsystems know about the new window - VID.NewWindow(vid.width, vid.height); - return rserr_ok; - } + vid.width = newDim.width; + vid.height = newDim.height; + + try + { + Display.create(); + } + catch (LWJGLException e) + { + return rserr_unknown; + } + + // let the sound and input subsystems know about the new window + VID.NewWindow(vid.width, vid.height); + return rserr_ok; + } - protected void GLimp_Shutdown() { - if (oldDisplayMode != null && Display.isFullscreen()) { - try { - Display.setDisplayMode(oldDisplayMode); - } catch (Exception e) { - e.printStackTrace(); - } - } - - while (Display.isCreated()) { - Display.destroy(); - } - } + protected void GLimp_Shutdown() { + if (oldDisplayMode != null && Display.isFullscreen()) { + try { + Display.setDisplayMode(oldDisplayMode); + } catch (Exception e) { + e.printStackTrace(); + } + } + + while (Display.isCreated()) { + Display.destroy(); + } + } - /** - * @return true - */ - protected boolean GLimp_Init(int xpos, int ypos) { - // do nothing - window_xpos = xpos; - window_ypos = ypos; - return true; - } + /** + * @return true + */ + protected boolean GLimp_Init(int xpos, int ypos) { + // do nothing + window_xpos = xpos; + window_ypos = ypos; + return true; + } - protected void GLimp_EndFrame() { - GL11.glFlush(); - // swap buffers - Display.update(); - } + protected void GLimp_EndFrame() { + GL11.glFlush(); + // swap buffers + Display.update(); + } - protected void GLimp_BeginFrame(float camera_separation) { - // do nothing - } + protected void GLimp_BeginFrame(float camera_separation) { + // do nothing + } - protected void GLimp_AppActivate(boolean activate) { - // do nothing - } + protected void GLimp_AppActivate(boolean activate) { + // do nothing + } - protected void GLimp_EnableLogging(boolean enable) { - // do nothing - } + protected void GLimp_EnableLogging(boolean enable) { + // do nothing + } - protected void GLimp_LogNewFrame() { - // do nothing - } + protected void GLimp_LogNewFrame() { + // do nothing + } - /** - * this is a hack for jogl renderers. - * @param callback - */ - public final void updateScreen(Runnable callback) { - callback.run(); - } + /** + * this is a hack for jogl renderers. + * @param callback + */ + public final void updateScreen(Runnable callback) { + callback.run(); + } } diff --git a/src/main/java/lwjake2/render/lwjgl/Light.java b/src/main/java/lwjake2/render/lwjgl/Light.java index feb2580..a3bea9c 100644 --- a/src/main/java/lwjake2/render/lwjgl/Light.java +++ b/src/main/java/lwjake2/render/lwjgl/Light.java @@ -41,438 +41,438 @@ import org.lwjgl.opengl.GL11; * @author cwei */ public abstract class Light extends Warp { - // r_light.c + // r_light.c - int r_dlightframecount; + int r_dlightframecount; - static final int DLIGHT_CUTOFF = 64; + static final int DLIGHT_CUTOFF = 64; - /* - ============================================================================= + /* + ============================================================================= - DYNAMIC LIGHTS BLEND RENDERING + DYNAMIC LIGHTS BLEND RENDERING - ============================================================================= - */ + ============================================================================= + */ - // stack variable - private final float[] v = {0, 0, 0}; - /** - * R_RenderDlight - */ - void R_RenderDlight(dlight_t light) - { - float rad = light.intensity * 0.35f; + // stack variable + private final float[] v = {0, 0, 0}; + /** + * R_RenderDlight + */ + void R_RenderDlight(dlight_t light) + { + float rad = light.intensity * 0.35f; - Math3D.VectorSubtract (light.origin, r_origin, v); + Math3D.VectorSubtract (light.origin, r_origin, v); - GL11.glBegin (GL11.GL_TRIANGLE_FAN); - GL11.glColor3f (light.color[0]*0.2f, light.color[1]*0.2f, light.color[2]*0.2f); - int i; - for (i=0 ; i<3 ; i++) - v[i] = light.origin[i] - vpn[i]*rad; - - GL11.glVertex3f(v[0], v[1], v[2]); - GL11.glColor3f (0,0,0); + GL11.glBegin (GL11.GL_TRIANGLE_FAN); + GL11.glColor3f (light.color[0]*0.2f, light.color[1]*0.2f, light.color[2]*0.2f); + int i; + for (i=0 ; i<3 ; i++) + v[i] = light.origin[i] - vpn[i]*rad; + + GL11.glVertex3f(v[0], v[1], v[2]); + GL11.glColor3f (0,0,0); - int j; - float a; - for (i=16 ; i>=0 ; i--) - { - a = (float)(i/16.0f * Math.PI*2); - for (j=0 ; j<3 ; j++) - v[j] = (float)(light.origin[j] + vright[j]*Math.cos(a)*rad - + vup[j]*Math.sin(a)*rad); - GL11.glVertex3f(v[0], v[1], v[2]); - } - GL11.glEnd (); - } + int j; + float a; + for (i=16 ; i>=0 ; i--) + { + a = (float)(i/16.0f * Math.PI*2); + for (j=0 ; j<3 ; j++) + v[j] = (float)(light.origin[j] + vright[j]*Math.cos(a)*rad + + vup[j]*Math.sin(a)*rad); + GL11.glVertex3f(v[0], v[1], v[2]); + } + GL11.glEnd (); + } - /** - * R_RenderDlights - */ - void R_RenderDlights() - { - if (gl_flashblend.value == 0) - return; + /** + * R_RenderDlights + */ + void R_RenderDlights() + { + if (gl_flashblend.value == 0) + return; - r_dlightframecount = r_framecount + 1; // because the count hasn't - // advanced yet for this frame - GL11.glDepthMask(false); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glShadeModel (GL11.GL_SMOOTH); - GL11.glEnable (GL11.GL_BLEND); - GL11.glBlendFunc (GL11.GL_ONE, GL11.GL_ONE); + r_dlightframecount = r_framecount + 1; // because the count hasn't + // advanced yet for this frame + GL11.glDepthMask(false); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel (GL11.GL_SMOOTH); + GL11.glEnable (GL11.GL_BLEND); + GL11.glBlendFunc (GL11.GL_ONE, GL11.GL_ONE); - for (int i=0 ; i light.intensity - DLIGHT_CUTOFF) - { - R_MarkLights (light, bit, node.children[0]); - return; - } - if (dist < -light.intensity + DLIGHT_CUTOFF) - { - R_MarkLights (light, bit, node.children[1]); - return; - } + cplane_t splitplane = node.plane; + float dist = Math3D.DotProduct (light.origin, splitplane.normal) - splitplane.dist; + + if (dist > light.intensity - DLIGHT_CUTOFF) + { + R_MarkLights (light, bit, node.children[0]); + return; + } + if (dist < -light.intensity + DLIGHT_CUTOFF) + { + R_MarkLights (light, bit, node.children[1]); + return; + } - // mark the polygons - msurface_t surf; - int sidebit; - for (int i=0 ; i= 0) ? 0 : Defines.SURF_PLANEBACK; - if ( (surf.flags & Defines.SURF_PLANEBACK) != sidebit ) - continue; - /* - * cwei - * bugfix end - */ + /* + * cwei + * bugfix for dlight behind the walls + */ + dist = Math3D.DotProduct (light.origin, surf.plane.normal) - surf.plane.dist; + sidebit = (dist >= 0) ? 0 : Defines.SURF_PLANEBACK; + if ( (surf.flags & Defines.SURF_PLANEBACK) != sidebit ) + continue; + /* + * cwei + * bugfix end + */ - if (surf.dlightframe != r_dlightframecount) - { - surf.dlightbits = 0; - surf.dlightframe = r_dlightframecount; - } - surf.dlightbits |= bit; - } + if (surf.dlightframe != r_dlightframecount) + { + surf.dlightbits = 0; + surf.dlightframe = r_dlightframecount; + } + surf.dlightbits |= bit; + } - R_MarkLights (light, bit, node.children[0]); - R_MarkLights (light, bit, node.children[1]); - } + R_MarkLights (light, bit, node.children[0]); + R_MarkLights (light, bit, node.children[1]); + } - /** - * R_PushDlights - */ - void R_PushDlights() - { - if (gl_flashblend.value != 0) - return; + /** + * R_PushDlights + */ + void R_PushDlights() + { + if (gl_flashblend.value != 0) + return; - r_dlightframecount = r_framecount + 1; // because the count hasn't - // advanced yet for this frame - dlight_t l; - for (int i=0 ; i= 0) { - Vec3Cache.release(); // mid - return r; // hit something - } - - if ( (back < 0) == side ) { - Vec3Cache.release(); // mid - return -1; // didn't hit anuthing - } - - // check for impact on this node - Math3D.VectorCopy (mid, lightspot); - lightplane = plane; - int surfIndex = node.firstsurface; + // FIXME: optimize for axial + cplane_t plane = node.plane; + float front = Math3D.DotProduct (start, plane.normal) - plane.dist; + float back = Math3D.DotProduct (end, plane.normal) - plane.dist; + boolean side = (front < 0); + int sideIndex = (side) ? 1 : 0; + + if ( (back < 0) == side) + return RecursiveLightPoint (node.children[sideIndex], start, end); + + float frac = front / (front-back); + float[] mid = Vec3Cache.get(); + mid[0] = start[0] + (end[0] - start[0])*frac; + mid[1] = start[1] + (end[1] - start[1])*frac; + mid[2] = start[2] + (end[2] - start[2])*frac; + + // go down front side + int r = RecursiveLightPoint (node.children[sideIndex], start, mid); + if (r >= 0) { + Vec3Cache.release(); // mid + return r; // hit something + } + + if ( (back < 0) == side ) { + Vec3Cache.release(); // mid + return -1; // didn't hit anuthing + } + + // check for impact on this node + Math3D.VectorCopy (mid, lightspot); + lightplane = plane; + int surfIndex = node.firstsurface; - msurface_t surf; - int s, t, ds, dt; - mtexinfo_t tex; - ByteBuffer lightmap; - int maps; - for (int i=0 ; i surf.extents[0] || dt > surf.extents[1] ) - continue; + if (s < surf.texturemins[0] || t < surf.texturemins[1]) + continue; + + ds = s - surf.texturemins[0]; + dt = t - surf.texturemins[1]; + + if ( ds > surf.extents[0] || dt > surf.extents[1] ) + continue; - if (surf.samples == null) - return 0; + if (surf.samples == null) + return 0; - ds >>= 4; - dt >>= 4; + ds >>= 4; + dt >>= 4; - lightmap = surf.samples; - int lightmapIndex = 0; + lightmap = surf.samples; + int lightmapIndex = 0; - Math3D.VectorCopy (Globals.vec3_origin, pointcolor); - if (lightmap != null) - { - float[] rgb; - lightmapIndex += 3 * (dt * ((surf.extents[0] >> 4) + 1) + ds); + Math3D.VectorCopy (Globals.vec3_origin, pointcolor); + if (lightmap != null) + { + float[] rgb; + lightmapIndex += 3 * (dt * ((surf.extents[0] >> 4) + 1) + ds); - float scale0, scale1, scale2; - for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255; maps++) - { - rgb = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb; - scale0 = gl_modulate.value * rgb[0]; - scale1 = gl_modulate.value * rgb[1]; - scale2 = gl_modulate.value * rgb[2]; + float scale0, scale1, scale2; + for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255; maps++) + { + rgb = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb; + scale0 = gl_modulate.value * rgb[0]; + scale1 = gl_modulate.value * rgb[1]; + scale2 = gl_modulate.value * rgb[2]; - pointcolor[0] += (lightmap.get(lightmapIndex + 0) & 0xFF) * scale0 * (1.0f/255); - pointcolor[1] += (lightmap.get(lightmapIndex + 1) & 0xFF) * scale1 * (1.0f/255); - pointcolor[2] += (lightmap.get(lightmapIndex + 2) & 0xFF) * scale2 * (1.0f/255); - lightmapIndex += 3 * ((surf.extents[0] >> 4) + 1) * ((surf.extents[1] >> 4) + 1); - } - } - Vec3Cache.release(); // mid - return 1; - } + pointcolor[0] += (lightmap.get(lightmapIndex + 0) & 0xFF) * scale0 * (1.0f/255); + pointcolor[1] += (lightmap.get(lightmapIndex + 1) & 0xFF) * scale1 * (1.0f/255); + pointcolor[2] += (lightmap.get(lightmapIndex + 2) & 0xFF) * scale2 * (1.0f/255); + lightmapIndex += 3 * ((surf.extents[0] >> 4) + 1) * ((surf.extents[1] >> 4) + 1); + } + } + Vec3Cache.release(); // mid + return 1; + } - // go down back side - r = RecursiveLightPoint (node.children[1 - sideIndex], mid, end); - Vec3Cache.release(); // mid - return r; - } + // go down back side + r = RecursiveLightPoint (node.children[1 - sideIndex], mid, end); + Vec3Cache.release(); // mid + return r; + } - // stack variable - private final float[] end = {0, 0, 0}; - /** - * R_LightPoint - */ - void R_LightPoint (float[] p, float[] color) - { - assert (p.length == 3) : "vec3_t bug"; - assert (color.length == 3) : "rgb bug"; + // stack variable + private final float[] end = {0, 0, 0}; + /** + * R_LightPoint + */ + void R_LightPoint (float[] p, float[] color) + { + assert (p.length == 3) : "vec3_t bug"; + assert (color.length == 3) : "rgb bug"; - if (r_worldmodel.lightdata == null) - { - color[0] = color[1] = color[2] = 1.0f; - return; - } - - end[0] = p[0]; - end[1] = p[1]; - end[2] = p[2] - 2048; - - float r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end); - - if (r == -1) - { - Math3D.VectorCopy (Globals.vec3_origin, color); - } - else - { - Math3D.VectorCopy (pointcolor, color); - } + if (r_worldmodel.lightdata == null) + { + color[0] = color[1] = color[2] = 1.0f; + return; + } + + end[0] = p[0]; + end[1] = p[1]; + end[2] = p[2] - 2048; + + float r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end); + + if (r == -1) + { + Math3D.VectorCopy (Globals.vec3_origin, color); + } + else + { + Math3D.VectorCopy (pointcolor, color); + } - // - // add dynamic lights - // - dlight_t dl; - float add; - for (int lnum=0 ; lnum 0) - { - Math3D.VectorMA (color, add, dl.color, color); - } - } - Math3D.VectorScale (color, gl_modulate.value, color); - } + // + // add dynamic lights + // + dlight_t dl; + float add; + for (int lnum=0 ; lnum 0) + { + Math3D.VectorMA (color, add, dl.color, color); + } + } + Math3D.VectorScale (color, gl_modulate.value, color); + } -// =================================================================== +// =================================================================== - float[] s_blocklights = new float[34 * 34 * 3]; - + float[] s_blocklights = new float[34 * 34 * 3]; + // TODO sync with jogl renderer. hoz - private final float[] impact = {0, 0, 0}; - /** - * R_AddDynamicLights - */ - void R_AddDynamicLights(msurface_t surf) - { - int sd, td; - float fdist, frad, fminlight; - int s, t; - dlight_t dl; - float[] pfBL; - float fsacc, ftacc; + private final float[] impact = {0, 0, 0}; + /** + * R_AddDynamicLights + */ + void R_AddDynamicLights(msurface_t surf) + { + int sd, td; + float fdist, frad, fminlight; + int s, t; + dlight_t dl; + float[] pfBL; + float fsacc, ftacc; - int smax = (surf.extents[0]>>4)+1; - int tmax = (surf.extents[1]>>4)+1; - mtexinfo_t tex = surf.texinfo; + int smax = (surf.extents[0]>>4)+1; + int tmax = (surf.extents[1]>>4)+1; + mtexinfo_t tex = surf.texinfo; - float local0, local1; - for (int lnum=0 ; lnum td) - fdist = sd + (td>>1); - else - fdist = td + (sd>>1); + if (sd > td) + fdist = sd + (td>>1); + else + fdist = td + (sd>>1); - if ( fdist < fminlight ) - { - pfBL[pfBLindex + 0] += ( frad - fdist ) * dl.color[0]; - pfBL[pfBLindex + 1] += ( frad - fdist ) * dl.color[1]; - pfBL[pfBLindex + 2] += ( frad - fdist ) * dl.color[2]; - } - } - } - } - } + if ( fdist < fminlight ) + { + pfBL[pfBLindex + 0] += ( frad - fdist ) * dl.color[0]; + pfBL[pfBLindex + 1] += ( frad - fdist ) * dl.color[1]; + pfBL[pfBLindex + 2] += ( frad - fdist ) * dl.color[2]; + } + } + } + } + } - /** - * R_SetCacheState - */ - void R_SetCacheState( msurface_t surf ) - { - for (int maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255 ; maps++) - { - surf.cached_light[maps] = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].white; - } - } - - private Throwable gotoStore = new Throwable(); + /** + * R_SetCacheState + */ + void R_SetCacheState( msurface_t surf ) + { + for (int maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255 ; maps++) + { + surf.cached_light[maps] = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].white; + } + } + + private Throwable gotoStore = new Throwable(); -// TODO sync with jogl renderer. hoz - /** - * R_BuildLightMap - * - * Combine and scale multiple lightmaps into the floating format in blocklights - */ - void R_BuildLightMap(msurface_t surf, IntBuffer dest, int stride) - { +// TODO sync with jogl renderer. hoz + /** + * R_BuildLightMap + * + * Combine and scale multiple lightmaps into the floating format in blocklights + */ + void R_BuildLightMap(msurface_t surf, IntBuffer dest, int stride) + { int r, g, b, a, max; int i, j; int nummaps; @@ -499,11 +499,11 @@ public abstract class Light extends Warp { s_blocklights[i] = 255; // TODO useless? hoz - // for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && + // for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && // surf.styles[maps] != (byte)255; maps++) - // { - // style = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF]; - // } + // { + // style = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF]; + // } // goto store; throw gotoStore; @@ -558,7 +558,7 @@ public abstract class Light extends Warp { } else { int maps; - // memset( s_blocklights, 0, sizeof( s_blocklights[0] ) * size * + // memset( s_blocklights, 0, sizeof( s_blocklights[0] ) * size * // 3 ); Arrays.fill(s_blocklights, 0, size * 3, 0.0f); diff --git a/src/main/java/lwjake2/render/lwjgl/Main.java b/src/main/java/lwjake2/render/lwjgl/Main.java index 40e4017..4aacbad 100644 --- a/src/main/java/lwjake2/render/lwjgl/Main.java +++ b/src/main/java/lwjake2/render/lwjgl/Main.java @@ -55,1458 +55,1458 @@ import org.lwjgl.opengl.GL13; */ @Slf4j public abstract class Main extends Base { - public static int[] d_8to24table = new int[256]; - - int c_visible_lightmaps; - int c_visible_textures; - - int registration_sequence; + public static int[] d_8to24table = new int[256]; + + int c_visible_lightmaps; + int c_visible_textures; + + int registration_sequence; - // this a hack for function pointer test - // default disabled - boolean qglColorTableEXT = false; - boolean qglActiveTextureARB = false; - boolean qglPointParameterfEXT = false; - boolean qglLockArraysEXT = false; - boolean qwglSwapIntervalEXT = false; - - // ================= - // abstract methods - // ================= - protected abstract void Draw_GetPalette(); - - abstract void GL_ImageList_f(); - abstract void GL_ScreenShot_f(); - abstract void GL_SetTexturePalette(int[] palette); - abstract void GL_Strings_f(); - - abstract void Mod_Modellist_f(); - abstract mleaf_t Mod_PointInLeaf(float[] point, model_t model); - - abstract void GL_SetDefaultState(); - - abstract void GL_InitImages(); - abstract void Mod_Init(); // Model.java - abstract void R_InitParticleTexture(); // MIsc.java - abstract void R_DrawAliasModel(entity_t e); // Mesh.java - abstract void R_DrawBrushModel(entity_t e); // Surf.java - abstract void Draw_InitLocal(); - abstract void R_LightPoint(float[] p, float[] color); - abstract void R_PushDlights(); - abstract void R_MarkLeaves(); - abstract void R_DrawWorld(); - abstract void R_RenderDlights(); - abstract void R_DrawAlphaSurfaces(); - - abstract void Mod_FreeAll(); - - abstract void GL_ShutdownImages(); - abstract void GL_Bind(int texnum); - abstract void GL_TexEnv(int mode); - abstract void GL_TextureMode(String string); - abstract void GL_TextureAlphaMode(String string); - abstract void GL_TextureSolidMode(String string); - abstract void GL_UpdateSwapInterval(); - - /* - ==================================================================== - - from gl_rmain.c - - ==================================================================== - */ - - int GL_TEXTURE0 = GL13.GL_TEXTURE0; - int GL_TEXTURE1 = GL13.GL_TEXTURE1; - - model_t r_worldmodel; - - float gldepthmin, gldepthmax; - - glconfig_t gl_config = new glconfig_t(); - glstate_t gl_state = new glstate_t(); - - image_t r_notexture; // use for bad textures - image_t r_particletexture; // little dot for particles - - entity_t currententity; - model_t currentmodel; - - cplane_t frustum[] = { new cplane_t(), new cplane_t(), new cplane_t(), new cplane_t()}; - - int r_visframecount; // bumped when going to a new PVS - int r_framecount; // used for dlight push checking - - int c_brush_polys, c_alias_polys; - - float v_blend[] = { 0, 0, 0, 0 }; // final blending color - - // - // view origin - // - float[] vup = { 0, 0, 0 }; - float[] vpn = { 0, 0, 0 }; - float[] vright = { 0, 0, 0 }; - float[] r_origin = { 0, 0, 0 }; - - //float r_world_matrix[] = new float[16]; - FloatBuffer r_world_matrix=BufferUtils.createFloatBuffer(16); - - float r_base_world_matrix[] = new float[16]; - - // - // screen size info - // - refdef_t r_newrefdef = new refdef_t(); - - int r_viewcluster, r_viewcluster2, r_oldviewcluster, r_oldviewcluster2; - - cvar_t r_norefresh; - cvar_t r_drawentities; - cvar_t r_drawworld; - cvar_t r_speeds; - cvar_t r_fullbright; - cvar_t r_novis; - cvar_t r_nocull; - cvar_t r_lerpmodels; - cvar_t r_lefthand; - - cvar_t r_lightlevel; - // FIXME: This is a HACK to get the client's light level - - cvar_t gl_nosubimage; - cvar_t gl_allow_software; - - cvar_t gl_vertex_arrays; - - cvar_t gl_particle_min_size; - cvar_t gl_particle_max_size; - cvar_t gl_particle_size; - cvar_t gl_particle_att_a; - cvar_t gl_particle_att_b; - cvar_t gl_particle_att_c; - - cvar_t gl_ext_swapinterval; - cvar_t gl_ext_palettedtexture; - cvar_t gl_ext_multitexture; - cvar_t gl_ext_pointparameters; - cvar_t gl_ext_compiled_vertex_array; - - cvar_t gl_log; - cvar_t gl_bitdepth; - cvar_t gl_drawbuffer; - cvar_t gl_driver; - cvar_t gl_lightmap; - cvar_t gl_shadows; - cvar_t gl_mode; - cvar_t gl_dynamic; - cvar_t gl_monolightmap; - cvar_t gl_modulate; - cvar_t gl_nobind; - cvar_t gl_round_down; - cvar_t gl_picmip; - cvar_t gl_skymip; - cvar_t gl_showtris; - cvar_t gl_ztrick; - cvar_t gl_finish; - cvar_t gl_clear; - cvar_t gl_cull; - cvar_t gl_polyblend; - cvar_t gl_flashblend; - cvar_t gl_playermip; - cvar_t gl_saturatelighting; - cvar_t gl_swapinterval; - cvar_t gl_texturemode; - cvar_t gl_texturealphamode; - cvar_t gl_texturesolidmode; - cvar_t gl_lockpvs; - - cvar_t gl_3dlabs_broken; - - cvar_t vid_gamma; - cvar_t vid_ref; - - // ============================================================================ - // to port from gl_rmain.c, ... - // ============================================================================ - - /** - * R_CullBox - * Returns true if the box is completely outside the frustum - */ - final boolean R_CullBox(float[] mins, float[] maxs) { - assert(mins.length == 3 && maxs.length == 3) : "vec3_t bug"; - - if (r_nocull.value != 0) - return false; - - for (int i = 0; i < 4; i++) { - if (Math3D.BoxOnPlaneSide(mins, maxs, frustum[i]) == 2) - return true; - } - return false; - } - - /** - * R_RotateForEntity - */ - final void R_RotateForEntity(entity_t e) { - GL11.glTranslatef(e.origin[0], e.origin[1], e.origin[2]); - - GL11.glRotatef(e.angles[1], 0, 0, 1); - GL11.glRotatef(-e.angles[0], 0, 1, 0); - GL11.glRotatef(-e.angles[2], 1, 0, 0); - } - - /* - ============================================================= - - SPRITE MODELS - - ============================================================= - */ - - // stack variable - private final float[] point = { 0, 0, 0 }; - /** - * R_DrawSpriteModel - */ - void R_DrawSpriteModel(entity_t e) { - float alpha = 1.0F; - - qfiles.dsprframe_t frame; - qfiles.dsprite_t psprite; - - // don't even bother culling, because it's just a single - // polygon without a surface cache - - psprite = (qfiles.dsprite_t) currentmodel.extradata; - - e.frame %= psprite.numframes; - - frame = psprite.frames[e.frame]; - - if ((e.flags & Defines.RF_TRANSLUCENT) != 0) - alpha = e.alpha; - - if (alpha != 1.0F) - GL11.glEnable(GL11.GL_BLEND); - - GL11.glColor4f(1, 1, 1, alpha); - - GL_Bind(currentmodel.skins[e.frame].texnum); - - GL_TexEnv(GL11.GL_MODULATE); - - if (alpha == 1.0) - GL11.glEnable(GL11.GL_ALPHA_TEST); - else - GL11.glDisable(GL11.GL_ALPHA_TEST); - - GL11.glBegin(GL11.GL_QUADS); - - GL11.glTexCoord2f(0, 1); - Math3D.VectorMA(e.origin, -frame.origin_y, vup, point); - Math3D.VectorMA(point, -frame.origin_x, vright, point); - GL11.glVertex3f(point[0], point[1], point[2]); - - GL11.glTexCoord2f(0, 0); - Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point); - Math3D.VectorMA(point, -frame.origin_x, vright, point); - GL11.glVertex3f(point[0], point[1], point[2]); - - GL11.glTexCoord2f(1, 0); - Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point); - Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point); - GL11.glVertex3f(point[0], point[1], point[2]); - - GL11.glTexCoord2f(1, 1); - Math3D.VectorMA(e.origin, -frame.origin_y, vup, point); - Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point); - GL11.glVertex3f(point[0], point[1], point[2]); - - GL11.glEnd(); - - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL_TexEnv(GL11.GL_REPLACE); - - if (alpha != 1.0F) - GL11.glDisable(GL11.GL_BLEND); - - GL11.glColor4f(1, 1, 1, 1); - } - - // ================================================================================== - - // stack variable - private final float[] shadelight = { 0, 0, 0 }; - /** - * R_DrawNullModel - */ - void R_DrawNullModel() { - if ((currententity.flags & Defines.RF_FULLBRIGHT) != 0) { - // cwei wollte blau: shadelight[0] = shadelight[1] = shadelight[2] = 1.0F; - shadelight[0] = shadelight[1] = shadelight[2] = 0.0F; - shadelight[2] = 0.8F; - } - else { - R_LightPoint(currententity.origin, shadelight); - } - - GL11.glPushMatrix(); - R_RotateForEntity(currententity); - - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glColor3f(shadelight[0], shadelight[1], shadelight[2]); - - // this replaces the TRIANGLE_FAN - //glut.glutWireCube(gl, 20); - - GL11.glBegin(GL11.GL_TRIANGLE_FAN); - GL11.glVertex3f(0, 0, -16); - int i; - for (i=0 ; i<=4 ; i++) { - GL11.glVertex3f((float)(16.0f * Math.cos(i * Math.PI / 2)), (float)(16.0f * Math.sin(i * Math.PI / 2)), 0.0f); - } - GL11.glEnd(); - - GL11.glBegin(GL11.GL_TRIANGLE_FAN); - GL11.glVertex3f (0, 0, 16); - for (i=4 ; i>=0 ; i--) { - GL11.glVertex3f((float)(16.0f * Math.cos(i * Math.PI / 2)), (float)(16.0f * Math.sin(i * Math.PI / 2)), 0.0f); - } - GL11.glEnd(); - - - GL11.glColor3f(1, 1, 1); - GL11.glPopMatrix(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } - - /** - * R_DrawEntitiesOnList - */ - void R_DrawEntitiesOnList() { - if (r_drawentities.value == 0.0f) - return; - - // draw non-transparent first - int i; - for (i = 0; i < r_newrefdef.num_entities; i++) { - currententity = r_newrefdef.entities[i]; - if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) - continue; // solid - - if ((currententity.flags & Defines.RF_BEAM) != 0) { - R_DrawBeam(currententity); - } - else { - currentmodel = currententity.model; - if (currentmodel == null) { - R_DrawNullModel(); - continue; - } - switch (currentmodel.type) { - case mod_alias : - R_DrawAliasModel(currententity); - break; - case mod_brush : - R_DrawBrushModel(currententity); - break; - case mod_sprite : - R_DrawSpriteModel(currententity); - break; - default : - Com.Error(Defines.ERR_DROP, "Bad modeltype"); - break; - } - } - } - // draw transparent entities - // we could sort these if it ever becomes a problem... - GL11.glDepthMask(false); // no z writes - for (i = 0; i < r_newrefdef.num_entities; i++) { - currententity = r_newrefdef.entities[i]; - if ((currententity.flags & Defines.RF_TRANSLUCENT) == 0) - continue; // solid - - if ((currententity.flags & Defines.RF_BEAM) != 0) { - R_DrawBeam(currententity); - } - else { - currentmodel = currententity.model; - - if (currentmodel == null) { - R_DrawNullModel(); - continue; - } - switch (currentmodel.type) { - case mod_alias : - R_DrawAliasModel(currententity); - break; - case mod_brush : - R_DrawBrushModel(currententity); - break; - case mod_sprite : - R_DrawSpriteModel(currententity); - break; - default : - Com.Error(Defines.ERR_DROP, "Bad modeltype"); - break; - } - } - } - GL11.glDepthMask(true); // back to writing - } - - // stack variable - private final float[] up = { 0, 0, 0 }; - private final float[] right = { 0, 0, 0 }; - /** - * GL_DrawParticles - */ - void GL_DrawParticles(int num_particles) { - float origin_x, origin_y, origin_z; - - Math3D.VectorScale(vup, 1.5f, up); - Math3D.VectorScale(vright, 1.5f, right); - - GL_Bind(r_particletexture.texnum); - GL11.glDepthMask(false); // no z buffering - GL11.glEnable(GL11.GL_BLEND); - GL_TexEnv(GL11.GL_MODULATE); - - GL11.glBegin(GL11.GL_TRIANGLES); - - FloatBuffer sourceVertices = particle_t.vertexArray; - IntBuffer sourceColors = particle_t.colorArray; - float scale; - int color; - for (int j = 0, i = 0; i < num_particles; i++) { - origin_x = sourceVertices.get(j++); - origin_y = sourceVertices.get(j++); - origin_z = sourceVertices.get(j++); - - // hack a scale up to keep particles from disapearing - scale = - (origin_x - r_origin[0]) * vpn[0] - + (origin_y - r_origin[1]) * vpn[1] - + (origin_z - r_origin[2]) * vpn[2]; - - scale = (scale < 20) ? 1 : 1 + scale * 0.004f; - - color = sourceColors.get(i); - - GL11.glColor4ub( - (byte)((color) & 0xFF), - (byte)((color >> 8) & 0xFF), - (byte)((color >> 16) & 0xFF), - (byte)((color >>> 24)) - ); - // first vertex - GL11.glTexCoord2f(0.0625f, 0.0625f); - GL11.glVertex3f(origin_x, origin_y, origin_z); - // second vertex - GL11.glTexCoord2f(1.0625f, 0.0625f); - GL11.glVertex3f(origin_x + up[0] * scale, origin_y + up[1] * scale, origin_z + up[2] * scale); - // third vertex - GL11.glTexCoord2f(0.0625f, 1.0625f); - GL11.glVertex3f(origin_x + right[0] * scale, origin_y + right[1] * scale, origin_z + right[2] * scale); - } - GL11.glEnd(); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glColor4f(1, 1, 1, 1); - GL11.glDepthMask(true); // back to normal Z buffering - GL_TexEnv(GL11.GL_REPLACE); - } - - /** - * R_DrawParticles - */ - void R_DrawParticles() { - - if (gl_ext_pointparameters.value != 0.0f && qglPointParameterfEXT) { - - //GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); - GL11.glVertexPointer(3, 0, particle_t.vertexArray); - GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); - GL11.glColorPointer(4, true, 0, particle_t.getColorAsByteBuffer()); - - GL11.glDepthMask(false); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glPointSize(gl_particle_size.value); - - GL11.glDrawArrays(GL11.GL_POINTS, 0, r_newrefdef.num_particles); - - GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); - //GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDepthMask(true); - GL11.glEnable(GL11.GL_TEXTURE_2D); - - } - else { - GL_DrawParticles(r_newrefdef.num_particles); - } - } - - /** - * R_PolyBlend - */ - void R_PolyBlend() { - if (gl_polyblend.value == 0.0f) - return; - - if (v_blend[3] == 0.0f) - return; - - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glDisable(GL11.GL_TEXTURE_2D); - - GL11.glLoadIdentity(); - - // FIXME: get rid of these - GL11.glRotatef(-90, 1, 0, 0); // put Z going up - GL11.glRotatef(90, 0, 0, 1); // put Z going up - - GL11.glColor4f(v_blend[0], v_blend[1], v_blend[2], v_blend[3]); - - GL11.glBegin(GL11.GL_QUADS); - - GL11.glVertex3f(10, 100, 100); - GL11.glVertex3f(10, -100, 100); - GL11.glVertex3f(10, -100, -100); - GL11.glVertex3f(10, 100, -100); - GL11.glEnd(); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_ALPHA_TEST); - - GL11.glColor4f(1, 1, 1, 1); - } - - // ======================================================================= - - /** - * SignbitsForPlane - */ - int SignbitsForPlane(cplane_t out) { - // for fast box on planeside test - int bits = 0; - for (int j = 0; j < 3; j++) { - if (out.normal[j] < 0) - bits |= (1 << j); - } - return bits; - } - - /** - * R_SetFrustum - */ - void R_SetFrustum() { - // rotate VPN right by FOV_X/2 degrees - Math3D.RotatePointAroundVector(frustum[0].normal, vup, vpn, - (90f - r_newrefdef.fov_x / 2f)); - // rotate VPN left by FOV_X/2 degrees - Math3D.RotatePointAroundVector(frustum[1].normal, vup, vpn, 90f - r_newrefdef.fov_x / 2f); - // rotate VPN up by FOV_X/2 degrees - Math3D.RotatePointAroundVector(frustum[2].normal, vright, vpn, 90f - r_newrefdef.fov_y / 2f); - // rotate VPN down by FOV_X/2 degrees - Math3D.RotatePointAroundVector(frustum[3].normal, vright, vpn, - (90f - r_newrefdef.fov_y / 2f)); - - for (int i = 0; i < 4; i++) { - frustum[i].type = Defines.PLANE_ANYZ; - frustum[i].dist = Math3D.DotProduct(r_origin, frustum[i].normal); - frustum[i].signbits = (byte) SignbitsForPlane(frustum[i]); - } - } - - // ======================================================================= - - // stack variable - private final float[] temp = {0, 0, 0}; - /** - * R_SetupFrame - */ - void R_SetupFrame() { - r_framecount++; - - // build the transformation matrix for the given view angles - Math3D.VectorCopy(r_newrefdef.vieworg, r_origin); - - Math3D.AngleVectors(r_newrefdef.viewangles, vpn, vright, vup); - - // current viewcluster - mleaf_t leaf; - if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0) { - r_oldviewcluster = r_viewcluster; - r_oldviewcluster2 = r_viewcluster2; - leaf = Mod_PointInLeaf(r_origin, r_worldmodel); - r_viewcluster = r_viewcluster2 = leaf.cluster; - - // check above and below so crossing solid water doesn't draw wrong - if (leaf.contents == 0) { // look down a bit - Math3D.VectorCopy(r_origin, temp); - temp[2] -= 16; - leaf = Mod_PointInLeaf(temp, r_worldmodel); - if ((leaf.contents & Defines.CONTENTS_SOLID) == 0 && (leaf.cluster != r_viewcluster2)) - r_viewcluster2 = leaf.cluster; - } - else { // look up a bit - Math3D.VectorCopy(r_origin, temp); - temp[2] += 16; - leaf = Mod_PointInLeaf(temp, r_worldmodel); - if ((leaf.contents & Defines.CONTENTS_SOLID) == 0 && (leaf.cluster != r_viewcluster2)) - r_viewcluster2 = leaf.cluster; - } - } - - for (int i = 0; i < 4; i++) - v_blend[i] = r_newrefdef.blend[i]; - - c_brush_polys = 0; - c_alias_polys = 0; - - // clear out the portion of the screen that the NOWORLDMODEL defines - if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0) { - GL11.glEnable(GL11.GL_SCISSOR_TEST); - GL11.glClearColor(0.3f, 0.3f, 0.3f, 1.0f); - GL11.glScissor( - r_newrefdef.x, - vid.height - r_newrefdef.height - r_newrefdef.y, - r_newrefdef.width, - r_newrefdef.height); - GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); - GL11.glClearColor(1.0f, 0.0f, 0.5f, 0.5f); - GL11.glDisable(GL11.GL_SCISSOR_TEST); - } - } - - /** - * MYgluPerspective - * - * @param fovy - * @param aspect - * @param zNear - * @param zFar - */ - void MYgluPerspective(double fovy, double aspect, double zNear, double zFar) { - double ymax = zNear * Math.tan(fovy * Math.PI / 360.0); - double ymin = -ymax; - - double xmin = ymin * aspect; - double xmax = ymax * aspect; - - xmin += - (2 * gl_state.camera_separation) / zNear; - xmax += - (2 * gl_state.camera_separation) / zNear; - - GL11.glFrustum(xmin, xmax, ymin, ymax, zNear, zFar); - } - - /** - * R_SetupGL - */ - void R_SetupGL() { - - // - // set up viewport - // - //int x = (int) Math.floor(r_newrefdef.x * vid.width / vid.width); - int x = r_newrefdef.x; - //int x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width); - int x2 = r_newrefdef.x + r_newrefdef.width; - //int y = (int) Math.floor(vid.height - r_newrefdef.y * vid.height / vid.height); - int y = vid.height - r_newrefdef.y; - //int y2 = (int) Math.ceil(vid.height - (r_newrefdef.y + r_newrefdef.height) * vid.height / vid.height); - int y2 = vid.height - (r_newrefdef.y + r_newrefdef.height); - - int w = x2 - x; - int h = y - y2; - - GL11.glViewport(x, y2, w, h); - - // - // set up projection matrix - // - float screenaspect = (float) r_newrefdef.width / r_newrefdef.height; - GL11.glMatrixMode(GL11.GL_PROJECTION); - GL11.glLoadIdentity(); - MYgluPerspective(r_newrefdef.fov_y, screenaspect, 4, 4096); - - GL11.glCullFace(GL11.GL_FRONT); - - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glLoadIdentity(); - - GL11.glRotatef(-90, 1, 0, 0); // put Z going up - GL11.glRotatef(90, 0, 0, 1); // put Z going up - GL11.glRotatef(-r_newrefdef.viewangles[2], 1, 0, 0); - GL11.glRotatef(-r_newrefdef.viewangles[0], 0, 1, 0); - GL11.glRotatef(-r_newrefdef.viewangles[1], 0, 0, 1); - GL11.glTranslatef(-r_newrefdef.vieworg[0], -r_newrefdef.vieworg[1], -r_newrefdef.vieworg[2]); - - GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, r_world_matrix); - r_world_matrix.clear(); - - // - // set drawing parms - // - if (gl_cull.value != 0.0f) - GL11.glEnable(GL11.GL_CULL_FACE); - else - GL11.glDisable(GL11.GL_CULL_FACE); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - - int trickframe = 0; - - /** - * R_Clear - */ - void R_Clear() { - if (gl_ztrick.value != 0.0f) { - - if (gl_clear.value != 0.0f) { - GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); - } - - trickframe++; - if ((trickframe & 1) != 0) { - gldepthmin = 0; - gldepthmax = 0.49999f; - GL11.glDepthFunc(GL11.GL_LEQUAL); - } - else { - gldepthmin = 1; - gldepthmax = 0.5f; - GL11.glDepthFunc(GL11.GL_GEQUAL); - } - } - else { - if (gl_clear.value != 0.0f) - GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); - else - GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); - - gldepthmin = 0; - gldepthmax = 1; - GL11.glDepthFunc(GL11.GL_LEQUAL); - } - GL11.glDepthRange(gldepthmin, gldepthmax); - } - - /** - * R_Flash - */ - void R_Flash() { - R_PolyBlend(); - } - - /** - * R_RenderView - * r_newrefdef must be set before the first call - */ - void R_RenderView(refdef_t fd) { - - if (r_norefresh.value != 0.0f) - return; - - r_newrefdef = fd; - - // included by cwei - if (r_newrefdef == null) { - Com.Error(Defines.ERR_DROP, "R_RenderView: refdef_t fd is null"); - } - - if (r_worldmodel == null && (r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0) - Com.Error(Defines.ERR_DROP, "R_RenderView: NULL worldmodel"); - - if (r_speeds.value != 0.0f) { - c_brush_polys = 0; - c_alias_polys = 0; - } - - R_PushDlights(); - - if (gl_finish.value != 0.0f) - GL11.glFinish(); - - R_SetupFrame(); - - R_SetFrustum(); - - R_SetupGL(); - - R_MarkLeaves(); // done here so we know if we're in water - - R_DrawWorld(); - - R_DrawEntitiesOnList(); - - R_RenderDlights(); - - R_DrawParticles(); - - R_DrawAlphaSurfaces(); - - R_Flash(); - - if (r_speeds.value != 0.0f) { - VID.Printf( - Defines.PRINT_ALL, - "%4i wpoly %4i epoly %i tex %i lmaps\n", - new Vargs(4).add(c_brush_polys).add(c_alias_polys).add(c_visible_textures).add(c_visible_lightmaps)); - } - } - - /** - * R_SetGL2D - */ - void R_SetGL2D() { - // set 2D virtual screen size - GL11.glViewport(0, 0, vid.width, vid.height); - GL11.glMatrixMode(GL11.GL_PROJECTION); - GL11.glLoadIdentity(); - GL11.glOrtho(0, vid.width, vid.height, 0, -99999, 99999); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glLoadIdentity(); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glColor4f(1, 1, 1, 1); - } - - // stack variable - private final float[] light = { 0, 0, 0 }; - /** - * R_SetLightLevel - */ - void R_SetLightLevel() { - if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0) - return; - - // save off light value for server to look at (BIG HACK!) - - R_LightPoint(r_newrefdef.vieworg, light); - - // pick the greatest component, which should be the same - // as the mono value returned by software - if (light[0] > light[1]) { - if (light[0] > light[2]) - r_lightlevel.value = 150 * light[0]; - else - r_lightlevel.value = 150 * light[2]; - } - else { - if (light[1] > light[2]) - r_lightlevel.value = 150 * light[1]; - else - r_lightlevel.value = 150 * light[2]; - } - } - - /** - * R_RenderFrame - */ - protected void R_RenderFrame(refdef_t fd) { - R_RenderView(fd); - R_SetLightLevel(); - R_SetGL2D(); - } - - /** - * R_Register - */ - protected void R_Register() { - r_lefthand = Cvar.Get("hand", "0", Globals.CVAR_USERINFO | Globals.CVAR_ARCHIVE); - r_norefresh = Cvar.Get("r_norefresh", "0", 0); - r_fullbright = Cvar.Get("r_fullbright", "0", 0); - r_drawentities = Cvar.Get("r_drawentities", "1", 0); - r_drawworld = Cvar.Get("r_drawworld", "1", 0); - r_novis = Cvar.Get("r_novis", "0", 0); - r_nocull = Cvar.Get("r_nocull", "0", 0); - r_lerpmodels = Cvar.Get("r_lerpmodels", "1", 0); - r_speeds = Cvar.Get("r_speeds", "0", 0); - - r_lightlevel = Cvar.Get("r_lightlevel", "1", 0); - - gl_nosubimage = Cvar.Get("gl_nosubimage", "0", 0); - gl_allow_software = Cvar.Get("gl_allow_software", "0", 0); - - gl_particle_min_size = Cvar.Get("gl_particle_min_size", "2", Globals.CVAR_ARCHIVE); - gl_particle_max_size = Cvar.Get("gl_particle_max_size", "40", Globals.CVAR_ARCHIVE); - gl_particle_size = Cvar.Get("gl_particle_size", "40", Globals.CVAR_ARCHIVE); - gl_particle_att_a = Cvar.Get("gl_particle_att_a", "0.01", Globals.CVAR_ARCHIVE); - gl_particle_att_b = Cvar.Get("gl_particle_att_b", "0.0", Globals.CVAR_ARCHIVE); - gl_particle_att_c = Cvar.Get("gl_particle_att_c", "0.01", Globals.CVAR_ARCHIVE); - - gl_modulate = Cvar.Get("gl_modulate", "1.5", Globals.CVAR_ARCHIVE); - gl_log = Cvar.Get("gl_log", "0", 0); - gl_bitdepth = Cvar.Get("gl_bitdepth", "0", 0); - gl_mode = Cvar.Get("gl_mode", "3", Globals.CVAR_ARCHIVE); // 640x480 - gl_lightmap = Cvar.Get("gl_lightmap", "0", 0); - gl_shadows = Cvar.Get("gl_shadows", "0", Globals.CVAR_ARCHIVE); - gl_dynamic = Cvar.Get("gl_dynamic", "1", 0); - gl_nobind = Cvar.Get("gl_nobind", "0", 0); - gl_round_down = Cvar.Get("gl_round_down", "1", 0); - gl_picmip = Cvar.Get("gl_picmip", "0", 0); - gl_skymip = Cvar.Get("gl_skymip", "0", 0); - gl_showtris = Cvar.Get("gl_showtris", "0", 0); - gl_ztrick = Cvar.Get("gl_ztrick", "0", 0); - gl_finish = Cvar.Get("gl_finish", "0", Globals.CVAR_ARCHIVE); - gl_clear = Cvar.Get("gl_clear", "0", 0); - gl_cull = Cvar.Get("gl_cull", "1", 0); - gl_polyblend = Cvar.Get("gl_polyblend", "1", 0); - gl_flashblend = Cvar.Get("gl_flashblend", "0", 0); - gl_playermip = Cvar.Get("gl_playermip", "0", 0); - gl_monolightmap = Cvar.Get("gl_monolightmap", "0", 0); - gl_driver = Cvar.Get("gl_driver", "opengl32", Globals.CVAR_ARCHIVE); - gl_texturemode = Cvar.Get("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", Globals.CVAR_ARCHIVE); - gl_texturealphamode = Cvar.Get("gl_texturealphamode", "default", Globals.CVAR_ARCHIVE); - gl_texturesolidmode = Cvar.Get("gl_texturesolidmode", "default", Globals.CVAR_ARCHIVE); - gl_lockpvs = Cvar.Get("gl_lockpvs", "0", 0); - - gl_vertex_arrays = Cvar.Get("gl_vertex_arrays", "1", Globals.CVAR_ARCHIVE); - - gl_ext_swapinterval = Cvar.Get("gl_ext_swapinterval", "1", Globals.CVAR_ARCHIVE); - gl_ext_palettedtexture = Cvar.Get("gl_ext_palettedtexture", "0", Globals.CVAR_ARCHIVE); - gl_ext_multitexture = Cvar.Get("gl_ext_multitexture", "1", Globals.CVAR_ARCHIVE); - gl_ext_pointparameters = Cvar.Get("gl_ext_pointparameters", "1", Globals.CVAR_ARCHIVE); - gl_ext_compiled_vertex_array = Cvar.Get("gl_ext_compiled_vertex_array", "1", Globals.CVAR_ARCHIVE); - - gl_drawbuffer = Cvar.Get("gl_drawbuffer", "GL_BACK", 0); - gl_swapinterval = Cvar.Get("gl_swapinterval", "0", Globals.CVAR_ARCHIVE); - - gl_saturatelighting = Cvar.Get("gl_saturatelighting", "0", 0); - - gl_3dlabs_broken = Cvar.Get("gl_3dlabs_broken", "1", Globals.CVAR_ARCHIVE); - - vid_fullscreen = Cvar.Get("vid_fullscreen", "0", Globals.CVAR_ARCHIVE); - vid_gamma = Cvar.Get("vid_gamma", "1.0", Globals.CVAR_ARCHIVE); - vid_ref = Cvar.Get("vid_ref", "lwjgl", Globals.CVAR_ARCHIVE); - - Cmd.AddCommand("imagelist", this::GL_ImageList_f); - - Cmd.AddCommand("screenshot", this::GL_ScreenShot_f); - Cmd.AddCommand("modellist", this::Mod_Modellist_f); - Cmd.AddCommand("gl_strings", this::GL_Strings_f); - } - - /** - * R_SetMode - */ - protected boolean R_SetMode() { - boolean fullscreen = (vid_fullscreen.value > 0.0f); - - vid_fullscreen.modified = false; - gl_mode.modified = false; - - Dimension dim = new Dimension(vid.width, vid.height); - - int err; // enum rserr_t - if ((err = GLimp_SetMode(dim, (int) gl_mode.value, fullscreen)) == rserr_ok) { - gl_state.prev_mode = (int) gl_mode.value; - } - else { - if (err == rserr_invalid_fullscreen) { - Cvar.SetValue("vid_fullscreen", 0); - vid_fullscreen.modified = false; - log.warn("ref_gl::R_SetMode() - fullscreen unavailable in this mode"); - if ((err = GLimp_SetMode(dim, (int) gl_mode.value, false)) == rserr_ok) - return true; - } - else if (err == rserr_invalid_mode) { - Cvar.SetValue("gl_mode", gl_state.prev_mode); - gl_mode.modified = false; - log.warn("ref_gl::R_SetMode() - invalid mode"); - } - - // try setting it back to something safe - if ((err = GLimp_SetMode(dim, gl_state.prev_mode, false)) != rserr_ok) { - log.warn("ref_gl::R_SetMode() - could not revert to safe mode"); - return false; - } - } - return true; - } - - float[] r_turbsin = new float[256]; - - /** - * R_Init - */ - protected boolean R_Init(int vid_xpos, int vid_ypos) { - - assert(Warp.SIN.length == 256) : "warpsin table bug"; - - // fill r_turbsin - for (int j = 0; j < 256; j++) { - r_turbsin[j] = Warp.SIN[j] * 0.5f; - } - - log.info("ref_gl version: {}", REF_VERSION); - - Draw_GetPalette(); - - R_Register(); - - // set our "safe" modes - gl_state.prev_mode = 3; - - // create the window and set up the context - if (!R_SetMode()) { - log.info("ref_gl::R_Init() - could not R_SetMode()"); - return false; - } - return true; - } - - /** - * R_Init2 - */ - protected boolean R_Init2() { - VID.MenuInit(); - - /* - ** get our various GL strings - */ - gl_config.vendor_string = GL11.glGetString(GL11.GL_VENDOR); - log.info("GL_VENDOR: {}", gl_config.vendor_string); - gl_config.renderer_string = GL11.glGetString(GL11.GL_RENDERER); - log.info("GL_RENDERER: {}", gl_config.renderer_string); - gl_config.version_string = GL11.glGetString(GL11.GL_VERSION); - log.info("GL_VERSION: {}", gl_config.version_string); - gl_config.extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS); - log.info("GL_EXTENSIONS: {}", gl_config.extensions_string); - - gl_config.parseOpenGLVersion(); - - String renderer_buffer = gl_config.renderer_string.toLowerCase(); - String vendor_buffer = gl_config.vendor_string.toLowerCase(); - - if (renderer_buffer.indexOf("voodoo") >= 0) { - if (renderer_buffer.indexOf("rush") < 0) - gl_config.renderer = GL_RENDERER_VOODOO; - else - gl_config.renderer = GL_RENDERER_VOODOO_RUSH; - } - else if (vendor_buffer.indexOf("sgi") >= 0) - gl_config.renderer = GL_RENDERER_SGI; - else if (renderer_buffer.indexOf("permedia") >= 0) - gl_config.renderer = GL_RENDERER_PERMEDIA2; - else if (renderer_buffer.indexOf("glint") >= 0) - gl_config.renderer = GL_RENDERER_GLINT_MX; - else if (renderer_buffer.indexOf("glzicd") >= 0) - gl_config.renderer = GL_RENDERER_REALIZM; - else if (renderer_buffer.indexOf("gdi") >= 0) - gl_config.renderer = GL_RENDERER_MCD; - else if (renderer_buffer.indexOf("pcx2") >= 0) - gl_config.renderer = GL_RENDERER_PCX2; - else if (renderer_buffer.indexOf("verite") >= 0) - gl_config.renderer = GL_RENDERER_RENDITION; - else - gl_config.renderer = GL_RENDERER_OTHER; - - String monolightmap = gl_monolightmap.string.toUpperCase(); - if (monolightmap.length() < 2 || monolightmap.charAt(1) != 'F') { - if (gl_config.renderer == GL_RENDERER_PERMEDIA2) { - Cvar.Set("gl_monolightmap", "A"); - log.info("...using gl_monolightmap 'a'"); - } - else if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) { - Cvar.Set("gl_monolightmap", "0"); - } - else { - Cvar.Set("gl_monolightmap", "0"); - } - } - - // power vr can't have anything stay in the framebuffer, so - // the screen needs to redraw the tiled background every frame - if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) { - Cvar.Set("scr_drawall", "1"); - } - else { - Cvar.Set("scr_drawall", "0"); - } - - // MCD has buffering issues - if (gl_config.renderer == GL_RENDERER_MCD) { - Cvar.SetValue("gl_finish", 1); - } - - if ((gl_config.renderer & GL_RENDERER_3DLABS) != 0) { - if (gl_3dlabs_broken.value != 0.0f) - gl_config.allow_cds = false; - else - gl_config.allow_cds = true; - } - else { - gl_config.allow_cds = true; - } - - if (gl_config.allow_cds) - log.info("...allowing CDS"); - else - log.info("...disabling CDS"); - - /* - ** grab extensions - */ - if (gl_config.extensions_string.indexOf("GL_EXT_compiled_vertex_array") >= 0 - || gl_config.extensions_string.indexOf("GL_SGI_compiled_vertex_array") >= 0) { - log.info("...enabling GL_EXT_compiled_vertex_array"); - // qglLockArraysEXT = ( void * ) qwglGetProcAddress( "glLockArraysEXT" ); - if (gl_ext_compiled_vertex_array.value != 0.0f) - qglLockArraysEXT = true; - else - qglLockArraysEXT = false; - // qglUnlockArraysEXT = ( void * ) qwglGetProcAddress( "glUnlockArraysEXT" ); - //qglUnlockArraysEXT = true; - } - else { - log.info("...GL_EXT_compiled_vertex_array not found"); - qglLockArraysEXT = false; - } - - if (gl_config.extensions_string.indexOf("WGL_EXT_swap_control") >= 0) { - qwglSwapIntervalEXT = true; - log.info("...enabling WGL_EXT_swap_control"); - } else { - qwglSwapIntervalEXT = false; - log.info("...WGL_EXT_swap_control not found"); - } - - if (gl_config.extensions_string.indexOf("GL_EXT_point_parameters") >= 0) { - if (gl_ext_pointparameters.value != 0.0f) { - // qglPointParameterfEXT = ( void (APIENTRY *)( GLenum, GLfloat ) ) qwglGetProcAddress( "glPointParameterfEXT" ); - qglPointParameterfEXT = true; - // qglPointParameterfvEXT = ( void (APIENTRY *)( GLenum, const GLfloat * ) ) qwglGetProcAddress( "glPointParameterfvEXT" ); - log.info("...using GL_EXT_point_parameters"); - } - else { - log.info("...ignoring GL_EXT_point_parameters"); - } - } - else { - log.info("...GL_EXT_point_parameters not found"); - } - - // #ifdef __linux__ - // if ( strstr( gl_config.extensions_string, "3DFX_set_global_palette" )) - // { - // if ( gl_ext_palettedtexture->value ) - // { - // VID.Printf( Defines.PRINT_ALL, "...using 3DFX_set_global_palette\n" ); - // qgl3DfxSetPaletteEXT = ( void ( APIENTRY * ) (GLuint *) )qwglGetProcAddress( "gl3DfxSetPaletteEXT" ); - //// qglColorTableEXT = Fake_glColorTableEXT; - // } - // else - // { - // VID.Printf( Defines.PRINT_ALL, "...ignoring 3DFX_set_global_palette\n" ); - // } - // } - // else - // { - // VID.Printf( Defines.PRINT_ALL, "...3DFX_set_global_palette not found\n" ); - // } - // #endif - - if (!qglColorTableEXT - && gl_config.extensions_string.indexOf("GL_EXT_paletted_texture") >= 0 - && gl_config.extensions_string.indexOf("GL_EXT_shared_texture_palette") >= 0) { - if (gl_ext_palettedtexture.value != 0.0f) { - log.info("...using GL_EXT_shared_texture_palette"); - qglColorTableEXT = false; // true; TODO jogl bug - } - else { - log.info("...ignoring GL_EXT_shared_texture_palette"); - qglColorTableEXT = false; - } - } - else { - log.info("...GL_EXT_shared_texture_palette not found"); - } - - if (gl_config.extensions_string.indexOf("GL_ARB_multitexture") >= 0) { - log.info("...using GL_ARB_multitexture"); - qglActiveTextureARB = true; - GL_TEXTURE0 = ARBMultitexture.GL_TEXTURE0_ARB; - GL_TEXTURE1 = ARBMultitexture.GL_TEXTURE1_ARB; - } - else { - log.info("...GL_ARB_multitexture not found"); - } - - if (!(qglActiveTextureARB)) - return false; - - GL_SetDefaultState(); - - GL_InitImages(); - Mod_Init(); - R_InitParticleTexture(); - Draw_InitLocal(); - - int err = GL11.glGetError(); - if (err != GL11.GL_NO_ERROR) - VID.Printf( - Defines.PRINT_ALL, - "glGetError() = 0x%x\n\t%s\n", - new Vargs(2).add(err).add("" + GL11.glGetString(err))); - - return true; - } - - /** - * R_Shutdown - */ - protected void R_Shutdown() { - Cmd.RemoveCommand("modellist"); - Cmd.RemoveCommand("screenshot"); - Cmd.RemoveCommand("imagelist"); - Cmd.RemoveCommand("gl_strings"); - - Mod_FreeAll(); - - GL_ShutdownImages(); - - /* - * shut down OS specific OpenGL stuff like contexts, etc. - */ - GLimp_Shutdown(); - } - - /** - * R_BeginFrame - */ - protected void R_BeginFrame(float camera_separation) { - - gl_state.camera_separation = camera_separation; - - /* - ** change modes if necessary - */ - if (gl_mode.modified || vid_fullscreen.modified) { - // FIXME: only restart if CDS is required - cvar_t ref; - - ref = Cvar.Get("vid_ref", "lwjgl", 0); - ref.modified = true; - } - - if (gl_log.modified) { - GLimp_EnableLogging((gl_log.value != 0.0f)); - gl_log.modified = false; - } - - if (gl_log.value != 0.0f) { - GLimp_LogNewFrame(); - } - - /* - ** update 3Dfx gamma -- it is expected that a user will do a vid_restart - ** after tweaking this value - */ - if (vid_gamma.modified) { - vid_gamma.modified = false; - - if ((gl_config.renderer & GL_RENDERER_VOODOO) != 0) { - // wird erstmal nicht gebraucht - - /* - char envbuffer[1024]; - float g; - - g = 2.00 * ( 0.8 - ( vid_gamma->value - 0.5 ) ) + 1.0F; - Com_sprintf( envbuffer, sizeof(envbuffer), "SSTV2_GAMMA=%f", g ); - putenv( envbuffer ); - Com_sprintf( envbuffer, sizeof(envbuffer), "SST_GAMMA=%f", g ); - putenv( envbuffer ); - */ - VID.Printf(Defines.PRINT_DEVELOPER, "gamma anpassung fuer VOODOO nicht gesetzt"); - } - } - - GLimp_BeginFrame(camera_separation); - - /* - ** go into 2D mode - */ - GL11.glViewport(0, 0, vid.width, vid.height); - GL11.glMatrixMode(GL11.GL_PROJECTION); - GL11.glLoadIdentity(); - GL11.glOrtho(0, vid.width, vid.height, 0, -99999, 99999); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glLoadIdentity(); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glColor4f(1, 1, 1, 1); - - /* - ** draw buffer stuff - */ - if (gl_drawbuffer.modified) { - gl_drawbuffer.modified = false; - - if (gl_state.camera_separation == 0 || !gl_state.stereo_enabled) { - if (gl_drawbuffer.string.equalsIgnoreCase("GL_FRONT")) - GL11.glDrawBuffer(GL11.GL_FRONT); - else - GL11.glDrawBuffer(GL11.GL_BACK); - } - } - - /* - ** texturemode stuff - */ - if (gl_texturemode.modified) { - GL_TextureMode(gl_texturemode.string); - gl_texturemode.modified = false; - } - - if (gl_texturealphamode.modified) { - GL_TextureAlphaMode(gl_texturealphamode.string); - gl_texturealphamode.modified = false; - } - - if (gl_texturesolidmode.modified) { - GL_TextureSolidMode(gl_texturesolidmode.string); - gl_texturesolidmode.modified = false; - } - - /* - ** swapinterval stuff - */ - GL_UpdateSwapInterval(); - - // - // clear screen if desired - // - R_Clear(); - } - - int[] r_rawpalette = new int[256]; - - /** - * R_SetPalette - */ - protected void R_SetPalette(byte[] palette) { - // 256 RGB values (768 bytes) - // or null - int i; - int color = 0; - - if (palette != null) { - int j =0; - for (i = 0; i < 256; i++) { - color = (palette[j++] & 0xFF) << 0; - color |= (palette[j++] & 0xFF) << 8; - color |= (palette[j++] & 0xFF) << 16; - color |= 0xFF000000; - r_rawpalette[i] = color; - } - } - else { - for (i = 0; i < 256; i++) { - r_rawpalette[i] = d_8to24table[i] | 0xff000000; - } - } - GL_SetTexturePalette(r_rawpalette); - - GL11.glClearColor(0, 0, 0, 0); - GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); - GL11.glClearColor(1f, 0f, 0.5f, 0.5f); - } - - static final int NUM_BEAM_SEGS = 6; - float[][] start_points = new float[NUM_BEAM_SEGS][3]; - // array of vec3_t - float[][] end_points = new float[NUM_BEAM_SEGS][3]; // array of vec3_t - - // stack variable - private final float[] perpvec = { 0, 0, 0 }; // vec3_t - private final float[] direction = { 0, 0, 0 }; // vec3_t - private final float[] normalized_direction = { 0, 0, 0 }; // vec3_t - private final float[] oldorigin = { 0, 0, 0 }; // vec3_t - private final float[] origin = { 0, 0, 0 }; // vec3_t - /** - * R_DrawBeam - */ - void R_DrawBeam(entity_t e) { - oldorigin[0] = e.oldorigin[0]; - oldorigin[1] = e.oldorigin[1]; - oldorigin[2] = e.oldorigin[2]; - - origin[0] = e.origin[0]; - origin[1] = e.origin[1]; - origin[2] = e.origin[2]; - - normalized_direction[0] = direction[0] = oldorigin[0] - origin[0]; - normalized_direction[1] = direction[1] = oldorigin[1] - origin[1]; - normalized_direction[2] = direction[2] = oldorigin[2] - origin[2]; - - if (Math3D.VectorNormalize(normalized_direction) == 0.0f) - return; - - Math3D.PerpendicularVector(perpvec, normalized_direction); - Math3D.VectorScale(perpvec, e.frame / 2, perpvec); - - for (int i = 0; i < 6; i++) { - Math3D.RotatePointAroundVector( - start_points[i], - normalized_direction, - perpvec, - (360.0f / NUM_BEAM_SEGS) * i); - - Math3D.VectorAdd(start_points[i], origin, start_points[i]); - Math3D.VectorAdd(start_points[i], direction, end_points[i]); - } - - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDepthMask(false); - - float r = (d_8to24table[e.skinnum & 0xFF]) & 0xFF; - float g = (d_8to24table[e.skinnum & 0xFF] >> 8) & 0xFF; - float b = (d_8to24table[e.skinnum & 0xFF] >> 16) & 0xFF; - - r *= 1 / 255.0f; - g *= 1 / 255.0f; - b *= 1 / 255.0f; - - GL11.glColor4f(r, g, b, e.alpha); - - GL11.glBegin(GL11.GL_TRIANGLE_STRIP); - - float[] v; - - for (int i = 0; i < NUM_BEAM_SEGS; i++) { - v = start_points[i]; - GL11.glVertex3f(v[0], v[1], v[2]); - v = end_points[i]; - GL11.glVertex3f(v[0], v[1], v[2]); - v = start_points[(i + 1) % NUM_BEAM_SEGS]; - GL11.glVertex3f(v[0], v[1], v[2]); - v = end_points[(i + 1) % NUM_BEAM_SEGS]; - GL11.glVertex3f(v[0], v[1], v[2]); - } - GL11.glEnd(); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); - } + // this a hack for function pointer test + // default disabled + boolean qglColorTableEXT = false; + boolean qglActiveTextureARB = false; + boolean qglPointParameterfEXT = false; + boolean qglLockArraysEXT = false; + boolean qwglSwapIntervalEXT = false; + + // ================= + // abstract methods + // ================= + protected abstract void Draw_GetPalette(); + + abstract void GL_ImageList_f(); + abstract void GL_ScreenShot_f(); + abstract void GL_SetTexturePalette(int[] palette); + abstract void GL_Strings_f(); + + abstract void Mod_Modellist_f(); + abstract mleaf_t Mod_PointInLeaf(float[] point, model_t model); + + abstract void GL_SetDefaultState(); + + abstract void GL_InitImages(); + abstract void Mod_Init(); // Model.java + abstract void R_InitParticleTexture(); // MIsc.java + abstract void R_DrawAliasModel(entity_t e); // Mesh.java + abstract void R_DrawBrushModel(entity_t e); // Surf.java + abstract void Draw_InitLocal(); + abstract void R_LightPoint(float[] p, float[] color); + abstract void R_PushDlights(); + abstract void R_MarkLeaves(); + abstract void R_DrawWorld(); + abstract void R_RenderDlights(); + abstract void R_DrawAlphaSurfaces(); + + abstract void Mod_FreeAll(); + + abstract void GL_ShutdownImages(); + abstract void GL_Bind(int texnum); + abstract void GL_TexEnv(int mode); + abstract void GL_TextureMode(String string); + abstract void GL_TextureAlphaMode(String string); + abstract void GL_TextureSolidMode(String string); + abstract void GL_UpdateSwapInterval(); + + /* + ==================================================================== + + from gl_rmain.c + + ==================================================================== + */ + + int GL_TEXTURE0 = GL13.GL_TEXTURE0; + int GL_TEXTURE1 = GL13.GL_TEXTURE1; + + model_t r_worldmodel; + + float gldepthmin, gldepthmax; + + glconfig_t gl_config = new glconfig_t(); + glstate_t gl_state = new glstate_t(); + + image_t r_notexture; // use for bad textures + image_t r_particletexture; // little dot for particles + + entity_t currententity; + model_t currentmodel; + + cplane_t frustum[] = { new cplane_t(), new cplane_t(), new cplane_t(), new cplane_t()}; + + int r_visframecount; // bumped when going to a new PVS + int r_framecount; // used for dlight push checking + + int c_brush_polys, c_alias_polys; + + float v_blend[] = { 0, 0, 0, 0 }; // final blending color + + // + // view origin + // + float[] vup = { 0, 0, 0 }; + float[] vpn = { 0, 0, 0 }; + float[] vright = { 0, 0, 0 }; + float[] r_origin = { 0, 0, 0 }; + + //float r_world_matrix[] = new float[16]; + FloatBuffer r_world_matrix=BufferUtils.createFloatBuffer(16); + + float r_base_world_matrix[] = new float[16]; + + // + // screen size info + // + refdef_t r_newrefdef = new refdef_t(); + + int r_viewcluster, r_viewcluster2, r_oldviewcluster, r_oldviewcluster2; + + cvar_t r_norefresh; + cvar_t r_drawentities; + cvar_t r_drawworld; + cvar_t r_speeds; + cvar_t r_fullbright; + cvar_t r_novis; + cvar_t r_nocull; + cvar_t r_lerpmodels; + cvar_t r_lefthand; + + cvar_t r_lightlevel; + // FIXME: This is a HACK to get the client's light level + + cvar_t gl_nosubimage; + cvar_t gl_allow_software; + + cvar_t gl_vertex_arrays; + + cvar_t gl_particle_min_size; + cvar_t gl_particle_max_size; + cvar_t gl_particle_size; + cvar_t gl_particle_att_a; + cvar_t gl_particle_att_b; + cvar_t gl_particle_att_c; + + cvar_t gl_ext_swapinterval; + cvar_t gl_ext_palettedtexture; + cvar_t gl_ext_multitexture; + cvar_t gl_ext_pointparameters; + cvar_t gl_ext_compiled_vertex_array; + + cvar_t gl_log; + cvar_t gl_bitdepth; + cvar_t gl_drawbuffer; + cvar_t gl_driver; + cvar_t gl_lightmap; + cvar_t gl_shadows; + cvar_t gl_mode; + cvar_t gl_dynamic; + cvar_t gl_monolightmap; + cvar_t gl_modulate; + cvar_t gl_nobind; + cvar_t gl_round_down; + cvar_t gl_picmip; + cvar_t gl_skymip; + cvar_t gl_showtris; + cvar_t gl_ztrick; + cvar_t gl_finish; + cvar_t gl_clear; + cvar_t gl_cull; + cvar_t gl_polyblend; + cvar_t gl_flashblend; + cvar_t gl_playermip; + cvar_t gl_saturatelighting; + cvar_t gl_swapinterval; + cvar_t gl_texturemode; + cvar_t gl_texturealphamode; + cvar_t gl_texturesolidmode; + cvar_t gl_lockpvs; + + cvar_t gl_3dlabs_broken; + + cvar_t vid_gamma; + cvar_t vid_ref; + + // ============================================================================ + // to port from gl_rmain.c, ... + // ============================================================================ + + /** + * R_CullBox + * Returns true if the box is completely outside the frustum + */ + final boolean R_CullBox(float[] mins, float[] maxs) { + assert(mins.length == 3 && maxs.length == 3) : "vec3_t bug"; + + if (r_nocull.value != 0) + return false; + + for (int i = 0; i < 4; i++) { + if (Math3D.BoxOnPlaneSide(mins, maxs, frustum[i]) == 2) + return true; + } + return false; + } + + /** + * R_RotateForEntity + */ + final void R_RotateForEntity(entity_t e) { + GL11.glTranslatef(e.origin[0], e.origin[1], e.origin[2]); + + GL11.glRotatef(e.angles[1], 0, 0, 1); + GL11.glRotatef(-e.angles[0], 0, 1, 0); + GL11.glRotatef(-e.angles[2], 1, 0, 0); + } + + /* + ============================================================= + + SPRITE MODELS + + ============================================================= + */ + + // stack variable + private final float[] point = { 0, 0, 0 }; + /** + * R_DrawSpriteModel + */ + void R_DrawSpriteModel(entity_t e) { + float alpha = 1.0F; + + qfiles.dsprframe_t frame; + qfiles.dsprite_t psprite; + + // don't even bother culling, because it's just a single + // polygon without a surface cache + + psprite = (qfiles.dsprite_t) currentmodel.extradata; + + e.frame %= psprite.numframes; + + frame = psprite.frames[e.frame]; + + if ((e.flags & Defines.RF_TRANSLUCENT) != 0) + alpha = e.alpha; + + if (alpha != 1.0F) + GL11.glEnable(GL11.GL_BLEND); + + GL11.glColor4f(1, 1, 1, alpha); + + GL_Bind(currentmodel.skins[e.frame].texnum); + + GL_TexEnv(GL11.GL_MODULATE); + + if (alpha == 1.0) + GL11.glEnable(GL11.GL_ALPHA_TEST); + else + GL11.glDisable(GL11.GL_ALPHA_TEST); + + GL11.glBegin(GL11.GL_QUADS); + + GL11.glTexCoord2f(0, 1); + Math3D.VectorMA(e.origin, -frame.origin_y, vup, point); + Math3D.VectorMA(point, -frame.origin_x, vright, point); + GL11.glVertex3f(point[0], point[1], point[2]); + + GL11.glTexCoord2f(0, 0); + Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point); + Math3D.VectorMA(point, -frame.origin_x, vright, point); + GL11.glVertex3f(point[0], point[1], point[2]); + + GL11.glTexCoord2f(1, 0); + Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point); + Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point); + GL11.glVertex3f(point[0], point[1], point[2]); + + GL11.glTexCoord2f(1, 1); + Math3D.VectorMA(e.origin, -frame.origin_y, vup, point); + Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point); + GL11.glVertex3f(point[0], point[1], point[2]); + + GL11.glEnd(); + + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL_TexEnv(GL11.GL_REPLACE); + + if (alpha != 1.0F) + GL11.glDisable(GL11.GL_BLEND); + + GL11.glColor4f(1, 1, 1, 1); + } + + // ================================================================================== + + // stack variable + private final float[] shadelight = { 0, 0, 0 }; + /** + * R_DrawNullModel + */ + void R_DrawNullModel() { + if ((currententity.flags & Defines.RF_FULLBRIGHT) != 0) { + // cwei wollte blau: shadelight[0] = shadelight[1] = shadelight[2] = 1.0F; + shadelight[0] = shadelight[1] = shadelight[2] = 0.0F; + shadelight[2] = 0.8F; + } + else { + R_LightPoint(currententity.origin, shadelight); + } + + GL11.glPushMatrix(); + R_RotateForEntity(currententity); + + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glColor3f(shadelight[0], shadelight[1], shadelight[2]); + + // this replaces the TRIANGLE_FAN + //glut.glutWireCube(gl, 20); + + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + GL11.glVertex3f(0, 0, -16); + int i; + for (i=0 ; i<=4 ; i++) { + GL11.glVertex3f((float)(16.0f * Math.cos(i * Math.PI / 2)), (float)(16.0f * Math.sin(i * Math.PI / 2)), 0.0f); + } + GL11.glEnd(); + + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + GL11.glVertex3f (0, 0, 16); + for (i=4 ; i>=0 ; i--) { + GL11.glVertex3f((float)(16.0f * Math.cos(i * Math.PI / 2)), (float)(16.0f * Math.sin(i * Math.PI / 2)), 0.0f); + } + GL11.glEnd(); + + + GL11.glColor3f(1, 1, 1); + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + /** + * R_DrawEntitiesOnList + */ + void R_DrawEntitiesOnList() { + if (r_drawentities.value == 0.0f) + return; + + // draw non-transparent first + int i; + for (i = 0; i < r_newrefdef.num_entities; i++) { + currententity = r_newrefdef.entities[i]; + if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) + continue; // solid + + if ((currententity.flags & Defines.RF_BEAM) != 0) { + R_DrawBeam(currententity); + } + else { + currentmodel = currententity.model; + if (currentmodel == null) { + R_DrawNullModel(); + continue; + } + switch (currentmodel.type) { + case mod_alias : + R_DrawAliasModel(currententity); + break; + case mod_brush : + R_DrawBrushModel(currententity); + break; + case mod_sprite : + R_DrawSpriteModel(currententity); + break; + default : + Com.Error(Defines.ERR_DROP, "Bad modeltype"); + break; + } + } + } + // draw transparent entities + // we could sort these if it ever becomes a problem... + GL11.glDepthMask(false); // no z writes + for (i = 0; i < r_newrefdef.num_entities; i++) { + currententity = r_newrefdef.entities[i]; + if ((currententity.flags & Defines.RF_TRANSLUCENT) == 0) + continue; // solid + + if ((currententity.flags & Defines.RF_BEAM) != 0) { + R_DrawBeam(currententity); + } + else { + currentmodel = currententity.model; + + if (currentmodel == null) { + R_DrawNullModel(); + continue; + } + switch (currentmodel.type) { + case mod_alias : + R_DrawAliasModel(currententity); + break; + case mod_brush : + R_DrawBrushModel(currententity); + break; + case mod_sprite : + R_DrawSpriteModel(currententity); + break; + default : + Com.Error(Defines.ERR_DROP, "Bad modeltype"); + break; + } + } + } + GL11.glDepthMask(true); // back to writing + } + + // stack variable + private final float[] up = { 0, 0, 0 }; + private final float[] right = { 0, 0, 0 }; + /** + * GL_DrawParticles + */ + void GL_DrawParticles(int num_particles) { + float origin_x, origin_y, origin_z; + + Math3D.VectorScale(vup, 1.5f, up); + Math3D.VectorScale(vright, 1.5f, right); + + GL_Bind(r_particletexture.texnum); + GL11.glDepthMask(false); // no z buffering + GL11.glEnable(GL11.GL_BLEND); + GL_TexEnv(GL11.GL_MODULATE); + + GL11.glBegin(GL11.GL_TRIANGLES); + + FloatBuffer sourceVertices = particle_t.vertexArray; + IntBuffer sourceColors = particle_t.colorArray; + float scale; + int color; + for (int j = 0, i = 0; i < num_particles; i++) { + origin_x = sourceVertices.get(j++); + origin_y = sourceVertices.get(j++); + origin_z = sourceVertices.get(j++); + + // hack a scale up to keep particles from disapearing + scale = + (origin_x - r_origin[0]) * vpn[0] + + (origin_y - r_origin[1]) * vpn[1] + + (origin_z - r_origin[2]) * vpn[2]; + + scale = (scale < 20) ? 1 : 1 + scale * 0.004f; + + color = sourceColors.get(i); + + GL11.glColor4ub( + (byte)((color) & 0xFF), + (byte)((color >> 8) & 0xFF), + (byte)((color >> 16) & 0xFF), + (byte)((color >>> 24)) + ); + // first vertex + GL11.glTexCoord2f(0.0625f, 0.0625f); + GL11.glVertex3f(origin_x, origin_y, origin_z); + // second vertex + GL11.glTexCoord2f(1.0625f, 0.0625f); + GL11.glVertex3f(origin_x + up[0] * scale, origin_y + up[1] * scale, origin_z + up[2] * scale); + // third vertex + GL11.glTexCoord2f(0.0625f, 1.0625f); + GL11.glVertex3f(origin_x + right[0] * scale, origin_y + right[1] * scale, origin_z + right[2] * scale); + } + GL11.glEnd(); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1, 1, 1, 1); + GL11.glDepthMask(true); // back to normal Z buffering + GL_TexEnv(GL11.GL_REPLACE); + } + + /** + * R_DrawParticles + */ + void R_DrawParticles() { + + if (gl_ext_pointparameters.value != 0.0f && qglPointParameterfEXT) { + + //GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); + GL11.glVertexPointer(3, 0, particle_t.vertexArray); + GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); + GL11.glColorPointer(4, true, 0, particle_t.getColorAsByteBuffer()); + + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glPointSize(gl_particle_size.value); + + GL11.glDrawArrays(GL11.GL_POINTS, 0, r_newrefdef.num_particles); + + GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); + //GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_TEXTURE_2D); + + } + else { + GL_DrawParticles(r_newrefdef.num_particles); + } + } + + /** + * R_PolyBlend + */ + void R_PolyBlend() { + if (gl_polyblend.value == 0.0f) + return; + + if (v_blend[3] == 0.0f) + return; + + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_TEXTURE_2D); + + GL11.glLoadIdentity(); + + // FIXME: get rid of these + GL11.glRotatef(-90, 1, 0, 0); // put Z going up + GL11.glRotatef(90, 0, 0, 1); // put Z going up + + GL11.glColor4f(v_blend[0], v_blend[1], v_blend[2], v_blend[3]); + + GL11.glBegin(GL11.GL_QUADS); + + GL11.glVertex3f(10, 100, 100); + GL11.glVertex3f(10, -100, 100); + GL11.glVertex3f(10, -100, -100); + GL11.glVertex3f(10, 100, -100); + GL11.glEnd(); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + GL11.glColor4f(1, 1, 1, 1); + } + + // ======================================================================= + + /** + * SignbitsForPlane + */ + int SignbitsForPlane(cplane_t out) { + // for fast box on planeside test + int bits = 0; + for (int j = 0; j < 3; j++) { + if (out.normal[j] < 0) + bits |= (1 << j); + } + return bits; + } + + /** + * R_SetFrustum + */ + void R_SetFrustum() { + // rotate VPN right by FOV_X/2 degrees + Math3D.RotatePointAroundVector(frustum[0].normal, vup, vpn, - (90f - r_newrefdef.fov_x / 2f)); + // rotate VPN left by FOV_X/2 degrees + Math3D.RotatePointAroundVector(frustum[1].normal, vup, vpn, 90f - r_newrefdef.fov_x / 2f); + // rotate VPN up by FOV_X/2 degrees + Math3D.RotatePointAroundVector(frustum[2].normal, vright, vpn, 90f - r_newrefdef.fov_y / 2f); + // rotate VPN down by FOV_X/2 degrees + Math3D.RotatePointAroundVector(frustum[3].normal, vright, vpn, - (90f - r_newrefdef.fov_y / 2f)); + + for (int i = 0; i < 4; i++) { + frustum[i].type = Defines.PLANE_ANYZ; + frustum[i].dist = Math3D.DotProduct(r_origin, frustum[i].normal); + frustum[i].signbits = (byte) SignbitsForPlane(frustum[i]); + } + } + + // ======================================================================= + + // stack variable + private final float[] temp = {0, 0, 0}; + /** + * R_SetupFrame + */ + void R_SetupFrame() { + r_framecount++; + + // build the transformation matrix for the given view angles + Math3D.VectorCopy(r_newrefdef.vieworg, r_origin); + + Math3D.AngleVectors(r_newrefdef.viewangles, vpn, vright, vup); + + // current viewcluster + mleaf_t leaf; + if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0) { + r_oldviewcluster = r_viewcluster; + r_oldviewcluster2 = r_viewcluster2; + leaf = Mod_PointInLeaf(r_origin, r_worldmodel); + r_viewcluster = r_viewcluster2 = leaf.cluster; + + // check above and below so crossing solid water doesn't draw wrong + if (leaf.contents == 0) { // look down a bit + Math3D.VectorCopy(r_origin, temp); + temp[2] -= 16; + leaf = Mod_PointInLeaf(temp, r_worldmodel); + if ((leaf.contents & Defines.CONTENTS_SOLID) == 0 && (leaf.cluster != r_viewcluster2)) + r_viewcluster2 = leaf.cluster; + } + else { // look up a bit + Math3D.VectorCopy(r_origin, temp); + temp[2] += 16; + leaf = Mod_PointInLeaf(temp, r_worldmodel); + if ((leaf.contents & Defines.CONTENTS_SOLID) == 0 && (leaf.cluster != r_viewcluster2)) + r_viewcluster2 = leaf.cluster; + } + } + + for (int i = 0; i < 4; i++) + v_blend[i] = r_newrefdef.blend[i]; + + c_brush_polys = 0; + c_alias_polys = 0; + + // clear out the portion of the screen that the NOWORLDMODEL defines + if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0) { + GL11.glEnable(GL11.GL_SCISSOR_TEST); + GL11.glClearColor(0.3f, 0.3f, 0.3f, 1.0f); + GL11.glScissor( + r_newrefdef.x, + vid.height - r_newrefdef.height - r_newrefdef.y, + r_newrefdef.width, + r_newrefdef.height); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + GL11.glClearColor(1.0f, 0.0f, 0.5f, 0.5f); + GL11.glDisable(GL11.GL_SCISSOR_TEST); + } + } + + /** + * MYgluPerspective + * + * @param fovy + * @param aspect + * @param zNear + * @param zFar + */ + void MYgluPerspective(double fovy, double aspect, double zNear, double zFar) { + double ymax = zNear * Math.tan(fovy * Math.PI / 360.0); + double ymin = -ymax; + + double xmin = ymin * aspect; + double xmax = ymax * aspect; + + xmin += - (2 * gl_state.camera_separation) / zNear; + xmax += - (2 * gl_state.camera_separation) / zNear; + + GL11.glFrustum(xmin, xmax, ymin, ymax, zNear, zFar); + } + + /** + * R_SetupGL + */ + void R_SetupGL() { + + // + // set up viewport + // + //int x = (int) Math.floor(r_newrefdef.x * vid.width / vid.width); + int x = r_newrefdef.x; + //int x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width); + int x2 = r_newrefdef.x + r_newrefdef.width; + //int y = (int) Math.floor(vid.height - r_newrefdef.y * vid.height / vid.height); + int y = vid.height - r_newrefdef.y; + //int y2 = (int) Math.ceil(vid.height - (r_newrefdef.y + r_newrefdef.height) * vid.height / vid.height); + int y2 = vid.height - (r_newrefdef.y + r_newrefdef.height); + + int w = x2 - x; + int h = y - y2; + + GL11.glViewport(x, y2, w, h); + + // + // set up projection matrix + // + float screenaspect = (float) r_newrefdef.width / r_newrefdef.height; + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + MYgluPerspective(r_newrefdef.fov_y, screenaspect, 4, 4096); + + GL11.glCullFace(GL11.GL_FRONT); + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + + GL11.glRotatef(-90, 1, 0, 0); // put Z going up + GL11.glRotatef(90, 0, 0, 1); // put Z going up + GL11.glRotatef(-r_newrefdef.viewangles[2], 1, 0, 0); + GL11.glRotatef(-r_newrefdef.viewangles[0], 0, 1, 0); + GL11.glRotatef(-r_newrefdef.viewangles[1], 0, 0, 1); + GL11.glTranslatef(-r_newrefdef.vieworg[0], -r_newrefdef.vieworg[1], -r_newrefdef.vieworg[2]); + + GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, r_world_matrix); + r_world_matrix.clear(); + + // + // set drawing parms + // + if (gl_cull.value != 0.0f) + GL11.glEnable(GL11.GL_CULL_FACE); + else + GL11.glDisable(GL11.GL_CULL_FACE); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + int trickframe = 0; + + /** + * R_Clear + */ + void R_Clear() { + if (gl_ztrick.value != 0.0f) { + + if (gl_clear.value != 0.0f) { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + } + + trickframe++; + if ((trickframe & 1) != 0) { + gldepthmin = 0; + gldepthmax = 0.49999f; + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + else { + gldepthmin = 1; + gldepthmax = 0.5f; + GL11.glDepthFunc(GL11.GL_GEQUAL); + } + } + else { + if (gl_clear.value != 0.0f) + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + else + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + + gldepthmin = 0; + gldepthmax = 1; + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + GL11.glDepthRange(gldepthmin, gldepthmax); + } + + /** + * R_Flash + */ + void R_Flash() { + R_PolyBlend(); + } + + /** + * R_RenderView + * r_newrefdef must be set before the first call + */ + void R_RenderView(refdef_t fd) { + + if (r_norefresh.value != 0.0f) + return; + + r_newrefdef = fd; + + // included by cwei + if (r_newrefdef == null) { + Com.Error(Defines.ERR_DROP, "R_RenderView: refdef_t fd is null"); + } + + if (r_worldmodel == null && (r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0) + Com.Error(Defines.ERR_DROP, "R_RenderView: NULL worldmodel"); + + if (r_speeds.value != 0.0f) { + c_brush_polys = 0; + c_alias_polys = 0; + } + + R_PushDlights(); + + if (gl_finish.value != 0.0f) + GL11.glFinish(); + + R_SetupFrame(); + + R_SetFrustum(); + + R_SetupGL(); + + R_MarkLeaves(); // done here so we know if we're in water + + R_DrawWorld(); + + R_DrawEntitiesOnList(); + + R_RenderDlights(); + + R_DrawParticles(); + + R_DrawAlphaSurfaces(); + + R_Flash(); + + if (r_speeds.value != 0.0f) { + VID.Printf( + Defines.PRINT_ALL, + "%4i wpoly %4i epoly %i tex %i lmaps\n", + new Vargs(4).add(c_brush_polys).add(c_alias_polys).add(c_visible_textures).add(c_visible_lightmaps)); + } + } + + /** + * R_SetGL2D + */ + void R_SetGL2D() { + // set 2D virtual screen size + GL11.glViewport(0, 0, vid.width, vid.height); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glOrtho(0, vid.width, vid.height, 0, -99999, 99999); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glColor4f(1, 1, 1, 1); + } + + // stack variable + private final float[] light = { 0, 0, 0 }; + /** + * R_SetLightLevel + */ + void R_SetLightLevel() { + if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0) + return; + + // save off light value for server to look at (BIG HACK!) + + R_LightPoint(r_newrefdef.vieworg, light); + + // pick the greatest component, which should be the same + // as the mono value returned by software + if (light[0] > light[1]) { + if (light[0] > light[2]) + r_lightlevel.value = 150 * light[0]; + else + r_lightlevel.value = 150 * light[2]; + } + else { + if (light[1] > light[2]) + r_lightlevel.value = 150 * light[1]; + else + r_lightlevel.value = 150 * light[2]; + } + } + + /** + * R_RenderFrame + */ + protected void R_RenderFrame(refdef_t fd) { + R_RenderView(fd); + R_SetLightLevel(); + R_SetGL2D(); + } + + /** + * R_Register + */ + protected void R_Register() { + r_lefthand = Cvar.Get("hand", "0", Globals.CVAR_USERINFO | Globals.CVAR_ARCHIVE); + r_norefresh = Cvar.Get("r_norefresh", "0", 0); + r_fullbright = Cvar.Get("r_fullbright", "0", 0); + r_drawentities = Cvar.Get("r_drawentities", "1", 0); + r_drawworld = Cvar.Get("r_drawworld", "1", 0); + r_novis = Cvar.Get("r_novis", "0", 0); + r_nocull = Cvar.Get("r_nocull", "0", 0); + r_lerpmodels = Cvar.Get("r_lerpmodels", "1", 0); + r_speeds = Cvar.Get("r_speeds", "0", 0); + + r_lightlevel = Cvar.Get("r_lightlevel", "1", 0); + + gl_nosubimage = Cvar.Get("gl_nosubimage", "0", 0); + gl_allow_software = Cvar.Get("gl_allow_software", "0", 0); + + gl_particle_min_size = Cvar.Get("gl_particle_min_size", "2", Globals.CVAR_ARCHIVE); + gl_particle_max_size = Cvar.Get("gl_particle_max_size", "40", Globals.CVAR_ARCHIVE); + gl_particle_size = Cvar.Get("gl_particle_size", "40", Globals.CVAR_ARCHIVE); + gl_particle_att_a = Cvar.Get("gl_particle_att_a", "0.01", Globals.CVAR_ARCHIVE); + gl_particle_att_b = Cvar.Get("gl_particle_att_b", "0.0", Globals.CVAR_ARCHIVE); + gl_particle_att_c = Cvar.Get("gl_particle_att_c", "0.01", Globals.CVAR_ARCHIVE); + + gl_modulate = Cvar.Get("gl_modulate", "1.5", Globals.CVAR_ARCHIVE); + gl_log = Cvar.Get("gl_log", "0", 0); + gl_bitdepth = Cvar.Get("gl_bitdepth", "0", 0); + gl_mode = Cvar.Get("gl_mode", "3", Globals.CVAR_ARCHIVE); // 640x480 + gl_lightmap = Cvar.Get("gl_lightmap", "0", 0); + gl_shadows = Cvar.Get("gl_shadows", "0", Globals.CVAR_ARCHIVE); + gl_dynamic = Cvar.Get("gl_dynamic", "1", 0); + gl_nobind = Cvar.Get("gl_nobind", "0", 0); + gl_round_down = Cvar.Get("gl_round_down", "1", 0); + gl_picmip = Cvar.Get("gl_picmip", "0", 0); + gl_skymip = Cvar.Get("gl_skymip", "0", 0); + gl_showtris = Cvar.Get("gl_showtris", "0", 0); + gl_ztrick = Cvar.Get("gl_ztrick", "0", 0); + gl_finish = Cvar.Get("gl_finish", "0", Globals.CVAR_ARCHIVE); + gl_clear = Cvar.Get("gl_clear", "0", 0); + gl_cull = Cvar.Get("gl_cull", "1", 0); + gl_polyblend = Cvar.Get("gl_polyblend", "1", 0); + gl_flashblend = Cvar.Get("gl_flashblend", "0", 0); + gl_playermip = Cvar.Get("gl_playermip", "0", 0); + gl_monolightmap = Cvar.Get("gl_monolightmap", "0", 0); + gl_driver = Cvar.Get("gl_driver", "opengl32", Globals.CVAR_ARCHIVE); + gl_texturemode = Cvar.Get("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", Globals.CVAR_ARCHIVE); + gl_texturealphamode = Cvar.Get("gl_texturealphamode", "default", Globals.CVAR_ARCHIVE); + gl_texturesolidmode = Cvar.Get("gl_texturesolidmode", "default", Globals.CVAR_ARCHIVE); + gl_lockpvs = Cvar.Get("gl_lockpvs", "0", 0); + + gl_vertex_arrays = Cvar.Get("gl_vertex_arrays", "1", Globals.CVAR_ARCHIVE); + + gl_ext_swapinterval = Cvar.Get("gl_ext_swapinterval", "1", Globals.CVAR_ARCHIVE); + gl_ext_palettedtexture = Cvar.Get("gl_ext_palettedtexture", "0", Globals.CVAR_ARCHIVE); + gl_ext_multitexture = Cvar.Get("gl_ext_multitexture", "1", Globals.CVAR_ARCHIVE); + gl_ext_pointparameters = Cvar.Get("gl_ext_pointparameters", "1", Globals.CVAR_ARCHIVE); + gl_ext_compiled_vertex_array = Cvar.Get("gl_ext_compiled_vertex_array", "1", Globals.CVAR_ARCHIVE); + + gl_drawbuffer = Cvar.Get("gl_drawbuffer", "GL_BACK", 0); + gl_swapinterval = Cvar.Get("gl_swapinterval", "0", Globals.CVAR_ARCHIVE); + + gl_saturatelighting = Cvar.Get("gl_saturatelighting", "0", 0); + + gl_3dlabs_broken = Cvar.Get("gl_3dlabs_broken", "1", Globals.CVAR_ARCHIVE); + + vid_fullscreen = Cvar.Get("vid_fullscreen", "0", Globals.CVAR_ARCHIVE); + vid_gamma = Cvar.Get("vid_gamma", "1.0", Globals.CVAR_ARCHIVE); + vid_ref = Cvar.Get("vid_ref", "lwjgl", Globals.CVAR_ARCHIVE); + + Cmd.AddCommand("imagelist", this::GL_ImageList_f); + + Cmd.AddCommand("screenshot", this::GL_ScreenShot_f); + Cmd.AddCommand("modellist", this::Mod_Modellist_f); + Cmd.AddCommand("gl_strings", this::GL_Strings_f); + } + + /** + * R_SetMode + */ + protected boolean R_SetMode() { + boolean fullscreen = (vid_fullscreen.value > 0.0f); + + vid_fullscreen.modified = false; + gl_mode.modified = false; + + Dimension dim = new Dimension(vid.width, vid.height); + + int err; // enum rserr_t + if ((err = GLimp_SetMode(dim, (int) gl_mode.value, fullscreen)) == rserr_ok) { + gl_state.prev_mode = (int) gl_mode.value; + } + else { + if (err == rserr_invalid_fullscreen) { + Cvar.SetValue("vid_fullscreen", 0); + vid_fullscreen.modified = false; + log.warn("ref_gl::R_SetMode() - fullscreen unavailable in this mode"); + if ((err = GLimp_SetMode(dim, (int) gl_mode.value, false)) == rserr_ok) + return true; + } + else if (err == rserr_invalid_mode) { + Cvar.SetValue("gl_mode", gl_state.prev_mode); + gl_mode.modified = false; + log.warn("ref_gl::R_SetMode() - invalid mode"); + } + + // try setting it back to something safe + if ((err = GLimp_SetMode(dim, gl_state.prev_mode, false)) != rserr_ok) { + log.warn("ref_gl::R_SetMode() - could not revert to safe mode"); + return false; + } + } + return true; + } + + float[] r_turbsin = new float[256]; + + /** + * R_Init + */ + protected boolean R_Init(int vid_xpos, int vid_ypos) { + + assert(Warp.SIN.length == 256) : "warpsin table bug"; + + // fill r_turbsin + for (int j = 0; j < 256; j++) { + r_turbsin[j] = Warp.SIN[j] * 0.5f; + } + + log.info("ref_gl version: {}", REF_VERSION); + + Draw_GetPalette(); + + R_Register(); + + // set our "safe" modes + gl_state.prev_mode = 3; + + // create the window and set up the context + if (!R_SetMode()) { + log.info("ref_gl::R_Init() - could not R_SetMode()"); + return false; + } + return true; + } + + /** + * R_Init2 + */ + protected boolean R_Init2() { + VID.MenuInit(); + + /* + ** get our various GL strings + */ + gl_config.vendor_string = GL11.glGetString(GL11.GL_VENDOR); + log.info("GL_VENDOR: {}", gl_config.vendor_string); + gl_config.renderer_string = GL11.glGetString(GL11.GL_RENDERER); + log.info("GL_RENDERER: {}", gl_config.renderer_string); + gl_config.version_string = GL11.glGetString(GL11.GL_VERSION); + log.info("GL_VERSION: {}", gl_config.version_string); + gl_config.extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS); + log.info("GL_EXTENSIONS: {}", gl_config.extensions_string); + + gl_config.parseOpenGLVersion(); + + String renderer_buffer = gl_config.renderer_string.toLowerCase(); + String vendor_buffer = gl_config.vendor_string.toLowerCase(); + + if (renderer_buffer.indexOf("voodoo") >= 0) { + if (renderer_buffer.indexOf("rush") < 0) + gl_config.renderer = GL_RENDERER_VOODOO; + else + gl_config.renderer = GL_RENDERER_VOODOO_RUSH; + } + else if (vendor_buffer.indexOf("sgi") >= 0) + gl_config.renderer = GL_RENDERER_SGI; + else if (renderer_buffer.indexOf("permedia") >= 0) + gl_config.renderer = GL_RENDERER_PERMEDIA2; + else if (renderer_buffer.indexOf("glint") >= 0) + gl_config.renderer = GL_RENDERER_GLINT_MX; + else if (renderer_buffer.indexOf("glzicd") >= 0) + gl_config.renderer = GL_RENDERER_REALIZM; + else if (renderer_buffer.indexOf("gdi") >= 0) + gl_config.renderer = GL_RENDERER_MCD; + else if (renderer_buffer.indexOf("pcx2") >= 0) + gl_config.renderer = GL_RENDERER_PCX2; + else if (renderer_buffer.indexOf("verite") >= 0) + gl_config.renderer = GL_RENDERER_RENDITION; + else + gl_config.renderer = GL_RENDERER_OTHER; + + String monolightmap = gl_monolightmap.string.toUpperCase(); + if (monolightmap.length() < 2 || monolightmap.charAt(1) != 'F') { + if (gl_config.renderer == GL_RENDERER_PERMEDIA2) { + Cvar.Set("gl_monolightmap", "A"); + log.info("...using gl_monolightmap 'a'"); + } + else if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) { + Cvar.Set("gl_monolightmap", "0"); + } + else { + Cvar.Set("gl_monolightmap", "0"); + } + } + + // power vr can't have anything stay in the framebuffer, so + // the screen needs to redraw the tiled background every frame + if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) { + Cvar.Set("scr_drawall", "1"); + } + else { + Cvar.Set("scr_drawall", "0"); + } + + // MCD has buffering issues + if (gl_config.renderer == GL_RENDERER_MCD) { + Cvar.SetValue("gl_finish", 1); + } + + if ((gl_config.renderer & GL_RENDERER_3DLABS) != 0) { + if (gl_3dlabs_broken.value != 0.0f) + gl_config.allow_cds = false; + else + gl_config.allow_cds = true; + } + else { + gl_config.allow_cds = true; + } + + if (gl_config.allow_cds) + log.info("...allowing CDS"); + else + log.info("...disabling CDS"); + + /* + ** grab extensions + */ + if (gl_config.extensions_string.indexOf("GL_EXT_compiled_vertex_array") >= 0 + || gl_config.extensions_string.indexOf("GL_SGI_compiled_vertex_array") >= 0) { + log.info("...enabling GL_EXT_compiled_vertex_array"); + // qglLockArraysEXT = ( void * ) qwglGetProcAddress( "glLockArraysEXT" ); + if (gl_ext_compiled_vertex_array.value != 0.0f) + qglLockArraysEXT = true; + else + qglLockArraysEXT = false; + // qglUnlockArraysEXT = ( void * ) qwglGetProcAddress( "glUnlockArraysEXT" ); + //qglUnlockArraysEXT = true; + } + else { + log.info("...GL_EXT_compiled_vertex_array not found"); + qglLockArraysEXT = false; + } + + if (gl_config.extensions_string.indexOf("WGL_EXT_swap_control") >= 0) { + qwglSwapIntervalEXT = true; + log.info("...enabling WGL_EXT_swap_control"); + } else { + qwglSwapIntervalEXT = false; + log.info("...WGL_EXT_swap_control not found"); + } + + if (gl_config.extensions_string.indexOf("GL_EXT_point_parameters") >= 0) { + if (gl_ext_pointparameters.value != 0.0f) { + // qglPointParameterfEXT = ( void (APIENTRY *)( GLenum, GLfloat ) ) qwglGetProcAddress( "glPointParameterfEXT" ); + qglPointParameterfEXT = true; + // qglPointParameterfvEXT = ( void (APIENTRY *)( GLenum, const GLfloat * ) ) qwglGetProcAddress( "glPointParameterfvEXT" ); + log.info("...using GL_EXT_point_parameters"); + } + else { + log.info("...ignoring GL_EXT_point_parameters"); + } + } + else { + log.info("...GL_EXT_point_parameters not found"); + } + + // #ifdef __linux__ + // if ( strstr( gl_config.extensions_string, "3DFX_set_global_palette" )) + // { + // if ( gl_ext_palettedtexture->value ) + // { + // VID.Printf( Defines.PRINT_ALL, "...using 3DFX_set_global_palette\n" ); + // qgl3DfxSetPaletteEXT = ( void ( APIENTRY * ) (GLuint *) )qwglGetProcAddress( "gl3DfxSetPaletteEXT" ); + //// qglColorTableEXT = Fake_glColorTableEXT; + // } + // else + // { + // VID.Printf( Defines.PRINT_ALL, "...ignoring 3DFX_set_global_palette\n" ); + // } + // } + // else + // { + // VID.Printf( Defines.PRINT_ALL, "...3DFX_set_global_palette not found\n" ); + // } + // #endif + + if (!qglColorTableEXT + && gl_config.extensions_string.indexOf("GL_EXT_paletted_texture") >= 0 + && gl_config.extensions_string.indexOf("GL_EXT_shared_texture_palette") >= 0) { + if (gl_ext_palettedtexture.value != 0.0f) { + log.info("...using GL_EXT_shared_texture_palette"); + qglColorTableEXT = false; // true; TODO jogl bug + } + else { + log.info("...ignoring GL_EXT_shared_texture_palette"); + qglColorTableEXT = false; + } + } + else { + log.info("...GL_EXT_shared_texture_palette not found"); + } + + if (gl_config.extensions_string.indexOf("GL_ARB_multitexture") >= 0) { + log.info("...using GL_ARB_multitexture"); + qglActiveTextureARB = true; + GL_TEXTURE0 = ARBMultitexture.GL_TEXTURE0_ARB; + GL_TEXTURE1 = ARBMultitexture.GL_TEXTURE1_ARB; + } + else { + log.info("...GL_ARB_multitexture not found"); + } + + if (!(qglActiveTextureARB)) + return false; + + GL_SetDefaultState(); + + GL_InitImages(); + Mod_Init(); + R_InitParticleTexture(); + Draw_InitLocal(); + + int err = GL11.glGetError(); + if (err != GL11.GL_NO_ERROR) + VID.Printf( + Defines.PRINT_ALL, + "glGetError() = 0x%x\n\t%s\n", + new Vargs(2).add(err).add("" + GL11.glGetString(err))); + + return true; + } + + /** + * R_Shutdown + */ + protected void R_Shutdown() { + Cmd.RemoveCommand("modellist"); + Cmd.RemoveCommand("screenshot"); + Cmd.RemoveCommand("imagelist"); + Cmd.RemoveCommand("gl_strings"); + + Mod_FreeAll(); + + GL_ShutdownImages(); + + /* + * shut down OS specific OpenGL stuff like contexts, etc. + */ + GLimp_Shutdown(); + } + + /** + * R_BeginFrame + */ + protected void R_BeginFrame(float camera_separation) { + + gl_state.camera_separation = camera_separation; + + /* + ** change modes if necessary + */ + if (gl_mode.modified || vid_fullscreen.modified) { + // FIXME: only restart if CDS is required + cvar_t ref; + + ref = Cvar.Get("vid_ref", "lwjgl", 0); + ref.modified = true; + } + + if (gl_log.modified) { + GLimp_EnableLogging((gl_log.value != 0.0f)); + gl_log.modified = false; + } + + if (gl_log.value != 0.0f) { + GLimp_LogNewFrame(); + } + + /* + ** update 3Dfx gamma -- it is expected that a user will do a vid_restart + ** after tweaking this value + */ + if (vid_gamma.modified) { + vid_gamma.modified = false; + + if ((gl_config.renderer & GL_RENDERER_VOODOO) != 0) { + // wird erstmal nicht gebraucht + + /* + char envbuffer[1024]; + float g; + + g = 2.00 * ( 0.8 - ( vid_gamma->value - 0.5 ) ) + 1.0F; + Com_sprintf( envbuffer, sizeof(envbuffer), "SSTV2_GAMMA=%f", g ); + putenv( envbuffer ); + Com_sprintf( envbuffer, sizeof(envbuffer), "SST_GAMMA=%f", g ); + putenv( envbuffer ); + */ + VID.Printf(Defines.PRINT_DEVELOPER, "gamma anpassung fuer VOODOO nicht gesetzt"); + } + } + + GLimp_BeginFrame(camera_separation); + + /* + ** go into 2D mode + */ + GL11.glViewport(0, 0, vid.width, vid.height); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glOrtho(0, vid.width, vid.height, 0, -99999, 99999); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glColor4f(1, 1, 1, 1); + + /* + ** draw buffer stuff + */ + if (gl_drawbuffer.modified) { + gl_drawbuffer.modified = false; + + if (gl_state.camera_separation == 0 || !gl_state.stereo_enabled) { + if (gl_drawbuffer.string.equalsIgnoreCase("GL_FRONT")) + GL11.glDrawBuffer(GL11.GL_FRONT); + else + GL11.glDrawBuffer(GL11.GL_BACK); + } + } + + /* + ** texturemode stuff + */ + if (gl_texturemode.modified) { + GL_TextureMode(gl_texturemode.string); + gl_texturemode.modified = false; + } + + if (gl_texturealphamode.modified) { + GL_TextureAlphaMode(gl_texturealphamode.string); + gl_texturealphamode.modified = false; + } + + if (gl_texturesolidmode.modified) { + GL_TextureSolidMode(gl_texturesolidmode.string); + gl_texturesolidmode.modified = false; + } + + /* + ** swapinterval stuff + */ + GL_UpdateSwapInterval(); + + // + // clear screen if desired + // + R_Clear(); + } + + int[] r_rawpalette = new int[256]; + + /** + * R_SetPalette + */ + protected void R_SetPalette(byte[] palette) { + // 256 RGB values (768 bytes) + // or null + int i; + int color = 0; + + if (palette != null) { + int j =0; + for (i = 0; i < 256; i++) { + color = (palette[j++] & 0xFF) << 0; + color |= (palette[j++] & 0xFF) << 8; + color |= (palette[j++] & 0xFF) << 16; + color |= 0xFF000000; + r_rawpalette[i] = color; + } + } + else { + for (i = 0; i < 256; i++) { + r_rawpalette[i] = d_8to24table[i] | 0xff000000; + } + } + GL_SetTexturePalette(r_rawpalette); + + GL11.glClearColor(0, 0, 0, 0); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + GL11.glClearColor(1f, 0f, 0.5f, 0.5f); + } + + static final int NUM_BEAM_SEGS = 6; + float[][] start_points = new float[NUM_BEAM_SEGS][3]; + // array of vec3_t + float[][] end_points = new float[NUM_BEAM_SEGS][3]; // array of vec3_t + + // stack variable + private final float[] perpvec = { 0, 0, 0 }; // vec3_t + private final float[] direction = { 0, 0, 0 }; // vec3_t + private final float[] normalized_direction = { 0, 0, 0 }; // vec3_t + private final float[] oldorigin = { 0, 0, 0 }; // vec3_t + private final float[] origin = { 0, 0, 0 }; // vec3_t + /** + * R_DrawBeam + */ + void R_DrawBeam(entity_t e) { + oldorigin[0] = e.oldorigin[0]; + oldorigin[1] = e.oldorigin[1]; + oldorigin[2] = e.oldorigin[2]; + + origin[0] = e.origin[0]; + origin[1] = e.origin[1]; + origin[2] = e.origin[2]; + + normalized_direction[0] = direction[0] = oldorigin[0] - origin[0]; + normalized_direction[1] = direction[1] = oldorigin[1] - origin[1]; + normalized_direction[2] = direction[2] = oldorigin[2] - origin[2]; + + if (Math3D.VectorNormalize(normalized_direction) == 0.0f) + return; + + Math3D.PerpendicularVector(perpvec, normalized_direction); + Math3D.VectorScale(perpvec, e.frame / 2, perpvec); + + for (int i = 0; i < 6; i++) { + Math3D.RotatePointAroundVector( + start_points[i], + normalized_direction, + perpvec, + (360.0f / NUM_BEAM_SEGS) * i); + + Math3D.VectorAdd(start_points[i], origin, start_points[i]); + Math3D.VectorAdd(start_points[i], direction, end_points[i]); + } + + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDepthMask(false); + + float r = (d_8to24table[e.skinnum & 0xFF]) & 0xFF; + float g = (d_8to24table[e.skinnum & 0xFF] >> 8) & 0xFF; + float b = (d_8to24table[e.skinnum & 0xFF] >> 16) & 0xFF; + + r *= 1 / 255.0f; + g *= 1 / 255.0f; + b *= 1 / 255.0f; + + GL11.glColor4f(r, g, b, e.alpha); + + GL11.glBegin(GL11.GL_TRIANGLE_STRIP); + + float[] v; + + for (int i = 0; i < NUM_BEAM_SEGS; i++) { + v = start_points[i]; + GL11.glVertex3f(v[0], v[1], v[2]); + v = end_points[i]; + GL11.glVertex3f(v[0], v[1], v[2]); + v = start_points[(i + 1) % NUM_BEAM_SEGS]; + GL11.glVertex3f(v[0], v[1], v[2]); + v = end_points[(i + 1) % NUM_BEAM_SEGS]; + GL11.glVertex3f(v[0], v[1], v[2]); + } + GL11.glEnd(); + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/render/lwjgl/Mesh.java b/src/main/java/lwjake2/render/lwjgl/Mesh.java index f04808b..b5ead42 100644 --- a/src/main/java/lwjake2/render/lwjgl/Mesh.java +++ b/src/main/java/lwjake2/render/lwjgl/Mesh.java @@ -39,646 +39,646 @@ import org.lwjgl.opengl.GL11; */ public abstract class Mesh extends Light { - // g_mesh.c: triangle model functions - /* - ============================================================= - - ALIAS MODELS - - ============================================================= - */ - - static final int NUMVERTEXNORMALS = 162; - - float[][] r_avertexnormals = Anorms.VERTEXNORMALS; - float[] shadevector = {0, 0, 0}; - float[] shadelight = {0, 0, 0}; - - // precalculated dot products for quantized angles - static final int SHADEDOT_QUANT = 16; - - float[][] r_avertexnormal_dots = Anorms.VERTEXNORMAL_DOTS; - - float[] shadedots = r_avertexnormal_dots[0]; - - /** - * GL_LerpVerts - * @param nverts - * @param ov - * @param verts - * @param move - * @param frontv - * @param backv - */ - void GL_LerpVerts(int nverts, int[] ov, int[] v, float[] move, float[] frontv, float[] backv ) - { - FloatBuffer lerp = vertexArrayBuf; - lerp.limit((nverts << 2) - nverts); // nverts * 3 - - int ovv, vv; - //PMM -- added RF_SHELL_DOUBLE, RF_SHELL_HALF_DAM - if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0 ) - { - float[] normal; - int j = 0; - for (int i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) - { - vv = v[i]; - normal = r_avertexnormals[(vv >>> 24 ) & 0xFF]; - ovv = ov[i]; - lerp.put(j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF) * frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); - lerp.put(j + 1, move[1] + ((ovv >>> 8) & 0xFF) * backv[1] + ((vv >>> 8) & 0xFF) * frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); - lerp.put(j + 2, move[2] + ((ovv >>> 16) & 0xFF) * backv[2] + ((vv >>> 16) & 0xFF) * frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); - j += 3; - } - } - else - { - int j = 0; - for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) - { - ovv = ov[i]; - vv = v[i]; - - lerp.put(j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF)*frontv[0]); - lerp.put(j + 1, move[1] + ((ovv >>> 8) & 0xFF)* backv[1] + ((vv >>> 8) & 0xFF)*frontv[1]); - lerp.put(j + 2, move[2] + ((ovv >>> 16) & 0xFF)* backv[2] + ((vv >>> 16) & 0xFF)*frontv[2]); - j += 3; - } - } - } - - FloatBuffer colorArrayBuf = BufferUtils.createFloatBuffer(qfiles.MAX_VERTS * 4); - FloatBuffer vertexArrayBuf = BufferUtils.createFloatBuffer(qfiles.MAX_VERTS * 3); - FloatBuffer textureArrayBuf = BufferUtils.createFloatBuffer(qfiles.MAX_VERTS * 2); - boolean isFilled = false; - float[] tmpVec = {0, 0, 0}; - float[][] vectors = { - {0, 0, 0}, {0, 0, 0}, {0, 0, 0} // 3 mal vec3_t - }; - - // stack variable - private final float[] move = {0, 0, 0}; // vec3_t - private final float[] frontv = {0, 0, 0}; // vec3_t - private final float[] backv = {0, 0, 0}; // vec3_t - /** - * GL_DrawAliasFrameLerp - * - * interpolates between two frames and origins - * FIXME: batch lerp all vertexes - */ - void GL_DrawAliasFrameLerp(qfiles.dmdl_t paliashdr, float backlerp) - { - qfiles.daliasframe_t frame = paliashdr.aliasFrames[currententity.frame]; - - int[] verts = frame.verts; - - qfiles.daliasframe_t oldframe = paliashdr.aliasFrames[currententity.oldframe]; - - int[] ov = oldframe.verts; - - float alpha; - if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) - alpha = currententity.alpha; - else - alpha = 1.0f; - - // PMM - added double shell - if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0) - GL11.glDisable( GL11.GL_TEXTURE_2D ); - - float frontlerp = 1.0f - backlerp; - - // move should be the delta back to the previous frame * backlerp - Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, frontv); - Math3D.AngleVectors (currententity.angles, vectors[0], vectors[1], vectors[2]); - - move[0] = Math3D.DotProduct (frontv, vectors[0]); // forward - move[1] = -Math3D.DotProduct (frontv, vectors[1]); // left - move[2] = Math3D.DotProduct (frontv, vectors[2]); // up - - Math3D.VectorAdd (move, oldframe.translate, move); - - for (int i=0 ; i<3 ; i++) - { - move[i] = backlerp*move[i] + frontlerp*frame.translate[i]; - frontv[i] = frontlerp*frame.scale[i]; - backv[i] = backlerp*oldframe.scale[i]; - } - - // ab hier wird optimiert - - GL_LerpVerts( paliashdr.num_xyz, ov, verts, move, frontv, backv ); - - //GL11.glEnableClientState( GL11.GL_VERTEX_ARRAY ); - GL11.glVertexPointer( 3, 0, vertexArrayBuf ); - - // PMM - added double damage shell - if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0) - { - GL11.glColor4f( shadelight[0], shadelight[1], shadelight[2], alpha ); - } - else - { - GL11.glEnableClientState( GL11.GL_COLOR_ARRAY ); - GL11.glColorPointer( 4, 0, colorArrayBuf ); - - // - // pre light everything - // - FloatBuffer color = colorArrayBuf; - float l; - int size = paliashdr.num_xyz; - int j = 0; - for (int i = 0; i < size; i++ ) - { - l = shadedots[(verts[i] >>> 24) & 0xFF]; - color.put(j, l * shadelight[0]); - color.put(j + 1, l * shadelight[1]); - color.put(j + 2, l * shadelight[2]); - color.put(j + 3, alpha); - j += 4; - } - } - - ARBMultitexture.glClientActiveTextureARB(GL_TEXTURE0); - GL11.glTexCoordPointer( 2, 0, textureArrayBuf); - //GL11.glEnableClientState( GL11.GL_TEXTURE_COORD_ARRAY); - - int pos = 0; - int[] counts = paliashdr.counts; - - IntBuffer srcIndexBuf = null; - - FloatBuffer dstTextureCoords = textureArrayBuf; - FloatBuffer srcTextureCoords = paliashdr.textureCoordBuf; - - int dstIndex = 0; - int srcIndex = 0; - int count; - int mode; - int size = counts.length; - for (int j = 0; j < size; j++) { - - // get the vertex count and primitive type - count = counts[j]; - if (count == 0) - break; // done - - srcIndexBuf = paliashdr.indexElements[j]; - - mode = GL11.GL_TRIANGLE_STRIP; - if (count < 0) { - mode = GL11.GL_TRIANGLE_FAN; - count = -count; - } - srcIndex = pos << 1; - srcIndex--; - for (int k = 0; k < count; k++) { - dstIndex = srcIndexBuf.get(k) << 1; - dstTextureCoords.put(dstIndex, srcTextureCoords.get(++srcIndex)); - dstTextureCoords.put(++dstIndex, srcTextureCoords.get(++srcIndex)); - } - - GL11.glDrawElements(mode, srcIndexBuf); - pos += count; - } - - // PMM - added double damage shell - if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0 ) - GL11.glEnable( GL11.GL_TEXTURE_2D ); - - GL11.glDisableClientState( GL11.GL_COLOR_ARRAY ); - } - - private final float[] point = {0, 0, 0}; - /** - * GL_DrawAliasShadow - */ - void GL_DrawAliasShadow(qfiles.dmdl_t paliashdr, int posenum) - { - float lheight = currententity.origin[2] - lightspot[2]; - // qfiles.daliasframe_t frame = paliashdr.aliasFrames[currententity.frame]; - int[] order = paliashdr.glCmds; - float height = -lheight + 1.0f; - - int orderIndex = 0; - int index = 0; - - // TODO shadow drawing with vertex arrays - - int count; - while (true) - { - // get the vertex count and primitive type - count = order[orderIndex++]; - if (count == 0) - break; // done - if (count < 0) - { - count = -count; - GL11.glBegin (GL11.GL_TRIANGLE_FAN); - } - else - GL11.glBegin (GL11.GL_TRIANGLE_STRIP); - - do - { - index = order[orderIndex + 2] * 3; - point[0] = vertexArrayBuf.get(index); - point[1] = vertexArrayBuf.get(index + 1); - point[2] = vertexArrayBuf.get(index + 2); - - point[0] -= shadevector[0]*(point[2]+lheight); - point[1] -= shadevector[1]*(point[2]+lheight); - point[2] = height; - GL11.glVertex3f(point[0], point[1], point[2]); - - orderIndex += 3; - - } while (--count != 0); - - GL11.glEnd (); - } - } - -// TODO sync with jogl renderer. hoz - // stack variable - private final float[] mins = { 0, 0, 0 }; - private final float[] maxs = { 0, 0, 0 }; - /** - * R_CullAliasModel - */ - boolean R_CullAliasModel(entity_t e) { - qfiles.dmdl_t paliashdr = (qfiles.dmdl_t) currentmodel.extradata; - - if ((e.frame >= paliashdr.num_frames) || (e.frame < 0)) { - VID.Printf(Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such frame " + e.frame + '\n'); - e.frame = 0; - } - if ((e.oldframe >= paliashdr.num_frames) || (e.oldframe < 0)) { - VID.Printf(Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such oldframe " + e.oldframe + '\n'); - e.oldframe = 0; - } - - qfiles.daliasframe_t pframe = paliashdr.aliasFrames[e.frame]; - qfiles.daliasframe_t poldframe = paliashdr.aliasFrames[e.oldframe]; - - /* - ** compute axially aligned mins and maxs - */ - if (pframe == poldframe) { - for (int i = 0; i < 3; i++) { - mins[i] = pframe.translate[i]; - maxs[i] = mins[i] + pframe.scale[i] * 255; - } - } else { - float thismaxs, oldmaxs; - for (int i = 0; i < 3; i++) { - thismaxs = pframe.translate[i] + pframe.scale[i] * 255; - - oldmaxs = poldframe.translate[i] + poldframe.scale[i] * 255; - - if (pframe.translate[i] < poldframe.translate[i]) - mins[i] = pframe.translate[i]; - else - mins[i] = poldframe.translate[i]; - - if (thismaxs > oldmaxs) - maxs[i] = thismaxs; - else - maxs[i] = oldmaxs; - } - } - - /* - ** compute a full bounding box - */ - float[] tmp; - for (int i = 0; i < 8; i++) { - tmp = bbox[i]; - if ((i & 1) != 0) - tmp[0] = mins[0]; - else - tmp[0] = maxs[0]; - - if ((i & 2) != 0) - tmp[1] = mins[1]; - else - tmp[1] = maxs[1]; - - if ((i & 4) != 0) - tmp[2] = mins[2]; - else - tmp[2] = maxs[2]; - } - - /* - ** rotate the bounding box - */ - tmp = mins; - Math3D.VectorCopy(e.angles, tmp); - tmp[YAW] = -tmp[YAW]; - Math3D.AngleVectors(tmp, vectors[0], vectors[1], vectors[2]); - - for (int i = 0; i < 8; i++) { - Math3D.VectorCopy(bbox[i], tmp); - - bbox[i][0] = Math3D.DotProduct(vectors[0], tmp); - bbox[i][1] = -Math3D.DotProduct(vectors[1], tmp); - bbox[i][2] = Math3D.DotProduct(vectors[2], tmp); - - Math3D.VectorAdd(e.origin, bbox[i], bbox[i]); - } - - int f, mask; - int aggregatemask = ~0; // 0xFFFFFFFF - - for (int p = 0; p < 8; p++) { - mask = 0; - - for (f = 0; f < 4; f++) { - float dp = Math3D.DotProduct(frustum[f].normal, bbox[p]); - - if ((dp - frustum[f].dist) < 0) { - mask |= (1 << f); - } - } - - aggregatemask &= mask; - } - - if (aggregatemask != 0) { - return true; - } - - return false; - } - - - // bounding box - float[][] bbox = { - {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, - {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} - }; - -// TODO sync with jogl renderer. hoz - /** - * R_DrawAliasModel - */ - void R_DrawAliasModel(entity_t e) - { - if ( ( e.flags & Defines.RF_WEAPONMODEL ) == 0) - { - if ( R_CullAliasModel(e) ) - return; - } - - if ( (e.flags & Defines.RF_WEAPONMODEL) != 0 ) - { - if ( r_lefthand.value == 2.0f ) - return; - } - - qfiles.dmdl_t paliashdr = (qfiles.dmdl_t)currentmodel.extradata; - - // - // get lighting information - // - // PMM - rewrote, reordered to handle new shells & mixing - // PMM - 3.20 code .. replaced with original way of doing it to keep mod authors happy - // - int i; - if ( (currententity.flags & ( Defines.RF_SHELL_HALF_DAM | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_RED | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE )) != 0 ) - { - Math3D.VectorClear(shadelight); - if ((currententity.flags & Defines.RF_SHELL_HALF_DAM) != 0) - { - shadelight[0] = 0.56f; - shadelight[1] = 0.59f; - shadelight[2] = 0.45f; - } - if ( (currententity.flags & Defines.RF_SHELL_DOUBLE) != 0 ) - { - shadelight[0] = 0.9f; - shadelight[1] = 0.7f; - } - if ( (currententity.flags & Defines.RF_SHELL_RED) != 0 ) - shadelight[0] = 1.0f; - if ( (currententity.flags & Defines.RF_SHELL_GREEN) != 0 ) - shadelight[1] = 1.0f; - if ( (currententity.flags & Defines.RF_SHELL_BLUE) != 0 ) - shadelight[2] = 1.0f; - } - - else if ( (currententity.flags & Defines.RF_FULLBRIGHT) != 0 ) - { - for (i=0 ; i<3 ; i++) - shadelight[i] = 1.0f; - } - else - { - R_LightPoint (currententity.origin, shadelight); - - // player lighting hack for communication back to server - // big hack! - if ( (currententity.flags & Defines.RF_WEAPONMODEL) != 0 ) - { - // pick the greatest component, which should be the same - // as the mono value returned by software - if (shadelight[0] > shadelight[1]) - { - if (shadelight[0] > shadelight[2]) - r_lightlevel.value = 150*shadelight[0]; - else - r_lightlevel.value = 150*shadelight[2]; - } - else - { - if (shadelight[1] > shadelight[2]) - r_lightlevel.value = 150*shadelight[1]; - else - r_lightlevel.value = 150*shadelight[2]; - } - } - - if ( gl_monolightmap.string.charAt(0) != '0' ) - { - float s = shadelight[0]; - - if ( s < shadelight[1] ) - s = shadelight[1]; - if ( s < shadelight[2] ) - s = shadelight[2]; - - shadelight[0] = s; - shadelight[1] = s; - shadelight[2] = s; - } - } - - if ( (currententity.flags & Defines.RF_MINLIGHT) != 0 ) - { - for (i=0 ; i<3 ; i++) - if (shadelight[i] > 0.1f) - break; - if (i == 3) - { - shadelight[0] = 0.1f; - shadelight[1] = 0.1f; - shadelight[2] = 0.1f; - } - } - - if ( (currententity.flags & Defines.RF_GLOW) != 0 ) - { // bonus items will pulse with time - float scale; - float min; - - scale = (float)(0.1f * Math.sin(r_newrefdef.time*7)); - for (i=0 ; i<3 ; i++) - { - min = shadelight[i] * 0.8f; - shadelight[i] += scale; - if (shadelight[i] < min) - shadelight[i] = min; - } - } - - // ================= - // PGM ir goggles color override - if ( (r_newrefdef.rdflags & Defines.RDF_IRGOGGLES) != 0 && (currententity.flags & Defines.RF_IR_VISIBLE) != 0) - { - shadelight[0] = 1.0f; - shadelight[1] = 0.0f; - shadelight[2] = 0.0f; - } - // PGM - // ================= - - shadedots = r_avertexnormal_dots[((int)(currententity.angles[1] * (SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)]; - - float an = (float)(currententity.angles[1]/180*Math.PI); - shadevector[0] = (float)Math.cos(-an); - shadevector[1] = (float)Math.sin(-an); - shadevector[2] = 1; - Math3D.VectorNormalize(shadevector); - - // - // locate the proper data - // - - c_alias_polys += paliashdr.num_tris; - - // - // draw all the triangles - // - if ( (currententity.flags & Defines.RF_DEPTHHACK) != 0) // hack the depth range to prevent view model from poking into walls - GL11.glDepthRange(gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin)); - - if ( (currententity.flags & Defines.RF_WEAPONMODEL) != 0 && (r_lefthand.value == 1.0f) ) - { - GL11.glMatrixMode( GL11.GL_PROJECTION ); - GL11.glPushMatrix(); - GL11.glLoadIdentity(); - GL11.glScalef( -1, 1, 1 ); - MYgluPerspective( r_newrefdef.fov_y, ( float ) r_newrefdef.width / r_newrefdef.height, 4, 4096); - GL11.glMatrixMode( GL11.GL_MODELVIEW ); - - GL11.glCullFace( GL11.GL_BACK ); - } - - GL11.glPushMatrix (); - e.angles[PITCH] = -e.angles[PITCH]; // sigh. - R_RotateForEntity (e); - e.angles[PITCH] = -e.angles[PITCH]; // sigh. - - - - image_t skin; - // select skin - if (currententity.skin != null) - skin = currententity.skin; // custom player skin - else - { - if (currententity.skinnum >= qfiles.MAX_MD2SKINS) - skin = currentmodel.skins[0]; - else - { - skin = currentmodel.skins[currententity.skinnum]; - if (skin == null) - skin = currentmodel.skins[0]; - } - } - if (skin == null) - skin = r_notexture; // fallback... - GL_Bind(skin.texnum); - - // draw it - - GL11.glShadeModel (GL11.GL_SMOOTH); - - GL_TexEnv( GL11.GL_MODULATE ); - if ( (currententity.flags & Defines.RF_TRANSLUCENT) != 0 ) - { - GL11.glEnable (GL11.GL_BLEND); - } - - - if ( (currententity.frame >= paliashdr.num_frames) - || (currententity.frame < 0) ) - { - VID.Printf (Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name +": no such frame " + currententity.frame + '\n'); - currententity.frame = 0; - currententity.oldframe = 0; - } - - if ( (currententity.oldframe >= paliashdr.num_frames) - || (currententity.oldframe < 0)) - { - VID.Printf (Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name +": no such oldframe " + currententity.oldframe + '\n'); - currententity.frame = 0; - currententity.oldframe = 0; - } - - if ( r_lerpmodels.value == 0.0f) - currententity.backlerp = 0; - - GL_DrawAliasFrameLerp(paliashdr, currententity.backlerp); - - GL_TexEnv( GL11.GL_REPLACE ); - GL11.glShadeModel (GL11.GL_FLAT); - - GL11.glPopMatrix (); - - if ( ( currententity.flags & Defines.RF_WEAPONMODEL ) != 0 && ( r_lefthand.value == 1.0F ) ) - { - GL11.glMatrixMode( GL11.GL_PROJECTION ); - GL11.glPopMatrix(); - GL11.glMatrixMode( GL11.GL_MODELVIEW ); - GL11.glCullFace( GL11.GL_FRONT ); - } - - if ( (currententity.flags & Defines.RF_TRANSLUCENT) != 0 ) - { - GL11.glDisable (GL11.GL_BLEND); - } - - if ( (currententity.flags & Defines.RF_DEPTHHACK) != 0) - GL11.glDepthRange (gldepthmin, gldepthmax); - - if ( gl_shadows.value != 0.0f && (currententity.flags & (Defines.RF_TRANSLUCENT | Defines.RF_WEAPONMODEL)) == 0) - { - GL11.glPushMatrix (); - R_RotateForEntity (e); - GL11.glDisable (GL11.GL_TEXTURE_2D); - GL11.glEnable (GL11.GL_BLEND); - GL11.glColor4f (0,0,0,0.5f); - GL_DrawAliasShadow (paliashdr, currententity.frame ); - GL11.glEnable (GL11.GL_TEXTURE_2D); - GL11.glDisable (GL11.GL_BLEND); - GL11.glPopMatrix (); - } - GL11.glColor4f (1,1,1,1); - } + // g_mesh.c: triangle model functions + /* + ============================================================= + + ALIAS MODELS + + ============================================================= + */ + + static final int NUMVERTEXNORMALS = 162; + + float[][] r_avertexnormals = Anorms.VERTEXNORMALS; + float[] shadevector = {0, 0, 0}; + float[] shadelight = {0, 0, 0}; + + // precalculated dot products for quantized angles + static final int SHADEDOT_QUANT = 16; + + float[][] r_avertexnormal_dots = Anorms.VERTEXNORMAL_DOTS; + + float[] shadedots = r_avertexnormal_dots[0]; + + /** + * GL_LerpVerts + * @param nverts + * @param ov + * @param verts + * @param move + * @param frontv + * @param backv + */ + void GL_LerpVerts(int nverts, int[] ov, int[] v, float[] move, float[] frontv, float[] backv ) + { + FloatBuffer lerp = vertexArrayBuf; + lerp.limit((nverts << 2) - nverts); // nverts * 3 + + int ovv, vv; + //PMM -- added RF_SHELL_DOUBLE, RF_SHELL_HALF_DAM + if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0 ) + { + float[] normal; + int j = 0; + for (int i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) + { + vv = v[i]; + normal = r_avertexnormals[(vv >>> 24 ) & 0xFF]; + ovv = ov[i]; + lerp.put(j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF) * frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); + lerp.put(j + 1, move[1] + ((ovv >>> 8) & 0xFF) * backv[1] + ((vv >>> 8) & 0xFF) * frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); + lerp.put(j + 2, move[2] + ((ovv >>> 16) & 0xFF) * backv[2] + ((vv >>> 16) & 0xFF) * frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); + j += 3; + } + } + else + { + int j = 0; + for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) + { + ovv = ov[i]; + vv = v[i]; + + lerp.put(j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF)*frontv[0]); + lerp.put(j + 1, move[1] + ((ovv >>> 8) & 0xFF)* backv[1] + ((vv >>> 8) & 0xFF)*frontv[1]); + lerp.put(j + 2, move[2] + ((ovv >>> 16) & 0xFF)* backv[2] + ((vv >>> 16) & 0xFF)*frontv[2]); + j += 3; + } + } + } + + FloatBuffer colorArrayBuf = BufferUtils.createFloatBuffer(qfiles.MAX_VERTS * 4); + FloatBuffer vertexArrayBuf = BufferUtils.createFloatBuffer(qfiles.MAX_VERTS * 3); + FloatBuffer textureArrayBuf = BufferUtils.createFloatBuffer(qfiles.MAX_VERTS * 2); + boolean isFilled = false; + float[] tmpVec = {0, 0, 0}; + float[][] vectors = { + {0, 0, 0}, {0, 0, 0}, {0, 0, 0} // 3 mal vec3_t + }; + + // stack variable + private final float[] move = {0, 0, 0}; // vec3_t + private final float[] frontv = {0, 0, 0}; // vec3_t + private final float[] backv = {0, 0, 0}; // vec3_t + /** + * GL_DrawAliasFrameLerp + * + * interpolates between two frames and origins + * FIXME: batch lerp all vertexes + */ + void GL_DrawAliasFrameLerp(qfiles.dmdl_t paliashdr, float backlerp) + { + qfiles.daliasframe_t frame = paliashdr.aliasFrames[currententity.frame]; + + int[] verts = frame.verts; + + qfiles.daliasframe_t oldframe = paliashdr.aliasFrames[currententity.oldframe]; + + int[] ov = oldframe.verts; + + float alpha; + if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) + alpha = currententity.alpha; + else + alpha = 1.0f; + + // PMM - added double shell + if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0) + GL11.glDisable( GL11.GL_TEXTURE_2D ); + + float frontlerp = 1.0f - backlerp; + + // move should be the delta back to the previous frame * backlerp + Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, frontv); + Math3D.AngleVectors (currententity.angles, vectors[0], vectors[1], vectors[2]); + + move[0] = Math3D.DotProduct (frontv, vectors[0]); // forward + move[1] = -Math3D.DotProduct (frontv, vectors[1]); // left + move[2] = Math3D.DotProduct (frontv, vectors[2]); // up + + Math3D.VectorAdd (move, oldframe.translate, move); + + for (int i=0 ; i<3 ; i++) + { + move[i] = backlerp*move[i] + frontlerp*frame.translate[i]; + frontv[i] = frontlerp*frame.scale[i]; + backv[i] = backlerp*oldframe.scale[i]; + } + + // ab hier wird optimiert + + GL_LerpVerts( paliashdr.num_xyz, ov, verts, move, frontv, backv ); + + //GL11.glEnableClientState( GL11.GL_VERTEX_ARRAY ); + GL11.glVertexPointer( 3, 0, vertexArrayBuf ); + + // PMM - added double damage shell + if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0) + { + GL11.glColor4f( shadelight[0], shadelight[1], shadelight[2], alpha ); + } + else + { + GL11.glEnableClientState( GL11.GL_COLOR_ARRAY ); + GL11.glColorPointer( 4, 0, colorArrayBuf ); + + // + // pre light everything + // + FloatBuffer color = colorArrayBuf; + float l; + int size = paliashdr.num_xyz; + int j = 0; + for (int i = 0; i < size; i++ ) + { + l = shadedots[(verts[i] >>> 24) & 0xFF]; + color.put(j, l * shadelight[0]); + color.put(j + 1, l * shadelight[1]); + color.put(j + 2, l * shadelight[2]); + color.put(j + 3, alpha); + j += 4; + } + } + + ARBMultitexture.glClientActiveTextureARB(GL_TEXTURE0); + GL11.glTexCoordPointer( 2, 0, textureArrayBuf); + //GL11.glEnableClientState( GL11.GL_TEXTURE_COORD_ARRAY); + + int pos = 0; + int[] counts = paliashdr.counts; + + IntBuffer srcIndexBuf = null; + + FloatBuffer dstTextureCoords = textureArrayBuf; + FloatBuffer srcTextureCoords = paliashdr.textureCoordBuf; + + int dstIndex = 0; + int srcIndex = 0; + int count; + int mode; + int size = counts.length; + for (int j = 0; j < size; j++) { + + // get the vertex count and primitive type + count = counts[j]; + if (count == 0) + break; // done + + srcIndexBuf = paliashdr.indexElements[j]; + + mode = GL11.GL_TRIANGLE_STRIP; + if (count < 0) { + mode = GL11.GL_TRIANGLE_FAN; + count = -count; + } + srcIndex = pos << 1; + srcIndex--; + for (int k = 0; k < count; k++) { + dstIndex = srcIndexBuf.get(k) << 1; + dstTextureCoords.put(dstIndex, srcTextureCoords.get(++srcIndex)); + dstTextureCoords.put(++dstIndex, srcTextureCoords.get(++srcIndex)); + } + + GL11.glDrawElements(mode, srcIndexBuf); + pos += count; + } + + // PMM - added double damage shell + if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0 ) + GL11.glEnable( GL11.GL_TEXTURE_2D ); + + GL11.glDisableClientState( GL11.GL_COLOR_ARRAY ); + } + + private final float[] point = {0, 0, 0}; + /** + * GL_DrawAliasShadow + */ + void GL_DrawAliasShadow(qfiles.dmdl_t paliashdr, int posenum) + { + float lheight = currententity.origin[2] - lightspot[2]; + // qfiles.daliasframe_t frame = paliashdr.aliasFrames[currententity.frame]; + int[] order = paliashdr.glCmds; + float height = -lheight + 1.0f; + + int orderIndex = 0; + int index = 0; + + // TODO shadow drawing with vertex arrays + + int count; + while (true) + { + // get the vertex count and primitive type + count = order[orderIndex++]; + if (count == 0) + break; // done + if (count < 0) + { + count = -count; + GL11.glBegin (GL11.GL_TRIANGLE_FAN); + } + else + GL11.glBegin (GL11.GL_TRIANGLE_STRIP); + + do + { + index = order[orderIndex + 2] * 3; + point[0] = vertexArrayBuf.get(index); + point[1] = vertexArrayBuf.get(index + 1); + point[2] = vertexArrayBuf.get(index + 2); + + point[0] -= shadevector[0]*(point[2]+lheight); + point[1] -= shadevector[1]*(point[2]+lheight); + point[2] = height; + GL11.glVertex3f(point[0], point[1], point[2]); + + orderIndex += 3; + + } while (--count != 0); + + GL11.glEnd (); + } + } + +// TODO sync with jogl renderer. hoz + // stack variable + private final float[] mins = { 0, 0, 0 }; + private final float[] maxs = { 0, 0, 0 }; + /** + * R_CullAliasModel + */ + boolean R_CullAliasModel(entity_t e) { + qfiles.dmdl_t paliashdr = (qfiles.dmdl_t) currentmodel.extradata; + + if ((e.frame >= paliashdr.num_frames) || (e.frame < 0)) { + VID.Printf(Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such frame " + e.frame + '\n'); + e.frame = 0; + } + if ((e.oldframe >= paliashdr.num_frames) || (e.oldframe < 0)) { + VID.Printf(Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such oldframe " + e.oldframe + '\n'); + e.oldframe = 0; + } + + qfiles.daliasframe_t pframe = paliashdr.aliasFrames[e.frame]; + qfiles.daliasframe_t poldframe = paliashdr.aliasFrames[e.oldframe]; + + /* + ** compute axially aligned mins and maxs + */ + if (pframe == poldframe) { + for (int i = 0; i < 3; i++) { + mins[i] = pframe.translate[i]; + maxs[i] = mins[i] + pframe.scale[i] * 255; + } + } else { + float thismaxs, oldmaxs; + for (int i = 0; i < 3; i++) { + thismaxs = pframe.translate[i] + pframe.scale[i] * 255; + + oldmaxs = poldframe.translate[i] + poldframe.scale[i] * 255; + + if (pframe.translate[i] < poldframe.translate[i]) + mins[i] = pframe.translate[i]; + else + mins[i] = poldframe.translate[i]; + + if (thismaxs > oldmaxs) + maxs[i] = thismaxs; + else + maxs[i] = oldmaxs; + } + } + + /* + ** compute a full bounding box + */ + float[] tmp; + for (int i = 0; i < 8; i++) { + tmp = bbox[i]; + if ((i & 1) != 0) + tmp[0] = mins[0]; + else + tmp[0] = maxs[0]; + + if ((i & 2) != 0) + tmp[1] = mins[1]; + else + tmp[1] = maxs[1]; + + if ((i & 4) != 0) + tmp[2] = mins[2]; + else + tmp[2] = maxs[2]; + } + + /* + ** rotate the bounding box + */ + tmp = mins; + Math3D.VectorCopy(e.angles, tmp); + tmp[YAW] = -tmp[YAW]; + Math3D.AngleVectors(tmp, vectors[0], vectors[1], vectors[2]); + + for (int i = 0; i < 8; i++) { + Math3D.VectorCopy(bbox[i], tmp); + + bbox[i][0] = Math3D.DotProduct(vectors[0], tmp); + bbox[i][1] = -Math3D.DotProduct(vectors[1], tmp); + bbox[i][2] = Math3D.DotProduct(vectors[2], tmp); + + Math3D.VectorAdd(e.origin, bbox[i], bbox[i]); + } + + int f, mask; + int aggregatemask = ~0; // 0xFFFFFFFF + + for (int p = 0; p < 8; p++) { + mask = 0; + + for (f = 0; f < 4; f++) { + float dp = Math3D.DotProduct(frustum[f].normal, bbox[p]); + + if ((dp - frustum[f].dist) < 0) { + mask |= (1 << f); + } + } + + aggregatemask &= mask; + } + + if (aggregatemask != 0) { + return true; + } + + return false; + } + + + // bounding box + float[][] bbox = { + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} + }; + +// TODO sync with jogl renderer. hoz + /** + * R_DrawAliasModel + */ + void R_DrawAliasModel(entity_t e) + { + if ( ( e.flags & Defines.RF_WEAPONMODEL ) == 0) + { + if ( R_CullAliasModel(e) ) + return; + } + + if ( (e.flags & Defines.RF_WEAPONMODEL) != 0 ) + { + if ( r_lefthand.value == 2.0f ) + return; + } + + qfiles.dmdl_t paliashdr = (qfiles.dmdl_t)currentmodel.extradata; + + // + // get lighting information + // + // PMM - rewrote, reordered to handle new shells & mixing + // PMM - 3.20 code .. replaced with original way of doing it to keep mod authors happy + // + int i; + if ( (currententity.flags & ( Defines.RF_SHELL_HALF_DAM | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_RED | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE )) != 0 ) + { + Math3D.VectorClear(shadelight); + if ((currententity.flags & Defines.RF_SHELL_HALF_DAM) != 0) + { + shadelight[0] = 0.56f; + shadelight[1] = 0.59f; + shadelight[2] = 0.45f; + } + if ( (currententity.flags & Defines.RF_SHELL_DOUBLE) != 0 ) + { + shadelight[0] = 0.9f; + shadelight[1] = 0.7f; + } + if ( (currententity.flags & Defines.RF_SHELL_RED) != 0 ) + shadelight[0] = 1.0f; + if ( (currententity.flags & Defines.RF_SHELL_GREEN) != 0 ) + shadelight[1] = 1.0f; + if ( (currententity.flags & Defines.RF_SHELL_BLUE) != 0 ) + shadelight[2] = 1.0f; + } + + else if ( (currententity.flags & Defines.RF_FULLBRIGHT) != 0 ) + { + for (i=0 ; i<3 ; i++) + shadelight[i] = 1.0f; + } + else + { + R_LightPoint (currententity.origin, shadelight); + + // player lighting hack for communication back to server + // big hack! + if ( (currententity.flags & Defines.RF_WEAPONMODEL) != 0 ) + { + // pick the greatest component, which should be the same + // as the mono value returned by software + if (shadelight[0] > shadelight[1]) + { + if (shadelight[0] > shadelight[2]) + r_lightlevel.value = 150*shadelight[0]; + else + r_lightlevel.value = 150*shadelight[2]; + } + else + { + if (shadelight[1] > shadelight[2]) + r_lightlevel.value = 150*shadelight[1]; + else + r_lightlevel.value = 150*shadelight[2]; + } + } + + if ( gl_monolightmap.string.charAt(0) != '0' ) + { + float s = shadelight[0]; + + if ( s < shadelight[1] ) + s = shadelight[1]; + if ( s < shadelight[2] ) + s = shadelight[2]; + + shadelight[0] = s; + shadelight[1] = s; + shadelight[2] = s; + } + } + + if ( (currententity.flags & Defines.RF_MINLIGHT) != 0 ) + { + for (i=0 ; i<3 ; i++) + if (shadelight[i] > 0.1f) + break; + if (i == 3) + { + shadelight[0] = 0.1f; + shadelight[1] = 0.1f; + shadelight[2] = 0.1f; + } + } + + if ( (currententity.flags & Defines.RF_GLOW) != 0 ) + { // bonus items will pulse with time + float scale; + float min; + + scale = (float)(0.1f * Math.sin(r_newrefdef.time*7)); + for (i=0 ; i<3 ; i++) + { + min = shadelight[i] * 0.8f; + shadelight[i] += scale; + if (shadelight[i] < min) + shadelight[i] = min; + } + } + + // ================= + // PGM ir goggles color override + if ( (r_newrefdef.rdflags & Defines.RDF_IRGOGGLES) != 0 && (currententity.flags & Defines.RF_IR_VISIBLE) != 0) + { + shadelight[0] = 1.0f; + shadelight[1] = 0.0f; + shadelight[2] = 0.0f; + } + // PGM + // ================= + + shadedots = r_avertexnormal_dots[((int)(currententity.angles[1] * (SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)]; + + float an = (float)(currententity.angles[1]/180*Math.PI); + shadevector[0] = (float)Math.cos(-an); + shadevector[1] = (float)Math.sin(-an); + shadevector[2] = 1; + Math3D.VectorNormalize(shadevector); + + // + // locate the proper data + // + + c_alias_polys += paliashdr.num_tris; + + // + // draw all the triangles + // + if ( (currententity.flags & Defines.RF_DEPTHHACK) != 0) // hack the depth range to prevent view model from poking into walls + GL11.glDepthRange(gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin)); + + if ( (currententity.flags & Defines.RF_WEAPONMODEL) != 0 && (r_lefthand.value == 1.0f) ) + { + GL11.glMatrixMode( GL11.GL_PROJECTION ); + GL11.glPushMatrix(); + GL11.glLoadIdentity(); + GL11.glScalef( -1, 1, 1 ); + MYgluPerspective( r_newrefdef.fov_y, ( float ) r_newrefdef.width / r_newrefdef.height, 4, 4096); + GL11.glMatrixMode( GL11.GL_MODELVIEW ); + + GL11.glCullFace( GL11.GL_BACK ); + } + + GL11.glPushMatrix (); + e.angles[PITCH] = -e.angles[PITCH]; // sigh. + R_RotateForEntity (e); + e.angles[PITCH] = -e.angles[PITCH]; // sigh. + + + + image_t skin; + // select skin + if (currententity.skin != null) + skin = currententity.skin; // custom player skin + else + { + if (currententity.skinnum >= qfiles.MAX_MD2SKINS) + skin = currentmodel.skins[0]; + else + { + skin = currentmodel.skins[currententity.skinnum]; + if (skin == null) + skin = currentmodel.skins[0]; + } + } + if (skin == null) + skin = r_notexture; // fallback... + GL_Bind(skin.texnum); + + // draw it + + GL11.glShadeModel (GL11.GL_SMOOTH); + + GL_TexEnv( GL11.GL_MODULATE ); + if ( (currententity.flags & Defines.RF_TRANSLUCENT) != 0 ) + { + GL11.glEnable (GL11.GL_BLEND); + } + + + if ( (currententity.frame >= paliashdr.num_frames) + || (currententity.frame < 0) ) + { + VID.Printf (Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name +": no such frame " + currententity.frame + '\n'); + currententity.frame = 0; + currententity.oldframe = 0; + } + + if ( (currententity.oldframe >= paliashdr.num_frames) + || (currententity.oldframe < 0)) + { + VID.Printf (Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name +": no such oldframe " + currententity.oldframe + '\n'); + currententity.frame = 0; + currententity.oldframe = 0; + } + + if ( r_lerpmodels.value == 0.0f) + currententity.backlerp = 0; + + GL_DrawAliasFrameLerp(paliashdr, currententity.backlerp); + + GL_TexEnv( GL11.GL_REPLACE ); + GL11.glShadeModel (GL11.GL_FLAT); + + GL11.glPopMatrix (); + + if ( ( currententity.flags & Defines.RF_WEAPONMODEL ) != 0 && ( r_lefthand.value == 1.0F ) ) + { + GL11.glMatrixMode( GL11.GL_PROJECTION ); + GL11.glPopMatrix(); + GL11.glMatrixMode( GL11.GL_MODELVIEW ); + GL11.glCullFace( GL11.GL_FRONT ); + } + + if ( (currententity.flags & Defines.RF_TRANSLUCENT) != 0 ) + { + GL11.glDisable (GL11.GL_BLEND); + } + + if ( (currententity.flags & Defines.RF_DEPTHHACK) != 0) + GL11.glDepthRange (gldepthmin, gldepthmax); + + if ( gl_shadows.value != 0.0f && (currententity.flags & (Defines.RF_TRANSLUCENT | Defines.RF_WEAPONMODEL)) == 0) + { + GL11.glPushMatrix (); + R_RotateForEntity (e); + GL11.glDisable (GL11.GL_TEXTURE_2D); + GL11.glEnable (GL11.GL_BLEND); + GL11.glColor4f (0,0,0,0.5f); + GL_DrawAliasShadow (paliashdr, currententity.frame ); + GL11.glEnable (GL11.GL_TEXTURE_2D); + GL11.glDisable (GL11.GL_BLEND); + GL11.glPopMatrix (); + } + GL11.glColor4f (1,1,1,1); + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/render/lwjgl/Misc.java b/src/main/java/lwjake2/render/lwjgl/Misc.java index c78e385..3ef03bb 100644 --- a/src/main/java/lwjake2/render/lwjgl/Misc.java +++ b/src/main/java/lwjake2/render/lwjgl/Misc.java @@ -43,243 +43,243 @@ import org.lwjgl.opengl.GL12; * @author cwei */ public abstract class Misc extends Mesh { - private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); + private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); - /* - ================== - R_InitParticleTexture - ================== - */ - byte[][] dottexture = - { - {0,0,0,0,0,0,0,0}, - {0,0,1,1,0,0,0,0}, - {0,1,1,1,1,0,0,0}, - {0,1,1,1,1,0,0,0}, - {0,0,1,1,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - }; + /* + ================== + R_InitParticleTexture + ================== + */ + byte[][] dottexture = + { + {0,0,0,0,0,0,0,0}, + {0,0,1,1,0,0,0,0}, + {0,1,1,1,1,0,0,0}, + {0,1,1,1,1,0,0,0}, + {0,0,1,1,0,0,0,0}, + {0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0}, + }; - void R_InitParticleTexture() - { - int x,y; - byte[] data = new byte[8 * 8 * 4]; + void R_InitParticleTexture() + { + int x,y; + byte[] data = new byte[8 * 8 * 4]; - // - // particle texture - // - for (x=0 ; x<8 ; x++) - { - for (y=0 ; y<8 ; y++) - { - data[y * 32 + x * 4 + 0] = (byte)255; - data[y * 32 + x * 4 + 1] = (byte)255; - data[y * 32 + x * 4 + 2] = (byte)255; - data[y * 32 + x * 4 + 3] = (byte)(dottexture[x][y]*255); + // + // particle texture + // + for (x=0 ; x<8 ; x++) + { + for (y=0 ; y<8 ; y++) + { + data[y * 32 + x * 4 + 0] = (byte)255; + data[y * 32 + x * 4 + 1] = (byte)255; + data[y * 32 + x * 4 + 2] = (byte)255; + data[y * 32 + x * 4 + 3] = (byte)(dottexture[x][y]*255); - } - } - r_particletexture = GL_LoadPic("***particle***", data, 8, 8, it_sprite, 32); - - // - // also use this for bad textures, but without alpha - // - for (x=0 ; x<8 ; x++) - { - for (y=0 ; y<8 ; y++) - { - data[y * 32 + x * 4 + 0] = (byte)(dottexture[x&3][y&3]*255); - data[y * 32 + x * 4 + 1] = 0; // dottexture[x&3][y&3]*255; - data[y * 32 + x * 4 + 2] = 0; //dottexture[x&3][y&3]*255; - data[y * 32 + x * 4 + 3] = (byte)255; - } - } - r_notexture = GL_LoadPic("***r_notexture***", data, 8, 8, it_wall, 32); - } - -// /* -// ============================================================================== -// -// SCREEN SHOTS -// -// ============================================================================== -// */ -// -// typedef struct _TargaHeader { -// unsigned char id_length, colormap_type, image_type; -// unsigned short colormap_index, colormap_length; -// unsigned char colormap_size; -// unsigned short x_origin, y_origin, width, height; -// unsigned char pixel_size, attributes; -// } TargaHeader; - - private final static int TGA_HEADER_SIZE = 18; - - /* - ================== - GL_ScreenShot_f - ================== - */ - void GL_ScreenShot_f() { - StringBuffer sb = new StringBuffer(fileSystem.getGamedir() + "/scrshot/jake00.tga"); - fileSystem.createPath(sb.toString()); - File file = new File(sb.toString()); - // find a valid file name - int i = 0; int offset = sb.length() - 6; - while (file.exists() && i++ < 100) { - sb.setCharAt(offset, (char) ((i/10) + '0')); - sb.setCharAt(offset + 1, (char) ((i%10) + '0')); - file = new File(sb.toString()); + } } - if (i == 100) { - VID.Printf(Defines.PRINT_ALL, "Clean up your screenshots\n"); - return; - } - - try { - RandomAccessFile out = new RandomAccessFile(file, "rw"); - FileChannel ch = out.getChannel(); - int fileLength = TGA_HEADER_SIZE + vid.width * vid.height * 3; - out.setLength(fileLength); - MappedByteBuffer image = ch.map(FileChannel.MapMode.READ_WRITE, 0, - fileLength); - - // write the TGA header - image.put(0, (byte) 0).put(1, (byte) 0); - image.put(2, (byte) 2); // uncompressed type - image.put(12, (byte) (vid.width & 0xFF)); // vid.width - image.put(13, (byte) (vid.width >> 8)); // vid.width - image.put(14, (byte) (vid.height & 0xFF)); // vid.height - image.put(15, (byte) (vid.height >> 8)); // vid.height - image.put(16, (byte) 24); // pixel size - - // go to image data position - image.position(TGA_HEADER_SIZE); - - - // change pixel alignment for reading - if (vid.width % 4 != 0) { - GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); - } - - // OpenGL 1.2+ supports the GL_BGR color format - // check the GL_VERSION to use the TARGA BGR order if possible - // e.g.: 1.5.2 NVIDIA 66.29 - if (gl_config.getOpenGLVersion() >= 1.2f) { - // read the BGR values into the image buffer - GL11.glReadPixels(0, 0, vid.width, vid.height, GL12.GL_BGR, GL11.GL_UNSIGNED_BYTE, image); - } else { - // read the RGB values into the image buffer - GL11.glReadPixels(0, 0, vid.width, vid.height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, image); - // flip RGB to BGR - byte tmp; - for (i = TGA_HEADER_SIZE; i < fileLength; i += 3) { - tmp = image.get(i); - image.put(i, image.get(i + 2)); - image.put(i + 2, tmp); - } - } - // reset to default alignment - GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 4); - // close the file channel - ch.close(); - } catch (IOException e) { - VID.Printf(Defines.PRINT_ALL, e.getMessage() + '\n'); - } + r_particletexture = GL_LoadPic("***particle***", data, 8, 8, it_sprite, 32); - VID.Printf(Defines.PRINT_ALL, "Wrote " + file + '\n'); - } + // + // also use this for bad textures, but without alpha + // + for (x=0 ; x<8 ; x++) + { + for (y=0 ; y<8 ; y++) + { + data[y * 32 + x * 4 + 0] = (byte)(dottexture[x&3][y&3]*255); + data[y * 32 + x * 4 + 1] = 0; // dottexture[x&3][y&3]*255; + data[y * 32 + x * 4 + 2] = 0; //dottexture[x&3][y&3]*255; + data[y * 32 + x * 4 + 3] = (byte)255; + } + } + r_notexture = GL_LoadPic("***r_notexture***", data, 8, 8, it_wall, 32); + } - /* - ** GL_Strings_f - */ - void GL_Strings_f() { - VID.Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); - VID.Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); - VID.Printf(Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n'); - VID.Printf(Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n'); - } +// /* +// ============================================================================== +// +// SCREEN SHOTS +// +// ============================================================================== +// */ +// +// typedef struct _TargaHeader { +// unsigned char id_length, colormap_type, image_type; +// unsigned short colormap_index, colormap_length; +// unsigned char colormap_size; +// unsigned short x_origin, y_origin, width, height; +// unsigned char pixel_size, attributes; +// } TargaHeader; - /* - ** GL_SetDefaultState - */ - void GL_SetDefaultState() - { - GL11.glClearColor(1f,0f, 0.5f , 0.5f); // original quake2 - //GL11.glClearColor(0, 0, 0, 0); // replaced with black - GL11.glCullFace(GL11.GL_FRONT); - GL11.glEnable(GL11.GL_TEXTURE_2D); + private final static int TGA_HEADER_SIZE = 18; + + /* + ================== + GL_ScreenShot_f + ================== + */ + void GL_ScreenShot_f() { + StringBuffer sb = new StringBuffer(fileSystem.getGamedir() + "/scrshot/jake00.tga"); + fileSystem.createPath(sb.toString()); + File file = new File(sb.toString()); + // find a valid file name + int i = 0; int offset = sb.length() - 6; + while (file.exists() && i++ < 100) { + sb.setCharAt(offset, (char) ((i/10) + '0')); + sb.setCharAt(offset + 1, (char) ((i%10) + '0')); + file = new File(sb.toString()); + } + if (i == 100) { + VID.Printf(Defines.PRINT_ALL, "Clean up your screenshots\n"); + return; + } + + try { + RandomAccessFile out = new RandomAccessFile(file, "rw"); + FileChannel ch = out.getChannel(); + int fileLength = TGA_HEADER_SIZE + vid.width * vid.height * 3; + out.setLength(fileLength); + MappedByteBuffer image = ch.map(FileChannel.MapMode.READ_WRITE, 0, + fileLength); + + // write the TGA header + image.put(0, (byte) 0).put(1, (byte) 0); + image.put(2, (byte) 2); // uncompressed type + image.put(12, (byte) (vid.width & 0xFF)); // vid.width + image.put(13, (byte) (vid.width >> 8)); // vid.width + image.put(14, (byte) (vid.height & 0xFF)); // vid.height + image.put(15, (byte) (vid.height >> 8)); // vid.height + image.put(16, (byte) 24); // pixel size + + // go to image data position + image.position(TGA_HEADER_SIZE); + + + // change pixel alignment for reading + if (vid.width % 4 != 0) { + GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); + } + + // OpenGL 1.2+ supports the GL_BGR color format + // check the GL_VERSION to use the TARGA BGR order if possible + // e.g.: 1.5.2 NVIDIA 66.29 + if (gl_config.getOpenGLVersion() >= 1.2f) { + // read the BGR values into the image buffer + GL11.glReadPixels(0, 0, vid.width, vid.height, GL12.GL_BGR, GL11.GL_UNSIGNED_BYTE, image); + } else { + // read the RGB values into the image buffer + GL11.glReadPixels(0, 0, vid.width, vid.height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, image); + // flip RGB to BGR + byte tmp; + for (i = TGA_HEADER_SIZE; i < fileLength; i += 3) { + tmp = image.get(i); + image.put(i, image.get(i + 2)); + image.put(i + 2, tmp); + } + } + // reset to default alignment + GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 4); + // close the file channel + ch.close(); + } catch (IOException e) { + VID.Printf(Defines.PRINT_ALL, e.getMessage() + '\n'); + } - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.666f); + VID.Printf(Defines.PRINT_ALL, "Wrote " + file + '\n'); + } - GL11.glDisable (GL11.GL_DEPTH_TEST); - GL11.glDisable (GL11.GL_CULL_FACE); - GL11.glDisable (GL11.GL_BLEND); + /* + ** GL_Strings_f + */ + void GL_Strings_f() { + VID.Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n'); + } - GL11.glColor4f (1,1,1,1); + /* + ** GL_SetDefaultState + */ + void GL_SetDefaultState() + { + GL11.glClearColor(1f,0f, 0.5f , 0.5f); // original quake2 + //GL11.glClearColor(0, 0, 0, 0); // replaced with black + GL11.glCullFace(GL11.GL_FRONT); + GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glPolygonMode (GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); - GL11.glShadeModel (GL11.GL_FLAT); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.666f); - GL_TextureMode( gl_texturemode.string ); - GL_TextureAlphaMode( gl_texturealphamode.string ); - GL_TextureSolidMode( gl_texturesolidmode.string ); + GL11.glDisable (GL11.GL_DEPTH_TEST); + GL11.glDisable (GL11.GL_CULL_FACE); + GL11.glDisable (GL11.GL_BLEND); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); + GL11.glColor4f (1,1,1,1); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); + GL11.glPolygonMode (GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); + GL11.glShadeModel (GL11.GL_FLAT); - GL11.glBlendFunc (GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL_TextureMode( gl_texturemode.string ); + GL_TextureAlphaMode( gl_texturealphamode.string ); + GL_TextureSolidMode( gl_texturesolidmode.string ); - GL_TexEnv( GL11.GL_REPLACE ); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max); - if ( qglPointParameterfEXT ) - { - // float[] attenuations = { gl_particle_att_a.value, gl_particle_att_b.value, gl_particle_att_c.value }; - FloatBuffer att_buffer=BufferUtils.createFloatBuffer(4); - att_buffer.put(0,gl_particle_att_a.value); - att_buffer.put(1,gl_particle_att_b.value); - att_buffer.put(2,gl_particle_att_c.value); - - GL11.glEnable( GL11.GL_POINT_SMOOTH ); - EXTPointParameters.glPointParameterfEXT( EXTPointParameters.GL_POINT_SIZE_MIN_EXT, gl_particle_min_size.value ); - EXTPointParameters.glPointParameterfEXT( EXTPointParameters.GL_POINT_SIZE_MAX_EXT, gl_particle_max_size.value ); - EXTPointParameters.glPointParameterEXT( EXTPointParameters.GL_DISTANCE_ATTENUATION_EXT, att_buffer ); - } + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); - if ( qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f ) - { - GL11.glEnable( EXTSharedTexturePalette.GL_SHARED_TEXTURE_PALETTE_EXT ); + GL11.glBlendFunc (GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL_SetTexturePalette( d_8to24table ); - } + GL_TexEnv( GL11.GL_REPLACE ); - GL_UpdateSwapInterval(); - - /* - * vertex array extension - */ - GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); - ARBMultitexture.glClientActiveTextureARB(GL_TEXTURE0); - GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); - } + if ( qglPointParameterfEXT ) + { + // float[] attenuations = { gl_particle_att_a.value, gl_particle_att_b.value, gl_particle_att_c.value }; + FloatBuffer att_buffer=BufferUtils.createFloatBuffer(4); + att_buffer.put(0,gl_particle_att_a.value); + att_buffer.put(1,gl_particle_att_b.value); + att_buffer.put(2,gl_particle_att_c.value); + + GL11.glEnable( GL11.GL_POINT_SMOOTH ); + EXTPointParameters.glPointParameterfEXT( EXTPointParameters.GL_POINT_SIZE_MIN_EXT, gl_particle_min_size.value ); + EXTPointParameters.glPointParameterfEXT( EXTPointParameters.GL_POINT_SIZE_MAX_EXT, gl_particle_max_size.value ); + EXTPointParameters.glPointParameterEXT( EXTPointParameters.GL_DISTANCE_ATTENUATION_EXT, att_buffer ); + } - void GL_UpdateSwapInterval() - { - if ( gl_swapinterval.modified ) - { - gl_swapinterval.modified = false; - if ( !gl_state.stereo_enabled ) - { - if (qwglSwapIntervalEXT) { - // ((WGL)gl).wglSwapIntervalEXT((int)gl_swapinterval.value); - } - } - } - } + if ( qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f ) + { + GL11.glEnable( EXTSharedTexturePalette.GL_SHARED_TEXTURE_PALETTE_EXT ); + + GL_SetTexturePalette( d_8to24table ); + } + + GL_UpdateSwapInterval(); + + /* + * vertex array extension + */ + GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); + ARBMultitexture.glClientActiveTextureARB(GL_TEXTURE0); + GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); + } + + void GL_UpdateSwapInterval() + { + if ( gl_swapinterval.modified ) + { + gl_swapinterval.modified = false; + if ( !gl_state.stereo_enabled ) + { + if (qwglSwapIntervalEXT) { + // ((WGL)gl).wglSwapIntervalEXT((int)gl_swapinterval.value); + } + } + } + } } diff --git a/src/main/java/lwjake2/render/lwjgl/Model.java b/src/main/java/lwjake2/render/lwjgl/Model.java index 4a7e410..0d3cd72 100644 --- a/src/main/java/lwjake2/render/lwjgl/Model.java +++ b/src/main/java/lwjake2/render/lwjgl/Model.java @@ -55,1316 +55,1316 @@ import org.lwjgl.BufferUtils; * @author cwei */ public abstract class Model extends Surf { - private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); - - // models.c -- model loading and caching - - model_t loadmodel; - int modfilelen; - - byte[] mod_novis = new byte[Defines.MAX_MAP_LEAFS/8]; - - static final int MAX_MOD_KNOWN = 512; - model_t[] mod_known = new model_t[MAX_MOD_KNOWN]; - int mod_numknown; - - // the inline * models from the current map are kept seperate - model_t[] mod_inline = new model_t[MAX_MOD_KNOWN]; - - abstract void GL_SubdivideSurface(msurface_t surface); // Warp.java - - /* - =============== - Mod_PointInLeaf - =============== - */ - mleaf_t Mod_PointInLeaf(float[] p, model_t model) - { - mnode_t node; - float d; - cplane_t plane; - - if (model == null || model.nodes == null) - Com.Error (Defines.ERR_DROP, "Mod_PointInLeaf: bad model"); - - node = model.nodes[0]; // root node - while (true) - { - if (node.contents != -1) - return (mleaf_t)node; - - plane = node.plane; - d = Math3D.DotProduct(p, plane.normal) - plane.dist; - if (d > 0) - node = node.children[0]; - else - node = node.children[1]; - } - // never reached - } - - - byte[] decompressed = new byte[Defines.MAX_MAP_LEAFS / 8]; - byte[] model_visibility = new byte[Defines.MAX_MAP_VISIBILITY]; - - /* - =================== - Mod_DecompressVis - =================== - */ - byte[] Mod_DecompressVis(byte[] in, int offset, model_t model) - { - int c; - byte[] out; - int outp, inp; - int row; - - row = (model.vis.numclusters+7)>>3; - out = decompressed; - outp = 0; - inp = offset; - - if (in == null) - { // no vis info, so make all visible - while (row != 0) - { - out[outp++] = (byte)0xFF; - row--; - } - return decompressed; - } - - do - { - if (in[inp] != 0) - { - out[outp++] = in[inp++]; - continue; - } - - c = in[inp + 1] & 0xFF; - inp += 2; - while (c != 0) - { - out[outp++] = 0; - c--; - } - } while (outp < row); - - return decompressed; - } - - /* - ============== - Mod_ClusterPVS - ============== - */ - byte[] Mod_ClusterPVS(int cluster, model_t model) - { - if (cluster == -1 || model.vis == null) - return mod_novis; - //return Mod_DecompressVis( (byte *)model.vis + model.vis.bitofs[cluster][Defines.DVIS_PVS], model); - return Mod_DecompressVis(model_visibility, model.vis.bitofs[cluster][Defines.DVIS_PVS], model); - } - - -// =============================================================================== - - /* - ================ - Mod_Modellist_f - ================ - */ - void Mod_Modellist_f() - { - int i; - model_t mod; - int total; - - total = 0; - VID.Printf(Defines.PRINT_ALL,"Loaded models:\n"); - for (i=0; i < mod_numknown ; i++) - { - mod = mod_known[i]; - if (mod.name.length() == 0) - continue; - - VID.Printf (Defines.PRINT_ALL, "%8i : %s\n", new Vargs(2).add(mod.extradatasize).add(mod.name)); - total += mod.extradatasize; - } - VID.Printf (Defines.PRINT_ALL, "Total resident: " + total +'\n'); - } - - /* - =============== - Mod_Init - =============== - */ - void Mod_Init() - { - // init mod_known - for (int i=0; i < MAX_MOD_KNOWN; i++) { - mod_known[i] = new model_t(); - } - Arrays.fill(mod_novis, (byte)0xff); - } - - byte[] fileBuffer; - - /* - ================== - Mod_ForName - - Loads in a model for the given name - ================== - */ - model_t Mod_ForName(String name, boolean crash) - { - model_t mod = null; - int i; - - if (name == null || name.length() == 0) - Com.Error(Defines.ERR_DROP, "Mod_ForName: NULL name"); - - // - // inline models are grabbed only from worldmodel - // - if (name.charAt(0) == '*') - { - i = Integer.parseInt(name.substring(1)); - if (i < 1 || r_worldmodel == null || i >= r_worldmodel.numsubmodels) - Com.Error (Defines.ERR_DROP, "bad inline model number"); - return mod_inline[i]; - } - - // - // search the currently loaded models - // - for (i=0; i Math.abs(maxs[i]) ? Math.abs(mins[i]) : Math.abs(maxs[i]); - } - return Math3D.VectorLength(corner); - } - - - /* - ================= - Mod_LoadSubmodels - ================= - */ - void Mod_LoadSubmodels(lump_t l) { - - if ((l.filelen % qfiles.dmodel_t.SIZE) != 0) - Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " - + loadmodel.name); - - int i, j; - - int count = l.filelen / qfiles.dmodel_t.SIZE; - // out = Hunk_Alloc ( count*sizeof(*out)); - mmodel_t out; - mmodel_t[] outs = new mmodel_t[count]; - for (i = 0; i < count; i++) { - outs[i] = new mmodel_t(); - } - - loadmodel.submodels = outs; - loadmodel.numsubmodels = count; - - ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen); - bb.order(ByteOrder.LITTLE_ENDIAN); - - qfiles.dmodel_t in; - - for (i = 0; i < count; i++) { - in = new qfiles.dmodel_t(bb); - out = outs[i]; - for (j = 0; j < 3; j++) { // spread the mins / maxs by a - // pixel - out.mins[j] = in.mins[j] - 1; - out.maxs[j] = in.maxs[j] + 1; - out.origin[j] = in.origin[j]; - } - out.radius = RadiusFromBounds(out.mins, out.maxs); - out.headnode = in.headnode; - out.firstface = in.firstface; - out.numfaces = in.numfaces; - } - } - - /* - ================= - Mod_LoadEdges - ================= - */ - void Mod_LoadEdges (lump_t l) - { - medge_t[] edges; - int i, count; - - if ( (l.filelen % medge_t.DISK_SIZE) != 0) - Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); - - count = l.filelen / medge_t.DISK_SIZE; - // out = Hunk_Alloc ( (count + 1) * sizeof(*out)); - edges = new medge_t[count + 1]; - - loadmodel.edges = edges; - loadmodel.numedges = count; - - ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen); - bb.order(ByteOrder.LITTLE_ENDIAN); - - for ( i=0 ; i 0) - out[i].next = loadmodel.texinfo[next]; - else - out[i].next = null; - - name = "textures/" + in.texture + ".wal"; - - out[i].image = GL_FindImage(name, it_wall); - if (out[i].image == null) { - VID.Printf(Defines.PRINT_ALL, "Couldn't load " + name + '\n'); - out[i].image = r_notexture; - } - } - - // count animation frames - for (i=0 ; i= 0) - v = loadmodel.vertexes[loadmodel.edges[e].v[0]]; - else - v = loadmodel.vertexes[loadmodel.edges[-e].v[1]]; - - for (j=0 ; j<2 ; j++) - { - val = v.position[0] * tex.vecs[j][0] + - v.position[1] * tex.vecs[j][1] + - v.position[2] * tex.vecs[j][2] + - tex.vecs[j][3]; - if (val < mins[j]) - mins[j] = val; - if (val > maxs[j]) - maxs[j] = val; - } - } - - for (int i=0 ; i<2 ; i++) - { - bmins[i] = (int)Math.floor(mins[i]/16); - bmaxs[i] = (int)Math.ceil(maxs[i]/16); - - s.texturemins[i] = (short)(bmins[i] * 16); - s.extents[i] = (short)((bmaxs[i] - bmins[i]) * 16); - - } - } - - /* - ================= - Mod_LoadFaces - ================= - */ - void Mod_LoadFaces(lump_t l) { - - int i, surfnum; - int planenum, side; - int ti; - - if ((l.filelen % qfiles.dface_t.SIZE) != 0) - Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " - + loadmodel.name); - - int count = l.filelen / qfiles.dface_t.SIZE; - // out = Hunk_Alloc ( count*sizeof(*out)); - msurface_t[] outs = new msurface_t[count]; - for (i = 0; i < count; i++) { - outs[i] = new msurface_t(); - } - - loadmodel.surfaces = outs; - loadmodel.numsurfaces = count; - - ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen); - bb.order(ByteOrder.LITTLE_ENDIAN); - - currentmodel = loadmodel; - - GL_BeginBuildingLightmaps(loadmodel); - - qfiles.dface_t in; - msurface_t out; - - for (surfnum = 0; surfnum < count; surfnum++) { - in = new qfiles.dface_t(bb); - out = outs[surfnum]; - out.firstedge = in.firstedge; - out.numedges = in.numedges; - out.flags = 0; - out.polys = null; - - planenum = in.planenum; - side = in.side; - if (side != 0) - out.flags |= Defines.SURF_PLANEBACK; - - out.plane = loadmodel.planes[planenum]; - - ti = in.texinfo; - if (ti < 0 || ti >= loadmodel.numtexinfo) - Com.Error(Defines.ERR_DROP, - "MOD_LoadBmodel: bad texinfo number"); - - out.texinfo = loadmodel.texinfo[ti]; - - CalcSurfaceExtents(out); - - // lighting info - - for (i = 0; i < Defines.MAXLIGHTMAPS; i++) - out.styles[i] = in.styles[i]; - - i = in.lightofs; - if (i == -1) - out.samples = null; - else { - ByteBuffer pointer = ByteBuffer.wrap(loadmodel.lightdata); - pointer.position(i); - pointer = pointer.slice(); - pointer.mark(); - out.samples = pointer; // subarray - } - - // set the drawing flags - - if ((out.texinfo.flags & Defines.SURF_WARP) != 0) { - out.flags |= Defines.SURF_DRAWTURB; - for (i = 0; i < 2; i++) { - out.extents[i] = 16384; - out.texturemins[i] = -8192; - } - GL_SubdivideSurface(out); // cut up polygon for warps - } - - // create lightmaps and polygons - if ((out.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 - | Defines.SURF_TRANS66 | Defines.SURF_WARP)) == 0) - GL_CreateSurfaceLightmap(out); - - if ((out.texinfo.flags & Defines.SURF_WARP) == 0) - GL_BuildPolygonFromSurface(out); - - } - GL_EndBuildingLightmaps(); - } - - - /* - ================= - Mod_SetParent - ================= - */ - void Mod_SetParent(mnode_t node, mnode_t parent) - { - node.parent = parent; - if (node.contents != -1) return; - Mod_SetParent(node.children[0], node); - Mod_SetParent(node.children[1], node); - } - - /* - ================= - Mod_LoadNodes - ================= - */ - void Mod_LoadNodes(lump_t l) - { - int i, j, count, p; - qfiles.dnode_t in; - mnode_t[] out; - - if ((l.filelen % qfiles.dnode_t.SIZE) != 0) - Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); - - count = l.filelen / qfiles.dnode_t.SIZE; - // out = Hunk_Alloc ( count*sizeof(*out)); - out = new mnode_t[count]; - - loadmodel.nodes = out; - loadmodel.numnodes = count; - - ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen); - bb.order(ByteOrder.LITTLE_ENDIAN); - - // initialize the tree array - for ( i=0 ; i= 0) - out[i].children[j] = loadmodel.nodes[p]; - else - out[i].children[j] = loadmodel.leafs[-1 - p]; // mleaf_t extends mnode_t - } - } - - Mod_SetParent(loadmodel.nodes[0], null); // sets nodes and leafs - } - - /* - ================= - Mod_LoadLeafs - ================= - */ - void Mod_LoadLeafs(lump_t l) - { - qfiles.dleaf_t in; - mleaf_t[] out; - int i, j, count; - - if ((l.filelen % qfiles.dleaf_t.SIZE) != 0) - Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); - - count = l.filelen / qfiles.dleaf_t.SIZE; - // out = Hunk_Alloc ( count*sizeof(*out)); - out = new mleaf_t[count]; - - loadmodel.leafs = out; - loadmodel.numleafs = count; - - ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen); - bb.order(ByteOrder.LITTLE_ENDIAN); - - for ( i=0 ; i= loadmodel.numsurfaces) - Com.Error(Defines.ERR_DROP, "Mod_ParseMarksurfaces: bad surface number"); - - out[i] = loadmodel.surfaces[j]; - } - } - - - /* - ================= - Mod_LoadSurfedges - ================= - */ - void Mod_LoadSurfedges(lump_t l) - { - int i, count; - int[] offsets; - - if ( (l.filelen % Defines.SIZE_OF_INT) != 0) - Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); - - count = l.filelen / Defines.SIZE_OF_INT; - if (count < 1 || count >= Defines.MAX_MAP_SURFEDGES) - Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: bad surfedges count in " + loadmodel.name + ": " + count); - - offsets = new int[count]; - - loadmodel.surfedges = offsets; - loadmodel.numsurfedges = count; - - ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen); - bb.order(ByteOrder.LITTLE_ENDIAN); - - for ( i=0 ; i= loadmodel.numnodes) - Com.Error(Defines.ERR_DROP, "Inline model " + i + " has bad firstnode"); - - Math3D.VectorCopy(bm.maxs, starmod.maxs); - Math3D.VectorCopy(bm.mins, starmod.mins); - starmod.radius = bm.radius; - - if (i == 0) - loadmodel = starmod.copy(); - - starmod.numleafs = bm.visleafs; - } - } - - /* - ============================================================================== - - ALIAS MODELS - - ============================================================================== - */ - - /* - ================= - Mod_LoadAliasModel - ================= - */ - void Mod_LoadAliasModel (model_t mod, ByteBuffer buffer) - { - int i; - qfiles.dmdl_t pheader; - qfiles.dstvert_t[] poutst; - qfiles.dtriangle_t[] pouttri; - qfiles.daliasframe_t[] poutframe; - int[] poutcmd; - - pheader = new qfiles.dmdl_t(buffer); - - if (pheader.version != qfiles.ALIAS_VERSION) - Com.Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)", - new Vargs(3).add(mod.name).add(pheader.version).add(qfiles.ALIAS_VERSION)); - - if (pheader.skinheight > MAX_LBM_HEIGHT) - Com.Error(Defines.ERR_DROP, "model "+ mod.name +" has a skin taller than " + MAX_LBM_HEIGHT); - - if (pheader.num_xyz <= 0) - Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no vertices"); - - if (pheader.num_xyz > qfiles.MAX_VERTS) - Com.Error(Defines.ERR_DROP, "model " + mod.name +" has too many vertices"); - - if (pheader.num_st <= 0) - Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no st vertices"); - - if (pheader.num_tris <= 0) - Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no triangles"); - - if (pheader.num_frames <= 0) - Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no frames"); - - // - // load base s and t vertices (not used in gl version) - // - poutst = new qfiles.dstvert_t[pheader.num_st]; - buffer.position(pheader.ofs_st); - for (i=0 ; i -1) { - skinNames[i] = skinNames[i].substring(0, n); - } - mod.skins[i] = GL_FindImage(skinNames[i], it_skin); - } - - // set the model arrays - pheader.skinNames = skinNames; // skin names - pheader.stVerts = poutst; // textur koordinaten - pheader.triAngles = pouttri; // dreiecke - pheader.glCmds = poutcmd; // STRIP or FAN - pheader.aliasFrames = poutframe; // frames mit vertex array - - mod.extradata = pheader; - - mod.mins[0] = -32; - mod.mins[1] = -32; - mod.mins[2] = -32; - mod.maxs[0] = 32; - mod.maxs[1] = 32; - mod.maxs[2] = 32; - - precompileGLCmds(pheader); - } - - /* - ============================================================================== - - SPRITE MODELS - - ============================================================================== - */ - - /* - ================= - Mod_LoadSpriteModel - ================= - */ - void Mod_LoadSpriteModel(model_t mod, ByteBuffer buffer) - { - qfiles.dsprite_t sprout = new qfiles.dsprite_t(buffer); - - if (sprout.version != qfiles.SPRITE_VERSION) - Com.Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)", - new Vargs(3).add(mod.name).add(sprout.version).add(qfiles.SPRITE_VERSION)); - - if (sprout.numframes > qfiles.MAX_MD2SKINS) - Com.Error(Defines.ERR_DROP, "%s has too many frames (%i > %i)", - new Vargs(3).add(mod.name).add(sprout.numframes).add(qfiles.MAX_MD2SKINS)); - - for (int i=0 ; i tmp = new Vector(); - - int count = 0; - int[] order = model.glCmds; - int orderIndex = 0; - while (true) - { - // get the vertex count and primitive type - count = order[orderIndex++]; - if (count == 0) - break; // done - - tmp.addElement(new Integer(count)); - - if (count < 0) - { - count = -count; - //gl.glBegin (GL.GL_TRIANGLE_FAN); - } - else - { - //gl.glBegin (GL.GL_TRIANGLE_STRIP); - } - - do { - // texture coordinates come from the draw list - globalModelTextureCoordBuf.put(Float.intBitsToFloat(order[orderIndex + 0])); - globalModelTextureCoordBuf.put(Float.intBitsToFloat(order[orderIndex + 1])); - globalModelVertexIndexBuf.put(order[orderIndex + 2]); - - orderIndex += 3; - } while (--count != 0); - } - - int size = tmp.size(); - - model.counts = new int[size]; - model.indexElements = new IntBuffer[size]; - - count = 0; - int pos = 0; - for (int i = 0; i < model.counts.length; i++) { - count = ((Integer)tmp.get(i)).intValue(); - model.counts[i] = count; - - count = (count < 0) ? -count : count; - model.vertexIndexBuf.position(pos); - model.indexElements[i] = model.vertexIndexBuf.slice(); - model.indexElements[i].limit(count); - pos += count; - } - } - - static void resetModelArrays() { - globalModelTextureCoordBuf.rewind(); - globalModelVertexIndexBuf.rewind(); - } - - static void modelMemoryUsage() { - System.out.println("AliasModels: globalVertexBuffer size " + globalModelVertexIndexBuf.position()); - } + private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); + + // models.c -- model loading and caching + + model_t loadmodel; + int modfilelen; + + byte[] mod_novis = new byte[Defines.MAX_MAP_LEAFS/8]; + + static final int MAX_MOD_KNOWN = 512; + model_t[] mod_known = new model_t[MAX_MOD_KNOWN]; + int mod_numknown; + + // the inline * models from the current map are kept seperate + model_t[] mod_inline = new model_t[MAX_MOD_KNOWN]; + + abstract void GL_SubdivideSurface(msurface_t surface); // Warp.java + + /* + =============== + Mod_PointInLeaf + =============== + */ + mleaf_t Mod_PointInLeaf(float[] p, model_t model) + { + mnode_t node; + float d; + cplane_t plane; + + if (model == null || model.nodes == null) + Com.Error (Defines.ERR_DROP, "Mod_PointInLeaf: bad model"); + + node = model.nodes[0]; // root node + while (true) + { + if (node.contents != -1) + return (mleaf_t)node; + + plane = node.plane; + d = Math3D.DotProduct(p, plane.normal) - plane.dist; + if (d > 0) + node = node.children[0]; + else + node = node.children[1]; + } + // never reached + } + + + byte[] decompressed = new byte[Defines.MAX_MAP_LEAFS / 8]; + byte[] model_visibility = new byte[Defines.MAX_MAP_VISIBILITY]; + + /* + =================== + Mod_DecompressVis + =================== + */ + byte[] Mod_DecompressVis(byte[] in, int offset, model_t model) + { + int c; + byte[] out; + int outp, inp; + int row; + + row = (model.vis.numclusters+7)>>3; + out = decompressed; + outp = 0; + inp = offset; + + if (in == null) + { // no vis info, so make all visible + while (row != 0) + { + out[outp++] = (byte)0xFF; + row--; + } + return decompressed; + } + + do + { + if (in[inp] != 0) + { + out[outp++] = in[inp++]; + continue; + } + + c = in[inp + 1] & 0xFF; + inp += 2; + while (c != 0) + { + out[outp++] = 0; + c--; + } + } while (outp < row); + + return decompressed; + } + + /* + ============== + Mod_ClusterPVS + ============== + */ + byte[] Mod_ClusterPVS(int cluster, model_t model) + { + if (cluster == -1 || model.vis == null) + return mod_novis; + //return Mod_DecompressVis( (byte *)model.vis + model.vis.bitofs[cluster][Defines.DVIS_PVS], model); + return Mod_DecompressVis(model_visibility, model.vis.bitofs[cluster][Defines.DVIS_PVS], model); + } + + +// =============================================================================== + + /* + ================ + Mod_Modellist_f + ================ + */ + void Mod_Modellist_f() + { + int i; + model_t mod; + int total; + + total = 0; + VID.Printf(Defines.PRINT_ALL,"Loaded models:\n"); + for (i=0; i < mod_numknown ; i++) + { + mod = mod_known[i]; + if (mod.name.length() == 0) + continue; + + VID.Printf (Defines.PRINT_ALL, "%8i : %s\n", new Vargs(2).add(mod.extradatasize).add(mod.name)); + total += mod.extradatasize; + } + VID.Printf (Defines.PRINT_ALL, "Total resident: " + total +'\n'); + } + + /* + =============== + Mod_Init + =============== + */ + void Mod_Init() + { + // init mod_known + for (int i=0; i < MAX_MOD_KNOWN; i++) { + mod_known[i] = new model_t(); + } + Arrays.fill(mod_novis, (byte)0xff); + } + + byte[] fileBuffer; + + /* + ================== + Mod_ForName + + Loads in a model for the given name + ================== + */ + model_t Mod_ForName(String name, boolean crash) + { + model_t mod = null; + int i; + + if (name == null || name.length() == 0) + Com.Error(Defines.ERR_DROP, "Mod_ForName: NULL name"); + + // + // inline models are grabbed only from worldmodel + // + if (name.charAt(0) == '*') + { + i = Integer.parseInt(name.substring(1)); + if (i < 1 || r_worldmodel == null || i >= r_worldmodel.numsubmodels) + Com.Error (Defines.ERR_DROP, "bad inline model number"); + return mod_inline[i]; + } + + // + // search the currently loaded models + // + for (i=0; i Math.abs(maxs[i]) ? Math.abs(mins[i]) : Math.abs(maxs[i]); + } + return Math3D.VectorLength(corner); + } + + + /* + ================= + Mod_LoadSubmodels + ================= + */ + void Mod_LoadSubmodels(lump_t l) { + + if ((l.filelen % qfiles.dmodel_t.SIZE) != 0) + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + + loadmodel.name); + + int i, j; + + int count = l.filelen / qfiles.dmodel_t.SIZE; + // out = Hunk_Alloc ( count*sizeof(*out)); + mmodel_t out; + mmodel_t[] outs = new mmodel_t[count]; + for (i = 0; i < count; i++) { + outs[i] = new mmodel_t(); + } + + loadmodel.submodels = outs; + loadmodel.numsubmodels = count; + + ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen); + bb.order(ByteOrder.LITTLE_ENDIAN); + + qfiles.dmodel_t in; + + for (i = 0; i < count; i++) { + in = new qfiles.dmodel_t(bb); + out = outs[i]; + for (j = 0; j < 3; j++) { // spread the mins / maxs by a + // pixel + out.mins[j] = in.mins[j] - 1; + out.maxs[j] = in.maxs[j] + 1; + out.origin[j] = in.origin[j]; + } + out.radius = RadiusFromBounds(out.mins, out.maxs); + out.headnode = in.headnode; + out.firstface = in.firstface; + out.numfaces = in.numfaces; + } + } + + /* + ================= + Mod_LoadEdges + ================= + */ + void Mod_LoadEdges (lump_t l) + { + medge_t[] edges; + int i, count; + + if ( (l.filelen % medge_t.DISK_SIZE) != 0) + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + + count = l.filelen / medge_t.DISK_SIZE; + // out = Hunk_Alloc ( (count + 1) * sizeof(*out)); + edges = new medge_t[count + 1]; + + loadmodel.edges = edges; + loadmodel.numedges = count; + + ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen); + bb.order(ByteOrder.LITTLE_ENDIAN); + + for ( i=0 ; i 0) + out[i].next = loadmodel.texinfo[next]; + else + out[i].next = null; + + name = "textures/" + in.texture + ".wal"; + + out[i].image = GL_FindImage(name, it_wall); + if (out[i].image == null) { + VID.Printf(Defines.PRINT_ALL, "Couldn't load " + name + '\n'); + out[i].image = r_notexture; + } + } + + // count animation frames + for (i=0 ; i= 0) + v = loadmodel.vertexes[loadmodel.edges[e].v[0]]; + else + v = loadmodel.vertexes[loadmodel.edges[-e].v[1]]; + + for (j=0 ; j<2 ; j++) + { + val = v.position[0] * tex.vecs[j][0] + + v.position[1] * tex.vecs[j][1] + + v.position[2] * tex.vecs[j][2] + + tex.vecs[j][3]; + if (val < mins[j]) + mins[j] = val; + if (val > maxs[j]) + maxs[j] = val; + } + } + + for (int i=0 ; i<2 ; i++) + { + bmins[i] = (int)Math.floor(mins[i]/16); + bmaxs[i] = (int)Math.ceil(maxs[i]/16); + + s.texturemins[i] = (short)(bmins[i] * 16); + s.extents[i] = (short)((bmaxs[i] - bmins[i]) * 16); + + } + } + + /* + ================= + Mod_LoadFaces + ================= + */ + void Mod_LoadFaces(lump_t l) { + + int i, surfnum; + int planenum, side; + int ti; + + if ((l.filelen % qfiles.dface_t.SIZE) != 0) + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + + loadmodel.name); + + int count = l.filelen / qfiles.dface_t.SIZE; + // out = Hunk_Alloc ( count*sizeof(*out)); + msurface_t[] outs = new msurface_t[count]; + for (i = 0; i < count; i++) { + outs[i] = new msurface_t(); + } + + loadmodel.surfaces = outs; + loadmodel.numsurfaces = count; + + ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen); + bb.order(ByteOrder.LITTLE_ENDIAN); + + currentmodel = loadmodel; + + GL_BeginBuildingLightmaps(loadmodel); + + qfiles.dface_t in; + msurface_t out; + + for (surfnum = 0; surfnum < count; surfnum++) { + in = new qfiles.dface_t(bb); + out = outs[surfnum]; + out.firstedge = in.firstedge; + out.numedges = in.numedges; + out.flags = 0; + out.polys = null; + + planenum = in.planenum; + side = in.side; + if (side != 0) + out.flags |= Defines.SURF_PLANEBACK; + + out.plane = loadmodel.planes[planenum]; + + ti = in.texinfo; + if (ti < 0 || ti >= loadmodel.numtexinfo) + Com.Error(Defines.ERR_DROP, + "MOD_LoadBmodel: bad texinfo number"); + + out.texinfo = loadmodel.texinfo[ti]; + + CalcSurfaceExtents(out); + + // lighting info + + for (i = 0; i < Defines.MAXLIGHTMAPS; i++) + out.styles[i] = in.styles[i]; + + i = in.lightofs; + if (i == -1) + out.samples = null; + else { + ByteBuffer pointer = ByteBuffer.wrap(loadmodel.lightdata); + pointer.position(i); + pointer = pointer.slice(); + pointer.mark(); + out.samples = pointer; // subarray + } + + // set the drawing flags + + if ((out.texinfo.flags & Defines.SURF_WARP) != 0) { + out.flags |= Defines.SURF_DRAWTURB; + for (i = 0; i < 2; i++) { + out.extents[i] = 16384; + out.texturemins[i] = -8192; + } + GL_SubdivideSurface(out); // cut up polygon for warps + } + + // create lightmaps and polygons + if ((out.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 + | Defines.SURF_TRANS66 | Defines.SURF_WARP)) == 0) + GL_CreateSurfaceLightmap(out); + + if ((out.texinfo.flags & Defines.SURF_WARP) == 0) + GL_BuildPolygonFromSurface(out); + + } + GL_EndBuildingLightmaps(); + } + + + /* + ================= + Mod_SetParent + ================= + */ + void Mod_SetParent(mnode_t node, mnode_t parent) + { + node.parent = parent; + if (node.contents != -1) return; + Mod_SetParent(node.children[0], node); + Mod_SetParent(node.children[1], node); + } + + /* + ================= + Mod_LoadNodes + ================= + */ + void Mod_LoadNodes(lump_t l) + { + int i, j, count, p; + qfiles.dnode_t in; + mnode_t[] out; + + if ((l.filelen % qfiles.dnode_t.SIZE) != 0) + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + + count = l.filelen / qfiles.dnode_t.SIZE; + // out = Hunk_Alloc ( count*sizeof(*out)); + out = new mnode_t[count]; + + loadmodel.nodes = out; + loadmodel.numnodes = count; + + ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen); + bb.order(ByteOrder.LITTLE_ENDIAN); + + // initialize the tree array + for ( i=0 ; i= 0) + out[i].children[j] = loadmodel.nodes[p]; + else + out[i].children[j] = loadmodel.leafs[-1 - p]; // mleaf_t extends mnode_t + } + } + + Mod_SetParent(loadmodel.nodes[0], null); // sets nodes and leafs + } + + /* + ================= + Mod_LoadLeafs + ================= + */ + void Mod_LoadLeafs(lump_t l) + { + qfiles.dleaf_t in; + mleaf_t[] out; + int i, j, count; + + if ((l.filelen % qfiles.dleaf_t.SIZE) != 0) + Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + + count = l.filelen / qfiles.dleaf_t.SIZE; + // out = Hunk_Alloc ( count*sizeof(*out)); + out = new mleaf_t[count]; + + loadmodel.leafs = out; + loadmodel.numleafs = count; + + ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen); + bb.order(ByteOrder.LITTLE_ENDIAN); + + for ( i=0 ; i= loadmodel.numsurfaces) + Com.Error(Defines.ERR_DROP, "Mod_ParseMarksurfaces: bad surface number"); + + out[i] = loadmodel.surfaces[j]; + } + } + + + /* + ================= + Mod_LoadSurfedges + ================= + */ + void Mod_LoadSurfedges(lump_t l) + { + int i, count; + int[] offsets; + + if ( (l.filelen % Defines.SIZE_OF_INT) != 0) + Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + + count = l.filelen / Defines.SIZE_OF_INT; + if (count < 1 || count >= Defines.MAX_MAP_SURFEDGES) + Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: bad surfedges count in " + loadmodel.name + ": " + count); + + offsets = new int[count]; + + loadmodel.surfedges = offsets; + loadmodel.numsurfedges = count; + + ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen); + bb.order(ByteOrder.LITTLE_ENDIAN); + + for ( i=0 ; i= loadmodel.numnodes) + Com.Error(Defines.ERR_DROP, "Inline model " + i + " has bad firstnode"); + + Math3D.VectorCopy(bm.maxs, starmod.maxs); + Math3D.VectorCopy(bm.mins, starmod.mins); + starmod.radius = bm.radius; + + if (i == 0) + loadmodel = starmod.copy(); + + starmod.numleafs = bm.visleafs; + } + } + + /* + ============================================================================== + + ALIAS MODELS + + ============================================================================== + */ + + /* + ================= + Mod_LoadAliasModel + ================= + */ + void Mod_LoadAliasModel (model_t mod, ByteBuffer buffer) + { + int i; + qfiles.dmdl_t pheader; + qfiles.dstvert_t[] poutst; + qfiles.dtriangle_t[] pouttri; + qfiles.daliasframe_t[] poutframe; + int[] poutcmd; + + pheader = new qfiles.dmdl_t(buffer); + + if (pheader.version != qfiles.ALIAS_VERSION) + Com.Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)", + new Vargs(3).add(mod.name).add(pheader.version).add(qfiles.ALIAS_VERSION)); + + if (pheader.skinheight > MAX_LBM_HEIGHT) + Com.Error(Defines.ERR_DROP, "model "+ mod.name +" has a skin taller than " + MAX_LBM_HEIGHT); + + if (pheader.num_xyz <= 0) + Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no vertices"); + + if (pheader.num_xyz > qfiles.MAX_VERTS) + Com.Error(Defines.ERR_DROP, "model " + mod.name +" has too many vertices"); + + if (pheader.num_st <= 0) + Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no st vertices"); + + if (pheader.num_tris <= 0) + Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no triangles"); + + if (pheader.num_frames <= 0) + Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no frames"); + + // + // load base s and t vertices (not used in gl version) + // + poutst = new qfiles.dstvert_t[pheader.num_st]; + buffer.position(pheader.ofs_st); + for (i=0 ; i -1) { + skinNames[i] = skinNames[i].substring(0, n); + } + mod.skins[i] = GL_FindImage(skinNames[i], it_skin); + } + + // set the model arrays + pheader.skinNames = skinNames; // skin names + pheader.stVerts = poutst; // textur koordinaten + pheader.triAngles = pouttri; // dreiecke + pheader.glCmds = poutcmd; // STRIP or FAN + pheader.aliasFrames = poutframe; // frames mit vertex array + + mod.extradata = pheader; + + mod.mins[0] = -32; + mod.mins[1] = -32; + mod.mins[2] = -32; + mod.maxs[0] = 32; + mod.maxs[1] = 32; + mod.maxs[2] = 32; + + precompileGLCmds(pheader); + } + + /* + ============================================================================== + + SPRITE MODELS + + ============================================================================== + */ + + /* + ================= + Mod_LoadSpriteModel + ================= + */ + void Mod_LoadSpriteModel(model_t mod, ByteBuffer buffer) + { + qfiles.dsprite_t sprout = new qfiles.dsprite_t(buffer); + + if (sprout.version != qfiles.SPRITE_VERSION) + Com.Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)", + new Vargs(3).add(mod.name).add(sprout.version).add(qfiles.SPRITE_VERSION)); + + if (sprout.numframes > qfiles.MAX_MD2SKINS) + Com.Error(Defines.ERR_DROP, "%s has too many frames (%i > %i)", + new Vargs(3).add(mod.name).add(sprout.numframes).add(qfiles.MAX_MD2SKINS)); + + for (int i=0 ; i tmp = new Vector(); + + int count = 0; + int[] order = model.glCmds; + int orderIndex = 0; + while (true) + { + // get the vertex count and primitive type + count = order[orderIndex++]; + if (count == 0) + break; // done + + tmp.addElement(new Integer(count)); + + if (count < 0) + { + count = -count; + //gl.glBegin (GL.GL_TRIANGLE_FAN); + } + else + { + //gl.glBegin (GL.GL_TRIANGLE_STRIP); + } + + do { + // texture coordinates come from the draw list + globalModelTextureCoordBuf.put(Float.intBitsToFloat(order[orderIndex + 0])); + globalModelTextureCoordBuf.put(Float.intBitsToFloat(order[orderIndex + 1])); + globalModelVertexIndexBuf.put(order[orderIndex + 2]); + + orderIndex += 3; + } while (--count != 0); + } + + int size = tmp.size(); + + model.counts = new int[size]; + model.indexElements = new IntBuffer[size]; + + count = 0; + int pos = 0; + for (int i = 0; i < model.counts.length; i++) { + count = ((Integer)tmp.get(i)).intValue(); + model.counts[i] = count; + + count = (count < 0) ? -count : count; + model.vertexIndexBuf.position(pos); + model.indexElements[i] = model.vertexIndexBuf.slice(); + model.indexElements[i].limit(count); + pos += count; + } + } + + static void resetModelArrays() { + globalModelTextureCoordBuf.rewind(); + globalModelVertexIndexBuf.rewind(); + } + + static void modelMemoryUsage() { + System.out.println("AliasModels: globalVertexBuffer size " + globalModelVertexIndexBuf.position()); + } } diff --git a/src/main/java/lwjake2/render/lwjgl/Polygon.java b/src/main/java/lwjake2/render/lwjgl/Polygon.java index 2904c7c..2778663 100644 --- a/src/main/java/lwjake2/render/lwjgl/Polygon.java +++ b/src/main/java/lwjake2/render/lwjgl/Polygon.java @@ -30,123 +30,123 @@ import java.nio.FloatBuffer; */ public final class Polygon extends glpoly_t { - private final static int MAX_POLYS = 20000; - private final static int MAX_BUFFER_VERTICES = 120000; - - // backup for s1 scrolling - private static float[] s1_old = new float[MAX_VERTICES]; + private final static int MAX_POLYS = 20000; + private final static int MAX_BUFFER_VERTICES = 120000; + + // backup for s1 scrolling + private static float[] s1_old = new float[MAX_VERTICES]; - private static FloatBuffer buffer = Lib.newFloatBuffer(MAX_BUFFER_VERTICES * STRIDE); - private static int bufferIndex = 0; - private static int polyCount = 0; - private static Polygon[] polyCache = new Polygon[MAX_POLYS]; - static { - for (int i = 0; i < polyCache.length; i++) { + private static FloatBuffer buffer = Lib.newFloatBuffer(MAX_BUFFER_VERTICES * STRIDE); + private static int bufferIndex = 0; + private static int polyCount = 0; + private static Polygon[] polyCache = new Polygon[MAX_POLYS]; + static { + for (int i = 0; i < polyCache.length; i++) { polyCache[i] = new Polygon(); } - } - - static glpoly_t create(int numverts) { - Polygon poly = polyCache[polyCount++]; - poly.clear(); - poly.numverts = numverts; - poly.pos = bufferIndex; - bufferIndex += numverts; - return poly; - } - - static void reset() { - polyCount = 0; - bufferIndex = 0; - } - - static FloatBuffer getInterleavedBuffer() { - return (FloatBuffer)buffer.rewind(); - } - - private Polygon() { - } - - private final void clear() { - next = null; - chain = null; - numverts = 0; - flags = 0; - } + } + + static glpoly_t create(int numverts) { + Polygon poly = polyCache[polyCount++]; + poly.clear(); + poly.numverts = numverts; + poly.pos = bufferIndex; + bufferIndex += numverts; + return poly; + } + + static void reset() { + polyCount = 0; + bufferIndex = 0; + } + + static FloatBuffer getInterleavedBuffer() { + return (FloatBuffer)buffer.rewind(); + } + + private Polygon() { + } + + private final void clear() { + next = null; + chain = null; + numverts = 0; + flags = 0; + } - // the interleaved buffer has the format: - // textureCoord0 (index 0, 1) - // vertex (index 2, 3, 4) - // textureCoord1 (index 5, 6) + // the interleaved buffer has the format: + // textureCoord0 (index 0, 1) + // vertex (index 2, 3, 4) + // textureCoord1 (index 5, 6) - public final float x(int index) { - return buffer.get((index + pos) * 7 + 2); - } - - public final void x(int index, float value) { - buffer.put((index + pos) * 7 + 2, value); - } + public final float x(int index) { + return buffer.get((index + pos) * 7 + 2); + } + + public final void x(int index, float value) { + buffer.put((index + pos) * 7 + 2, value); + } - public final float y(int index) { - return buffer.get((index + pos) * 7 + 3); - } - - public final void y(int index, float value) { - buffer.put((index + pos) * 7 + 3, value); - } - - public final float z(int index) { - return buffer.get((index + pos) * 7 + 4); - } - - public final void z(int index, float value) { - buffer.put((index + pos) * 7 + 4, value); - } + public final float y(int index) { + return buffer.get((index + pos) * 7 + 3); + } + + public final void y(int index, float value) { + buffer.put((index + pos) * 7 + 3, value); + } + + public final float z(int index) { + return buffer.get((index + pos) * 7 + 4); + } + + public final void z(int index, float value) { + buffer.put((index + pos) * 7 + 4, value); + } - public final float s1(int index) { - return buffer.get((index + pos) * 7 + 0); - } - - public final void s1(int index, float value) { - buffer.put((index + pos) * 7 + 0, value); - } + public final float s1(int index) { + return buffer.get((index + pos) * 7 + 0); + } + + public final void s1(int index, float value) { + buffer.put((index + pos) * 7 + 0, value); + } - public final float t1(int index) { - return buffer.get((index + pos) * 7 + 1); - } - - public final void t1(int index, float value) { - buffer.put((index + pos) * 7 + 1, value); - } + public final float t1(int index) { + return buffer.get((index + pos) * 7 + 1); + } + + public final void t1(int index, float value) { + buffer.put((index + pos) * 7 + 1, value); + } - public final float s2(int index) { - return buffer.get((index + pos) * 7 + 5); - } - - public final void s2(int index, float value) { - buffer.put((index + pos) * 7 + 5, value); - } + public final float s2(int index) { + return buffer.get((index + pos) * 7 + 5); + } + + public final void s2(int index, float value) { + buffer.put((index + pos) * 7 + 5, value); + } - public final float t2(int index) { - return buffer.get((index + pos) * 7 + 6); - } - - public final void t2(int index, float value) { - buffer.put((index + pos) * 7 + 6, value); - } - - public final void beginScrolling(float scroll) { - int index = pos * 7; - for (int i = 0; i < numverts; i++, index+=7) { - scroll += s1_old[i] = buffer.get(index); + public final float t2(int index) { + return buffer.get((index + pos) * 7 + 6); + } + + public final void t2(int index, float value) { + buffer.put((index + pos) * 7 + 6, value); + } + + public final void beginScrolling(float scroll) { + int index = pos * 7; + for (int i = 0; i < numverts; i++, index+=7) { + scroll += s1_old[i] = buffer.get(index); buffer.put(index, scroll); } - } + } - public final void endScrolling() { - int index = pos * 7; - for (int i = 0; i < numverts; i++, index+=7) { + public final void endScrolling() { + int index = pos * 7; + for (int i = 0; i < numverts; i++, index+=7) { buffer.put(index, s1_old[i]); } - } + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/render/lwjgl/Surf.java b/src/main/java/lwjake2/render/lwjgl/Surf.java index 4ecf394..c7969b3 100644 --- a/src/main/java/lwjake2/render/lwjgl/Surf.java +++ b/src/main/java/lwjake2/render/lwjgl/Surf.java @@ -51,120 +51,120 @@ import org.lwjgl.opengl.GL11; */ public abstract class Surf extends Draw { - // GL_RSURF.C: surface-related refresh code - float[] modelorg = {0, 0, 0}; // relative to viewpoint + // GL_RSURF.C: surface-related refresh code + float[] modelorg = {0, 0, 0}; // relative to viewpoint - msurface_t r_alpha_surfaces; + msurface_t r_alpha_surfaces; - static final int DYNAMIC_LIGHT_WIDTH = 128; - static final int DYNAMIC_LIGHT_HEIGHT = 128; + static final int DYNAMIC_LIGHT_WIDTH = 128; + static final int DYNAMIC_LIGHT_HEIGHT = 128; - static final int LIGHTMAP_BYTES = 4; + static final int LIGHTMAP_BYTES = 4; - static final int BLOCK_WIDTH = 128; - static final int BLOCK_HEIGHT = 128; + static final int BLOCK_WIDTH = 128; + static final int BLOCK_HEIGHT = 128; - static final int MAX_LIGHTMAPS = 128; + static final int MAX_LIGHTMAPS = 128; - int c_visible_lightmaps; - int c_visible_textures; + int c_visible_lightmaps; + int c_visible_textures; - static final int GL_LIGHTMAP_FORMAT = GL11.GL_RGBA; + static final int GL_LIGHTMAP_FORMAT = GL11.GL_RGBA; - static class gllightmapstate_t - { - int internal_format; - int current_lightmap_texture; + static class gllightmapstate_t + { + int internal_format; + int current_lightmap_texture; - msurface_t[] lightmap_surfaces = new msurface_t[MAX_LIGHTMAPS]; - int[] allocated = new int[BLOCK_WIDTH]; + msurface_t[] lightmap_surfaces = new msurface_t[MAX_LIGHTMAPS]; + int[] allocated = new int[BLOCK_WIDTH]; - // the lightmap texture data needs to be kept in - // main memory so texsubimage can update properly - //byte[] lightmap_buffer = new byte[4 * BLOCK_WIDTH * BLOCK_HEIGHT]; - IntBuffer lightmap_buffer = Lib.newIntBuffer(BLOCK_WIDTH * BLOCK_HEIGHT, ByteOrder.LITTLE_ENDIAN); - - public gllightmapstate_t() { - for (int i = 0; i < MAX_LIGHTMAPS; i++) - lightmap_surfaces[i] = new msurface_t(); - } - - public void clearLightmapSurfaces() { - for (int i = 0; i < MAX_LIGHTMAPS; i++) - // TODO lightmap_surfaces[i].clear(); - lightmap_surfaces[i] = new msurface_t(); - } - - } + // the lightmap texture data needs to be kept in + // main memory so texsubimage can update properly + //byte[] lightmap_buffer = new byte[4 * BLOCK_WIDTH * BLOCK_HEIGHT]; + IntBuffer lightmap_buffer = Lib.newIntBuffer(BLOCK_WIDTH * BLOCK_HEIGHT, ByteOrder.LITTLE_ENDIAN); + + public gllightmapstate_t() { + for (int i = 0; i < MAX_LIGHTMAPS; i++) + lightmap_surfaces[i] = new msurface_t(); + } + + public void clearLightmapSurfaces() { + for (int i = 0; i < MAX_LIGHTMAPS; i++) + // TODO lightmap_surfaces[i].clear(); + lightmap_surfaces[i] = new msurface_t(); + } + + } - gllightmapstate_t gl_lms = new gllightmapstate_t(); + gllightmapstate_t gl_lms = new gllightmapstate_t(); - // Model.java - abstract byte[] Mod_ClusterPVS(int cluster, model_t model); - // Warp.java - abstract void R_DrawSkyBox(); - abstract void R_AddSkySurface(msurface_t surface); - abstract void R_ClearSkyBox(); - abstract void EmitWaterPolys(msurface_t fa); - // Light.java - abstract void R_MarkLights (dlight_t light, int bit, mnode_t node); - abstract void R_SetCacheState( msurface_t surf ); - abstract void R_BuildLightMap(msurface_t surf, IntBuffer dest, int stride); + // Model.java + abstract byte[] Mod_ClusterPVS(int cluster, model_t model); + // Warp.java + abstract void R_DrawSkyBox(); + abstract void R_AddSkySurface(msurface_t surface); + abstract void R_ClearSkyBox(); + abstract void EmitWaterPolys(msurface_t fa); + // Light.java + abstract void R_MarkLights (dlight_t light, int bit, mnode_t node); + abstract void R_SetCacheState( msurface_t surf ); + abstract void R_BuildLightMap(msurface_t surf, IntBuffer dest, int stride); - /* - ============================================================= + /* + ============================================================= - BRUSH MODELS + BRUSH MODELS - ============================================================= - */ + ============================================================= + */ - /** - * R_TextureAnimation - * Returns the proper texture for a given time and base texture - */ - image_t R_TextureAnimation(mtexinfo_t tex) - { - if (tex.next == null) - return tex.image; + /** + * R_TextureAnimation + * Returns the proper texture for a given time and base texture + */ + image_t R_TextureAnimation(mtexinfo_t tex) + { + if (tex.next == null) + return tex.image; - int c = currententity.frame % tex.numframes; - while (c != 0) - { - tex = tex.next; - c--; - } + int c = currententity.frame % tex.numframes; + while (c != 0) + { + tex = tex.next; + c--; + } - return tex.image; - } + return tex.image; + } - /** - * DrawGLPoly - */ - void DrawGLPoly(glpoly_t p) - { - GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); - } + /** + * DrawGLPoly + */ + void DrawGLPoly(glpoly_t p) + { + GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); + } - /** - * DrawGLFlowingPoly - * version that handles scrolling texture - */ - void DrawGLFlowingPoly(glpoly_t p) - { - float scroll = -64 * ( (r_newrefdef.time / 40.0f) - (int)(r_newrefdef.time / 40.0f) ); - if(scroll == 0.0f) - scroll = -64.0f; - p.beginScrolling(scroll); - GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); - p.endScrolling(); - } + /** + * DrawGLFlowingPoly + * version that handles scrolling texture + */ + void DrawGLFlowingPoly(glpoly_t p) + { + float scroll = -64 * ( (r_newrefdef.time / 40.0f) - (int)(r_newrefdef.time / 40.0f) ); + if(scroll == 0.0f) + scroll = -64.0f; + p.beginScrolling(scroll); + GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); + p.endScrolling(); + } - /** - * R_DrawTriangleOutlines - */ - void R_DrawTriangleOutlines() - { + /** + * R_DrawTriangleOutlines + */ + void R_DrawTriangleOutlines() + { if (gl_showtris.value == 0) return; @@ -174,16 +174,16 @@ public abstract class Surf extends Draw { msurface_t surf; glpoly_t p; - int j; + int j; for (int i = 0; i < MAX_LIGHTMAPS; i++) { for (surf = gl_lms.lightmap_surfaces[i]; surf != null; surf = surf.lightmapchain) { for (p = surf.polys; p != null; p = p.chain) { for (j = 2; j < p.numverts; j++) { GL11.glBegin(GL11.GL_LINE_STRIP); - GL11.glVertex3f(p.x(0), p.y(0), p.z(0)); - GL11.glVertex3f(p.x(j-1), p.y(j-1), p.z(j-1)); - GL11.glVertex3f(p.x(j), p.y(j), p.z(j)); - GL11.glVertex3f(p.x(0), p.y(0), p.z(0)); + GL11.glVertex3f(p.x(0), p.y(0), p.z(0)); + GL11.glVertex3f(p.x(j-1), p.y(j-1), p.z(j-1)); + GL11.glVertex3f(p.x(j), p.y(j), p.z(j)); + GL11.glVertex3f(p.x(0), p.y(0), p.z(0)); GL11.glEnd(); } } @@ -192,1146 +192,1146 @@ public abstract class Surf extends Draw { GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); - } - - private final IntBuffer temp2 = Lib.newIntBuffer(34 * 34, ByteOrder.LITTLE_ENDIAN); - - /** - * R_RenderBrushPoly - */ - void R_RenderBrushPoly(msurface_t fa) - { - c_brush_polys++; - - image_t image = R_TextureAnimation(fa.texinfo); - - if ((fa.flags & Defines.SURF_DRAWTURB) != 0) - { - GL_Bind( image.texnum ); - - // warp texture, no lightmaps - GL_TexEnv( GL11.GL_MODULATE ); - GL11.glColor4f( gl_state.inverse_intensity, - gl_state.inverse_intensity, - gl_state.inverse_intensity, - 1.0F ); - EmitWaterPolys (fa); - GL_TexEnv( GL11.GL_REPLACE ); - - return; - } - else - { - GL_Bind( image.texnum ); - GL_TexEnv( GL11.GL_REPLACE ); - } - - // ====== - // PGM - if((fa.texinfo.flags & Defines.SURF_FLOWING) != 0) - DrawGLFlowingPoly(fa.polys); - else - DrawGLPoly (fa.polys); - // PGM - // ====== - - // ersetzt goto - boolean gotoDynamic = false; - /* - ** check for lightmap modification - */ - int maps; - for ( maps = 0; maps < Defines.MAXLIGHTMAPS && fa.styles[maps] != (byte)255; maps++ ) - { - if ( r_newrefdef.lightstyles[fa.styles[maps] & 0xFF].white != fa.cached_light[maps] ) { - gotoDynamic = true; - break; - } - } - - // this is a hack from cwei - if (maps == 4) maps--; - - // dynamic this frame or dynamic previously - boolean is_dynamic = false; - if ( gotoDynamic || ( fa.dlightframe == r_framecount ) ) - { - // label dynamic: - if ( gl_dynamic.value != 0 ) - { - if (( fa.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP ) ) == 0) - { - is_dynamic = true; - } - } - } - - if ( is_dynamic ) - { - if ( ( (fa.styles[maps] & 0xFF) >= 32 || fa.styles[maps] == 0 ) && ( fa.dlightframe != r_framecount ) ) - { - // ist ersetzt durch temp2: unsigned temp[34*34]; - int smax, tmax; - - smax = (fa.extents[0]>>4)+1; - tmax = (fa.extents[1]>>4)+1; - - R_BuildLightMap( fa, temp2, smax); - R_SetCacheState( fa ); - - GL_Bind( gl_state.lightmap_textures + fa.lightmaptexturenum ); - - GL11.glTexSubImage2D( GL11.GL_TEXTURE_2D, 0, - fa.light_s, fa.light_t, - smax, tmax, - GL_LIGHTMAP_FORMAT, - GL11.GL_UNSIGNED_BYTE, temp2 ); - - fa.lightmapchain = gl_lms.lightmap_surfaces[fa.lightmaptexturenum]; - gl_lms.lightmap_surfaces[fa.lightmaptexturenum] = fa; - } - else - { - fa.lightmapchain = gl_lms.lightmap_surfaces[0]; - gl_lms.lightmap_surfaces[0] = fa; - } - } - else - { - fa.lightmapchain = gl_lms.lightmap_surfaces[fa.lightmaptexturenum]; - gl_lms.lightmap_surfaces[fa.lightmaptexturenum] = fa; - } - } - - - /** - * R_DrawAlphaSurfaces - * Draw water surfaces and windows. - * The BSP tree is waled front to back, so unwinding the chain - * of alpha_surfaces will draw back to front, giving proper ordering. - */ - void R_DrawAlphaSurfaces() - { - r_world_matrix.clear(); - // - // go back to the world matrix - // - GL11.glLoadMatrix(r_world_matrix); - - GL11.glEnable (GL11.GL_BLEND); - GL_TexEnv(GL11.GL_MODULATE ); - - - // the textures are prescaled up for a better lighting range, - // so scale it back down - float intens = gl_state.inverse_intensity; - - GL11.glInterleavedArrays(GL11.GL_T2F_V3F, Polygon.BYTE_STRIDE, globalPolygonInterleavedBuf); - - for (msurface_t s = r_alpha_surfaces ; s != null ; s=s.texturechain) - { - GL_Bind(s.texinfo.image.texnum); - c_brush_polys++; - if ((s.texinfo.flags & Defines.SURF_TRANS33) != 0) - GL11.glColor4f (intens, intens, intens, 0.33f); - else if ((s.texinfo.flags & Defines.SURF_TRANS66) != 0) - GL11.glColor4f (intens, intens, intens, 0.66f); - else - GL11.glColor4f (intens,intens,intens,1); - if ((s.flags & Defines.SURF_DRAWTURB) != 0) - EmitWaterPolys(s); - else if((s.texinfo.flags & Defines.SURF_FLOWING) != 0) // PGM 9/16/98 - DrawGLFlowingPoly(s.polys); // PGM - else - DrawGLPoly(s.polys); - } - - GL_TexEnv( GL11.GL_REPLACE ); - GL11.glColor4f (1,1,1,1); - GL11.glDisable (GL11.GL_BLEND); - - r_alpha_surfaces = null; - } - - /** - * DrawTextureChains - */ - void DrawTextureChains() - { - c_visible_textures = 0; - - msurface_t s; - image_t image; - int i; - for (i = 0; i < numgltextures ; i++) - { - image = gltextures[i]; - - if (image.registration_sequence == 0) - continue; - if (image.texturechain == null) - continue; - c_visible_textures++; - - for ( s = image.texturechain; s != null ; s=s.texturechain) - { - if ( ( s.flags & Defines.SURF_DRAWTURB) == 0 ) - R_RenderBrushPoly(s); - } - } - - GL_EnableMultitexture( false ); - for (i = 0; i < numgltextures ; i++) - { - image = gltextures[i]; - - if (image.registration_sequence == 0) - continue; - s = image.texturechain; - if (s == null) - continue; - - for ( ; s != null ; s=s.texturechain) - { - if ( (s.flags & Defines.SURF_DRAWTURB) != 0 ) - R_RenderBrushPoly(s); - } - - image.texturechain = null; - } - - GL_TexEnv( GL11.GL_REPLACE ); - } - - // direct buffer - private final IntBuffer temp = Lib.newIntBuffer(128 * 128, ByteOrder.LITTLE_ENDIAN); - - /** - * GL_RenderLightmappedPoly - * @param surf - */ - void GL_RenderLightmappedPoly( msurface_t surf ) - { - - // ersetzt goto - boolean gotoDynamic = false; - int map; - for ( map = 0; map < Defines.MAXLIGHTMAPS && (surf.styles[map] != (byte)255); map++ ) - { - if ( r_newrefdef.lightstyles[surf.styles[map] & 0xFF].white != surf.cached_light[map] ) { - gotoDynamic = true; - break; - } - } - - // this is a hack from cwei - if (map == 4) map--; - - // dynamic this frame or dynamic previously - boolean is_dynamic = false; - if ( gotoDynamic || ( surf.dlightframe == r_framecount ) ) - { - // label dynamic: - if ( gl_dynamic.value != 0 ) - { - if ( (surf.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP )) == 0 ) - { - is_dynamic = true; - } - } - } - - glpoly_t p; - image_t image = R_TextureAnimation( surf.texinfo ); - int lmtex = surf.lightmaptexturenum; - - if ( is_dynamic ) - { - // ist raus gezogen worden int[] temp = new int[128*128]; - int smax, tmax; - - if ( ( (surf.styles[map] & 0xFF) >= 32 || surf.styles[map] == 0 ) && ( surf.dlightframe != r_framecount ) ) - { - smax = (surf.extents[0]>>4)+1; - tmax = (surf.extents[1]>>4)+1; - - R_BuildLightMap( surf, temp, smax); - R_SetCacheState( surf ); - - GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + surf.lightmaptexturenum ); - - lmtex = surf.lightmaptexturenum; - - GL11.glTexSubImage2D( GL11.GL_TEXTURE_2D, 0, - surf.light_s, surf.light_t, - smax, tmax, - GL_LIGHTMAP_FORMAT, - GL11.GL_UNSIGNED_BYTE, temp ); - - } - else - { - smax = (surf.extents[0]>>4)+1; - tmax = (surf.extents[1]>>4)+1; - - R_BuildLightMap( surf, temp, smax); - - GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + 0 ); - - lmtex = 0; - - GL11.glTexSubImage2D( GL11.GL_TEXTURE_2D, 0, - surf.light_s, surf.light_t, - smax, tmax, - GL_LIGHTMAP_FORMAT, - GL11.GL_UNSIGNED_BYTE, temp ); - - } - - c_brush_polys++; - - GL_MBind( GL_TEXTURE0, image.texnum ); - GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + lmtex ); - - // ========== - // PGM - if ((surf.texinfo.flags & Defines.SURF_FLOWING) != 0) - { - float scroll; - - scroll = -64 * ( (r_newrefdef.time / 40.0f) - (int)(r_newrefdef.time / 40.0f) ); - if(scroll == 0.0f) - scroll = -64.0f; - - for ( p = surf.polys; p != null; p = p.chain ) - { - p.beginScrolling(scroll); - GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); - p.endScrolling(); - } - } - else - { - for ( p = surf.polys; p != null; p = p.chain ) - { - GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); - } - } - // PGM - // ========== - } - else - { - c_brush_polys++; - - GL_MBind( GL_TEXTURE0, image.texnum ); - GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + lmtex); - - // ========== - // PGM - if ((surf.texinfo.flags & Defines.SURF_FLOWING) != 0) - { - float scroll; - - scroll = -64 * ( (r_newrefdef.time / 40.0f) - (int)(r_newrefdef.time / 40.0f) ); - if(scroll == 0.0) - scroll = -64.0f; - - for ( p = surf.polys; p != null; p = p.chain ) - { - p.beginScrolling(scroll); - GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); - p.endScrolling(); - } - } - else - { - // PGM - // ========== - for ( p = surf.polys; p != null; p = p.chain ) - { - GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); - } - - // ========== - // PGM - } - // PGM - // ========== - } - } - - /** - * R_DrawInlineBModel - */ - void R_DrawInlineBModel() - { - // calculate dynamic lighting for bmodel - if ( gl_flashblend.value == 0 ) - { - dlight_t lt; - for (int k=0 ; ksurfaces[currentmodel->firstmodelsurface]; - int psurfp = currentmodel.firstmodelsurface; - msurface_t[] surfaces = currentmodel.surfaces; - //psurf = surfaces[psurfp]; - - if ( (currententity.flags & Defines.RF_TRANSLUCENT) != 0 ) - { - GL11.glEnable (GL11.GL_BLEND); - GL11.glColor4f (1,1,1,0.25f); - GL_TexEnv( GL11.GL_MODULATE ); - } - - // - // draw texture - // - msurface_t psurf; - cplane_t pplane; - float dot; - for (int i=0 ; i BACKFACE_EPSILON))) - { - if ((psurf.texinfo.flags & (Defines.SURF_TRANS33 | Defines.SURF_TRANS66)) != 0 ) - { // add to the translucent chain - psurf.texturechain = r_alpha_surfaces; - r_alpha_surfaces = psurf; - } - else if ( (psurf.flags & Defines.SURF_DRAWTURB) == 0 ) - { - GL_RenderLightmappedPoly( psurf ); - } - else - { - GL_EnableMultitexture( false ); - R_RenderBrushPoly( psurf ); - GL_EnableMultitexture( true ); - } - } - } - - if ( (currententity.flags & Defines.RF_TRANSLUCENT) != 0 ) { - GL11.glDisable (GL11.GL_BLEND); - GL11.glColor4f (1,1,1,1); - GL_TexEnv( GL11.GL_REPLACE ); - } - } - - // stack variable - private final float[] mins = {0, 0, 0}; - private final float[] maxs = {0, 0, 0}; - private final float[] org = {0, 0, 0}; - private final float[] forward = {0, 0, 0}; - private final float[] right = {0, 0, 0}; - private final float[] up = {0, 0, 0}; - /** - * R_DrawBrushModel - */ - void R_DrawBrushModel(entity_t e) - { - if (currentmodel.nummodelsurfaces == 0) - return; - - currententity = e; - gl_state.currenttextures[0] = gl_state.currenttextures[1] = -1; - - boolean rotated; - if (e.angles[0] != 0 || e.angles[1] != 0 || e.angles[2] != 0) - { - rotated = true; - for (int i=0 ; i<3 ; i++) - { - mins[i] = e.origin[i] - currentmodel.radius; - maxs[i] = e.origin[i] + currentmodel.radius; - } - } - else - { - rotated = false; - Math3D.VectorAdd(e.origin, currentmodel.mins, mins); - Math3D.VectorAdd(e.origin, currentmodel.maxs, maxs); - } - - if (R_CullBox(mins, maxs)) return; - - GL11.glColor3f (1,1,1); - - // memset (gl_lms.lightmap_surfaces, 0, sizeof(gl_lms.lightmap_surfaces)); - - // TODO wird beim multitexturing nicht gebraucht - //gl_lms.clearLightmapSurfaces(); - - Math3D.VectorSubtract (r_newrefdef.vieworg, e.origin, modelorg); - if (rotated) - { - Math3D.VectorCopy (modelorg, org); - Math3D.AngleVectors (e.angles, forward, right, up); - modelorg[0] = Math3D.DotProduct (org, forward); - modelorg[1] = -Math3D.DotProduct (org, right); - modelorg[2] = Math3D.DotProduct (org, up); - } - - GL11.glPushMatrix(); - - e.angles[0] = -e.angles[0]; // stupid quake bug - e.angles[2] = -e.angles[2]; // stupid quake bug - R_RotateForEntity(e); - e.angles[0] = -e.angles[0]; // stupid quake bug - e.angles[2] = -e.angles[2]; // stupid quake bug - - GL_EnableMultitexture( true ); - GL_SelectTexture(GL_TEXTURE0); - GL_TexEnv( GL11.GL_REPLACE ); - GL11.glInterleavedArrays(GL11.GL_T2F_V3F, Polygon.BYTE_STRIDE, globalPolygonInterleavedBuf); - GL_SelectTexture(GL_TEXTURE1); - GL_TexEnv( GL11.GL_MODULATE ); - GL11.glTexCoordPointer(2, Polygon.BYTE_STRIDE, globalPolygonTexCoord1Buf); - GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); - - R_DrawInlineBModel(); - - ARBMultitexture.glClientActiveTextureARB(GL_TEXTURE1); - GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); - - GL_EnableMultitexture( false ); - - GL11.glPopMatrix(); - } - - /* - ============================================================= - - WORLD MODEL - - ============================================================= - */ - - /** - * R_RecursiveWorldNode - */ - void R_RecursiveWorldNode (mnode_t node) - { - if (node.contents == Defines.CONTENTS_SOLID) - return; // solid - - if (node.visframe != r_visframecount) - return; - - if (R_CullBox(node.mins, node.maxs)) - return; - - int c; - msurface_t mark; - // if a leaf node, draw stuff - if (node.contents != -1) - { - mleaf_t pleaf = (mleaf_t)node; - - // check for door connected areas - if (r_newrefdef.areabits != null) - { - if ( ((r_newrefdef.areabits[pleaf.area >> 3] & 0xFF) & (1 << (pleaf.area & 7)) ) == 0 ) - return; // not visible - } - - int markp = 0; - - mark = pleaf.getMarkSurface(markp); // first marked surface - c = pleaf.nummarksurfaces; - - if (c != 0) - { - do - { - mark.visframe = r_framecount; - mark = pleaf.getMarkSurface(++markp); // next surface - } while (--c != 0); - } - - return; - } - - // node is just a decision point, so go down the apropriate sides - - // find which side of the node we are on - cplane_t plane = node.plane; - float dot; - switch (plane.type) - { - case Defines.PLANE_X: - dot = modelorg[0] - plane.dist; - break; - case Defines.PLANE_Y: - dot = modelorg[1] - plane.dist; - break; - case Defines.PLANE_Z: - dot = modelorg[2] - plane.dist; - break; - default: - dot = Math3D.DotProduct(modelorg, plane.normal) - plane.dist; - break; - } - - int side, sidebit; - if (dot >= 0.0f) - { - side = 0; - sidebit = 0; - } - else - { - side = 1; - sidebit = Defines.SURF_PLANEBACK; - } - - // recurse down the children, front side first - R_RecursiveWorldNode(node.children[side]); - - // draw stuff - msurface_t surf; - image_t image; - //for ( c = node.numsurfaces, surf = r_worldmodel.surfaces[node.firstsurface]; c != 0 ; c--, surf++) - for ( c = 0; c < node.numsurfaces; c++) - { - surf = r_worldmodel.surfaces[node.firstsurface + c]; - if (surf.visframe != r_framecount) - continue; - - if ( (surf.flags & Defines.SURF_PLANEBACK) != sidebit ) - continue; // wrong side - - if ((surf.texinfo.flags & Defines.SURF_SKY) != 0) - { // just adds to visible sky bounds - R_AddSkySurface(surf); - } - else if ((surf.texinfo.flags & (Defines.SURF_TRANS33 | Defines.SURF_TRANS66)) != 0) - { // add to the translucent chain - surf.texturechain = r_alpha_surfaces; - r_alpha_surfaces = surf; - } - else - { - if ( ( surf.flags & Defines.SURF_DRAWTURB) == 0 ) - { - GL_RenderLightmappedPoly( surf ); - } - else - { - // the polygon is visible, so add it to the texture - // sorted chain - // FIXME: this is a hack for animation - image = R_TextureAnimation(surf.texinfo); - surf.texturechain = image.texturechain; - image.texturechain = surf; - } - } - } - // recurse down the back side - R_RecursiveWorldNode(node.children[1 - side]); - } - - private final entity_t worldEntity = new entity_t(); - - /** - * R_DrawWorld - */ - void R_DrawWorld() - { - if (r_drawworld.value == 0) - return; - - if ( (r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0 ) - return; - - currentmodel = r_worldmodel; - - Math3D.VectorCopy(r_newrefdef.vieworg, modelorg); - - entity_t ent = worldEntity; - // auto cycle the world frame for texture animation - ent.clear(); - ent.frame = (int)(r_newrefdef.time*2); - currententity = ent; - - gl_state.currenttextures[0] = gl_state.currenttextures[1] = -1; - - GL11.glColor3f (1,1,1); - // memset (gl_lms.lightmap_surfaces, 0, sizeof(gl_lms.lightmap_surfaces)); - // TODO wird bei multitexture nicht gebraucht - //gl_lms.clearLightmapSurfaces(); - - R_ClearSkyBox(); - - GL_EnableMultitexture( true ); - - GL_SelectTexture( GL_TEXTURE0); - GL_TexEnv( GL11.GL_REPLACE ); - GL11.glInterleavedArrays(GL11.GL_T2F_V3F, Polygon.BYTE_STRIDE, globalPolygonInterleavedBuf); - GL_SelectTexture( GL_TEXTURE1); - GL11.glTexCoordPointer(2, Polygon.BYTE_STRIDE, globalPolygonTexCoord1Buf); - GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); - - if ( gl_lightmap.value != 0) - GL_TexEnv( GL11.GL_REPLACE ); - else - GL_TexEnv( GL11.GL_MODULATE ); - - R_RecursiveWorldNode(r_worldmodel.nodes[0]); // root node - - ARBMultitexture.glClientActiveTextureARB(GL_TEXTURE1); - GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); - - GL_EnableMultitexture( false ); - - DrawTextureChains(); - R_DrawSkyBox(); - R_DrawTriangleOutlines(); - } - - final byte[] fatvis = new byte[Defines.MAX_MAP_LEAFS / 8]; - - /** - * R_MarkLeaves - * Mark the leaves and nodes that are in the PVS for the current - * cluster - */ - void R_MarkLeaves() - { - if (r_oldviewcluster == r_viewcluster && r_oldviewcluster2 == r_viewcluster2 && r_novis.value == 0 && r_viewcluster != -1) - return; - - // development aid to let you run around and see exactly where - // the pvs ends - if (gl_lockpvs.value != 0) - return; - - r_visframecount++; - r_oldviewcluster = r_viewcluster; - r_oldviewcluster2 = r_viewcluster2; - - int i; - if (r_novis.value != 0 || r_viewcluster == -1 || r_worldmodel.vis == null) - { - // mark everything - for (i=0 ; i> 3); - vis = Mod_ClusterPVS(r_viewcluster2, r_worldmodel); - c = (r_worldmodel.numleafs + 31) >> 5; - c <<= 2; - for (int k=0 ; k>3] & 0xFF) & (1 << (cluster & 7))) != 0) - { - node = (mnode_t)leaf; - do - { - if (node.visframe == r_visframecount) - break; - node.visframe = r_visframecount; - node = node.parent; - } while (node != null); - } - } - } - - /* - ============================================================================= - - LIGHTMAP ALLOCATION - - ============================================================================= - */ - - /** - * LM_InitBlock - */ - void LM_InitBlock() - { - Arrays.fill(gl_lms.allocated, 0); - } - - /** - * LM_UploadBlock - * @param dynamic - */ - void LM_UploadBlock( boolean dynamic ) - { - int texture = ( dynamic ) ? 0 : gl_lms.current_lightmap_texture; - - GL_Bind( gl_state.lightmap_textures + texture ); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); - - gl_lms.lightmap_buffer.rewind(); - if ( dynamic ) - { - int height = 0; - for (int i = 0; i < BLOCK_WIDTH; i++ ) - { - if ( gl_lms.allocated[i] > height ) - height = gl_lms.allocated[i]; - } - - GL11.glTexSubImage2D( GL11.GL_TEXTURE_2D, - 0, - 0, 0, - BLOCK_WIDTH, height, - GL_LIGHTMAP_FORMAT, - GL11.GL_UNSIGNED_BYTE, - gl_lms.lightmap_buffer ); - } - else - { - GL11.glTexImage2D( GL11.GL_TEXTURE_2D, - 0, - gl_lms.internal_format, - BLOCK_WIDTH, BLOCK_HEIGHT, - 0, - GL_LIGHTMAP_FORMAT, - GL11.GL_UNSIGNED_BYTE, - gl_lms.lightmap_buffer ); - if ( ++gl_lms.current_lightmap_texture == MAX_LIGHTMAPS ) - Com.Error( Defines.ERR_DROP, "LM_UploadBlock() - MAX_LIGHTMAPS exceeded\n" ); - - //debugLightmap(gl_lms.lightmap_buffer, 128, 128, 4); - } - } - - /** - * LM_AllocBlock - * @param w - * @param h - * @param pos - * @return a texture number and the position inside it - */ - boolean LM_AllocBlock (int w, int h, pos_t pos) - { - int best = BLOCK_HEIGHT; - - int best2; - int i, j; - for (i=0 ; i= best) - break; - if (gl_lms.allocated[i+j] > best2) - best2 = gl_lms.allocated[i+j]; - } - if (j == w) - { // this is a valid spot - pos.x = i; - pos.y = best = best2; - } - } - - if (best + h > BLOCK_HEIGHT) - return false; - - for (i=0 ; i 0) - { - r_pedge = pedges[lindex]; - vec = currentmodel.vertexes[r_pedge.v[0]].position; - } - else - { - r_pedge = pedges[-lindex]; - vec = currentmodel.vertexes[r_pedge.v[1]].position; - } - s = Math3D.DotProduct (vec, fa.texinfo.vecs[0]) + fa.texinfo.vecs[0][3]; - s /= fa.texinfo.image.width; - - t = Math3D.DotProduct (vec, fa.texinfo.vecs[1]) + fa.texinfo.vecs[1][3]; - t /= fa.texinfo.image.height; - - poly.x(i, vec[0]); - poly.y(i, vec[1]); - poly.z(i, vec[2]); - - poly.s1(i, s); - poly.t1(i, t); - - // - // lightmap texture coordinates - // - s = Math3D.DotProduct (vec, fa.texinfo.vecs[0]) + fa.texinfo.vecs[0][3]; - s -= fa.texturemins[0]; - s += fa.light_s*16; - s += 8; - s /= BLOCK_WIDTH*16; //fa.texinfo.texture.width; - - t = Math3D.DotProduct (vec, fa.texinfo.vecs[1]) + fa.texinfo.vecs[1][3]; - t -= fa.texturemins[1]; - t += fa.light_t*16; - t += 8; - t /= BLOCK_HEIGHT*16; //fa.texinfo.texture.height; - - poly.s2(i, s); - poly.t2(i, t); - } - } - - /** - * GL_CreateSurfaceLightmap - */ - void GL_CreateSurfaceLightmap(msurface_t surf) - { - if ( (surf.flags & (Defines.SURF_DRAWSKY | Defines.SURF_DRAWTURB)) != 0) - return; - - int smax = (surf.extents[0]>>4)+1; - int tmax = (surf.extents[1]>>4)+1; - - pos_t lightPos = new pos_t(surf.light_s, surf.light_t); - - if ( !LM_AllocBlock( smax, tmax, lightPos ) ) - { - LM_UploadBlock( false ); - LM_InitBlock(); - lightPos = new pos_t(surf.light_s, surf.light_t); - if ( !LM_AllocBlock( smax, tmax, lightPos ) ) - { - Com.Error( Defines.ERR_FATAL, "Consecutive calls to LM_AllocBlock(" + smax +"," + tmax +") failed\n"); - } - } - - // kopiere die koordinaten zurueck - surf.light_s = lightPos.x; - surf.light_t = lightPos.y; - - surf.lightmaptexturenum = gl_lms.current_lightmap_texture; - - IntBuffer base = gl_lms.lightmap_buffer; - base.position(surf.light_t * BLOCK_WIDTH + surf.light_s); - - R_SetCacheState( surf ); - R_BuildLightMap(surf, base.slice(), BLOCK_WIDTH); - } - - lightstyle_t[] lightstyles; - private final IntBuffer dummy = BufferUtils.createIntBuffer(128*128); - - /** - * GL_BeginBuildingLightmaps - */ - void GL_BeginBuildingLightmaps(model_t m) - { - // static lightstyle_t lightstyles[MAX_LIGHTSTYLES]; - int i; - - // init lightstyles - if ( lightstyles == null ) { - lightstyles = new lightstyle_t[Defines.MAX_LIGHTSTYLES]; - for (i = 0; i < lightstyles.length; i++) - { - lightstyles[i] = new lightstyle_t(); - } - } - - // memset( gl_lms.allocated, 0, sizeof(gl_lms.allocated) ); - Arrays.fill(gl_lms.allocated, 0); - - r_framecount = 1; // no dlightcache - - GL_EnableMultitexture( true ); - GL_SelectTexture( GL_TEXTURE1); - - /* - ** setup the base lightstyles so the lightmaps won't have to be regenerated - ** the first time they're seen - */ - for (i=0 ; i < Defines.MAX_LIGHTSTYLES ; i++) - { - lightstyles[i].rgb[0] = 1; - lightstyles[i].rgb[1] = 1; - lightstyles[i].rgb[2] = 1; - lightstyles[i].white = 3; - } - r_newrefdef.lightstyles = lightstyles; - - if (gl_state.lightmap_textures == 0) - { - gl_state.lightmap_textures = TEXNUM_LIGHTMAPS; - } - - gl_lms.current_lightmap_texture = 1; - - /* - ** if mono lightmaps are enabled and we want to use alpha - ** blending (a,1-a) then we're likely running on a 3DLabs - ** Permedia2. In a perfect world we'd use a GL_ALPHA lightmap - ** in order to conserve space and maximize bandwidth, however - ** this isn't a perfect world. - ** - ** So we have to use alpha lightmaps, but stored in GL_RGBA format, - ** which means we only get 1/16th the color resolution we should when - ** using alpha lightmaps. If we find another board that supports - ** only alpha lightmaps but that can at least support the GL_ALPHA - ** format then we should change this code to use real alpha maps. - */ - - char format = gl_monolightmap.string.toUpperCase().charAt(0); - - if ( format == 'A' ) - { - gl_lms.internal_format = gl_tex_alpha_format; - } - /* - ** try to do hacked colored lighting with a blended texture - */ - else if ( format == 'C' ) - { - gl_lms.internal_format = gl_tex_alpha_format; - } - else if ( format == 'I' ) - { - gl_lms.internal_format = GL11.GL_INTENSITY8; - } - else if ( format == 'L' ) - { - gl_lms.internal_format = GL11.GL_LUMINANCE8; - } - else - { - gl_lms.internal_format = gl_tex_solid_format; - } - - /* - ** initialize the dynamic lightmap texture - */ - GL_Bind( gl_state.lightmap_textures + 0 ); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); - GL11.glTexImage2D( GL11.GL_TEXTURE_2D, - 0, - gl_lms.internal_format, - BLOCK_WIDTH, BLOCK_HEIGHT, - 0, - GL_LIGHTMAP_FORMAT, - GL11.GL_UNSIGNED_BYTE, - dummy ); - } - - /** - * GL_EndBuildingLightmaps - */ - void GL_EndBuildingLightmaps() - { - LM_UploadBlock( false ); - GL_EnableMultitexture( false ); - } - - /* - * new buffers for vertex array handling - */ - static FloatBuffer globalPolygonInterleavedBuf = Polygon.getInterleavedBuffer(); - static FloatBuffer globalPolygonTexCoord1Buf = null; - - static { - globalPolygonInterleavedBuf.position(Polygon.STRIDE - 2); - globalPolygonTexCoord1Buf = globalPolygonInterleavedBuf.slice(); - globalPolygonInterleavedBuf.position(0); - }; - - //ImageFrame frame; - -// void debugLightmap(byte[] buf, int w, int h, float scale) { -// IntBuffer pix = ByteBuffer.wrap(buf).order(ByteOrder.LITTLE_ENDIAN).asIntBuffer(); -// -// int[] pixel = new int[w * h]; -// -// pix.get(pixel); -// -// BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR); -// image.setRGB(0, 0, w, h, pixel, 0, w); -// AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(scale, scale), AffineTransformOp.TYPE_NEAREST_NEIGHBOR); -// BufferedImage tmp = op.filter(image, null); -// -// if (frame == null) { -// frame = new ImageFrame(null); -// frame.show(); -// } -// frame.showImage(tmp); -// -// } + } + + private final IntBuffer temp2 = Lib.newIntBuffer(34 * 34, ByteOrder.LITTLE_ENDIAN); + + /** + * R_RenderBrushPoly + */ + void R_RenderBrushPoly(msurface_t fa) + { + c_brush_polys++; + + image_t image = R_TextureAnimation(fa.texinfo); + + if ((fa.flags & Defines.SURF_DRAWTURB) != 0) + { + GL_Bind( image.texnum ); + + // warp texture, no lightmaps + GL_TexEnv( GL11.GL_MODULATE ); + GL11.glColor4f( gl_state.inverse_intensity, + gl_state.inverse_intensity, + gl_state.inverse_intensity, + 1.0F ); + EmitWaterPolys (fa); + GL_TexEnv( GL11.GL_REPLACE ); + + return; + } + else + { + GL_Bind( image.texnum ); + GL_TexEnv( GL11.GL_REPLACE ); + } + + // ====== + // PGM + if((fa.texinfo.flags & Defines.SURF_FLOWING) != 0) + DrawGLFlowingPoly(fa.polys); + else + DrawGLPoly (fa.polys); + // PGM + // ====== + + // ersetzt goto + boolean gotoDynamic = false; + /* + ** check for lightmap modification + */ + int maps; + for ( maps = 0; maps < Defines.MAXLIGHTMAPS && fa.styles[maps] != (byte)255; maps++ ) + { + if ( r_newrefdef.lightstyles[fa.styles[maps] & 0xFF].white != fa.cached_light[maps] ) { + gotoDynamic = true; + break; + } + } + + // this is a hack from cwei + if (maps == 4) maps--; + + // dynamic this frame or dynamic previously + boolean is_dynamic = false; + if ( gotoDynamic || ( fa.dlightframe == r_framecount ) ) + { + // label dynamic: + if ( gl_dynamic.value != 0 ) + { + if (( fa.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP ) ) == 0) + { + is_dynamic = true; + } + } + } + + if ( is_dynamic ) + { + if ( ( (fa.styles[maps] & 0xFF) >= 32 || fa.styles[maps] == 0 ) && ( fa.dlightframe != r_framecount ) ) + { + // ist ersetzt durch temp2: unsigned temp[34*34]; + int smax, tmax; + + smax = (fa.extents[0]>>4)+1; + tmax = (fa.extents[1]>>4)+1; + + R_BuildLightMap( fa, temp2, smax); + R_SetCacheState( fa ); + + GL_Bind( gl_state.lightmap_textures + fa.lightmaptexturenum ); + + GL11.glTexSubImage2D( GL11.GL_TEXTURE_2D, 0, + fa.light_s, fa.light_t, + smax, tmax, + GL_LIGHTMAP_FORMAT, + GL11.GL_UNSIGNED_BYTE, temp2 ); + + fa.lightmapchain = gl_lms.lightmap_surfaces[fa.lightmaptexturenum]; + gl_lms.lightmap_surfaces[fa.lightmaptexturenum] = fa; + } + else + { + fa.lightmapchain = gl_lms.lightmap_surfaces[0]; + gl_lms.lightmap_surfaces[0] = fa; + } + } + else + { + fa.lightmapchain = gl_lms.lightmap_surfaces[fa.lightmaptexturenum]; + gl_lms.lightmap_surfaces[fa.lightmaptexturenum] = fa; + } + } + + + /** + * R_DrawAlphaSurfaces + * Draw water surfaces and windows. + * The BSP tree is waled front to back, so unwinding the chain + * of alpha_surfaces will draw back to front, giving proper ordering. + */ + void R_DrawAlphaSurfaces() + { + r_world_matrix.clear(); + // + // go back to the world matrix + // + GL11.glLoadMatrix(r_world_matrix); + + GL11.glEnable (GL11.GL_BLEND); + GL_TexEnv(GL11.GL_MODULATE ); + + + // the textures are prescaled up for a better lighting range, + // so scale it back down + float intens = gl_state.inverse_intensity; + + GL11.glInterleavedArrays(GL11.GL_T2F_V3F, Polygon.BYTE_STRIDE, globalPolygonInterleavedBuf); + + for (msurface_t s = r_alpha_surfaces ; s != null ; s=s.texturechain) + { + GL_Bind(s.texinfo.image.texnum); + c_brush_polys++; + if ((s.texinfo.flags & Defines.SURF_TRANS33) != 0) + GL11.glColor4f (intens, intens, intens, 0.33f); + else if ((s.texinfo.flags & Defines.SURF_TRANS66) != 0) + GL11.glColor4f (intens, intens, intens, 0.66f); + else + GL11.glColor4f (intens,intens,intens,1); + if ((s.flags & Defines.SURF_DRAWTURB) != 0) + EmitWaterPolys(s); + else if((s.texinfo.flags & Defines.SURF_FLOWING) != 0) // PGM 9/16/98 + DrawGLFlowingPoly(s.polys); // PGM + else + DrawGLPoly(s.polys); + } + + GL_TexEnv( GL11.GL_REPLACE ); + GL11.glColor4f (1,1,1,1); + GL11.glDisable (GL11.GL_BLEND); + + r_alpha_surfaces = null; + } + + /** + * DrawTextureChains + */ + void DrawTextureChains() + { + c_visible_textures = 0; + + msurface_t s; + image_t image; + int i; + for (i = 0; i < numgltextures ; i++) + { + image = gltextures[i]; + + if (image.registration_sequence == 0) + continue; + if (image.texturechain == null) + continue; + c_visible_textures++; + + for ( s = image.texturechain; s != null ; s=s.texturechain) + { + if ( ( s.flags & Defines.SURF_DRAWTURB) == 0 ) + R_RenderBrushPoly(s); + } + } + + GL_EnableMultitexture( false ); + for (i = 0; i < numgltextures ; i++) + { + image = gltextures[i]; + + if (image.registration_sequence == 0) + continue; + s = image.texturechain; + if (s == null) + continue; + + for ( ; s != null ; s=s.texturechain) + { + if ( (s.flags & Defines.SURF_DRAWTURB) != 0 ) + R_RenderBrushPoly(s); + } + + image.texturechain = null; + } + + GL_TexEnv( GL11.GL_REPLACE ); + } + + // direct buffer + private final IntBuffer temp = Lib.newIntBuffer(128 * 128, ByteOrder.LITTLE_ENDIAN); + + /** + * GL_RenderLightmappedPoly + * @param surf + */ + void GL_RenderLightmappedPoly( msurface_t surf ) + { + + // ersetzt goto + boolean gotoDynamic = false; + int map; + for ( map = 0; map < Defines.MAXLIGHTMAPS && (surf.styles[map] != (byte)255); map++ ) + { + if ( r_newrefdef.lightstyles[surf.styles[map] & 0xFF].white != surf.cached_light[map] ) { + gotoDynamic = true; + break; + } + } + + // this is a hack from cwei + if (map == 4) map--; + + // dynamic this frame or dynamic previously + boolean is_dynamic = false; + if ( gotoDynamic || ( surf.dlightframe == r_framecount ) ) + { + // label dynamic: + if ( gl_dynamic.value != 0 ) + { + if ( (surf.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP )) == 0 ) + { + is_dynamic = true; + } + } + } + + glpoly_t p; + image_t image = R_TextureAnimation( surf.texinfo ); + int lmtex = surf.lightmaptexturenum; + + if ( is_dynamic ) + { + // ist raus gezogen worden int[] temp = new int[128*128]; + int smax, tmax; + + if ( ( (surf.styles[map] & 0xFF) >= 32 || surf.styles[map] == 0 ) && ( surf.dlightframe != r_framecount ) ) + { + smax = (surf.extents[0]>>4)+1; + tmax = (surf.extents[1]>>4)+1; + + R_BuildLightMap( surf, temp, smax); + R_SetCacheState( surf ); + + GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + surf.lightmaptexturenum ); + + lmtex = surf.lightmaptexturenum; + + GL11.glTexSubImage2D( GL11.GL_TEXTURE_2D, 0, + surf.light_s, surf.light_t, + smax, tmax, + GL_LIGHTMAP_FORMAT, + GL11.GL_UNSIGNED_BYTE, temp ); + + } + else + { + smax = (surf.extents[0]>>4)+1; + tmax = (surf.extents[1]>>4)+1; + + R_BuildLightMap( surf, temp, smax); + + GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + 0 ); + + lmtex = 0; + + GL11.glTexSubImage2D( GL11.GL_TEXTURE_2D, 0, + surf.light_s, surf.light_t, + smax, tmax, + GL_LIGHTMAP_FORMAT, + GL11.GL_UNSIGNED_BYTE, temp ); + + } + + c_brush_polys++; + + GL_MBind( GL_TEXTURE0, image.texnum ); + GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + lmtex ); + + // ========== + // PGM + if ((surf.texinfo.flags & Defines.SURF_FLOWING) != 0) + { + float scroll; + + scroll = -64 * ( (r_newrefdef.time / 40.0f) - (int)(r_newrefdef.time / 40.0f) ); + if(scroll == 0.0f) + scroll = -64.0f; + + for ( p = surf.polys; p != null; p = p.chain ) + { + p.beginScrolling(scroll); + GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); + p.endScrolling(); + } + } + else + { + for ( p = surf.polys; p != null; p = p.chain ) + { + GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); + } + } + // PGM + // ========== + } + else + { + c_brush_polys++; + + GL_MBind( GL_TEXTURE0, image.texnum ); + GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + lmtex); + + // ========== + // PGM + if ((surf.texinfo.flags & Defines.SURF_FLOWING) != 0) + { + float scroll; + + scroll = -64 * ( (r_newrefdef.time / 40.0f) - (int)(r_newrefdef.time / 40.0f) ); + if(scroll == 0.0) + scroll = -64.0f; + + for ( p = surf.polys; p != null; p = p.chain ) + { + p.beginScrolling(scroll); + GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); + p.endScrolling(); + } + } + else + { + // PGM + // ========== + for ( p = surf.polys; p != null; p = p.chain ) + { + GL11.glDrawArrays(GL11.GL_POLYGON, p.pos, p.numverts); + } + + // ========== + // PGM + } + // PGM + // ========== + } + } + + /** + * R_DrawInlineBModel + */ + void R_DrawInlineBModel() + { + // calculate dynamic lighting for bmodel + if ( gl_flashblend.value == 0 ) + { + dlight_t lt; + for (int k=0 ; ksurfaces[currentmodel->firstmodelsurface]; + int psurfp = currentmodel.firstmodelsurface; + msurface_t[] surfaces = currentmodel.surfaces; + //psurf = surfaces[psurfp]; + + if ( (currententity.flags & Defines.RF_TRANSLUCENT) != 0 ) + { + GL11.glEnable (GL11.GL_BLEND); + GL11.glColor4f (1,1,1,0.25f); + GL_TexEnv( GL11.GL_MODULATE ); + } + + // + // draw texture + // + msurface_t psurf; + cplane_t pplane; + float dot; + for (int i=0 ; i BACKFACE_EPSILON))) + { + if ((psurf.texinfo.flags & (Defines.SURF_TRANS33 | Defines.SURF_TRANS66)) != 0 ) + { // add to the translucent chain + psurf.texturechain = r_alpha_surfaces; + r_alpha_surfaces = psurf; + } + else if ( (psurf.flags & Defines.SURF_DRAWTURB) == 0 ) + { + GL_RenderLightmappedPoly( psurf ); + } + else + { + GL_EnableMultitexture( false ); + R_RenderBrushPoly( psurf ); + GL_EnableMultitexture( true ); + } + } + } + + if ( (currententity.flags & Defines.RF_TRANSLUCENT) != 0 ) { + GL11.glDisable (GL11.GL_BLEND); + GL11.glColor4f (1,1,1,1); + GL_TexEnv( GL11.GL_REPLACE ); + } + } + + // stack variable + private final float[] mins = {0, 0, 0}; + private final float[] maxs = {0, 0, 0}; + private final float[] org = {0, 0, 0}; + private final float[] forward = {0, 0, 0}; + private final float[] right = {0, 0, 0}; + private final float[] up = {0, 0, 0}; + /** + * R_DrawBrushModel + */ + void R_DrawBrushModel(entity_t e) + { + if (currentmodel.nummodelsurfaces == 0) + return; + + currententity = e; + gl_state.currenttextures[0] = gl_state.currenttextures[1] = -1; + + boolean rotated; + if (e.angles[0] != 0 || e.angles[1] != 0 || e.angles[2] != 0) + { + rotated = true; + for (int i=0 ; i<3 ; i++) + { + mins[i] = e.origin[i] - currentmodel.radius; + maxs[i] = e.origin[i] + currentmodel.radius; + } + } + else + { + rotated = false; + Math3D.VectorAdd(e.origin, currentmodel.mins, mins); + Math3D.VectorAdd(e.origin, currentmodel.maxs, maxs); + } + + if (R_CullBox(mins, maxs)) return; + + GL11.glColor3f (1,1,1); + + // memset (gl_lms.lightmap_surfaces, 0, sizeof(gl_lms.lightmap_surfaces)); + + // TODO wird beim multitexturing nicht gebraucht + //gl_lms.clearLightmapSurfaces(); + + Math3D.VectorSubtract (r_newrefdef.vieworg, e.origin, modelorg); + if (rotated) + { + Math3D.VectorCopy (modelorg, org); + Math3D.AngleVectors (e.angles, forward, right, up); + modelorg[0] = Math3D.DotProduct (org, forward); + modelorg[1] = -Math3D.DotProduct (org, right); + modelorg[2] = Math3D.DotProduct (org, up); + } + + GL11.glPushMatrix(); + + e.angles[0] = -e.angles[0]; // stupid quake bug + e.angles[2] = -e.angles[2]; // stupid quake bug + R_RotateForEntity(e); + e.angles[0] = -e.angles[0]; // stupid quake bug + e.angles[2] = -e.angles[2]; // stupid quake bug + + GL_EnableMultitexture( true ); + GL_SelectTexture(GL_TEXTURE0); + GL_TexEnv( GL11.GL_REPLACE ); + GL11.glInterleavedArrays(GL11.GL_T2F_V3F, Polygon.BYTE_STRIDE, globalPolygonInterleavedBuf); + GL_SelectTexture(GL_TEXTURE1); + GL_TexEnv( GL11.GL_MODULATE ); + GL11.glTexCoordPointer(2, Polygon.BYTE_STRIDE, globalPolygonTexCoord1Buf); + GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); + + R_DrawInlineBModel(); + + ARBMultitexture.glClientActiveTextureARB(GL_TEXTURE1); + GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); + + GL_EnableMultitexture( false ); + + GL11.glPopMatrix(); + } + + /* + ============================================================= + + WORLD MODEL + + ============================================================= + */ + + /** + * R_RecursiveWorldNode + */ + void R_RecursiveWorldNode (mnode_t node) + { + if (node.contents == Defines.CONTENTS_SOLID) + return; // solid + + if (node.visframe != r_visframecount) + return; + + if (R_CullBox(node.mins, node.maxs)) + return; + + int c; + msurface_t mark; + // if a leaf node, draw stuff + if (node.contents != -1) + { + mleaf_t pleaf = (mleaf_t)node; + + // check for door connected areas + if (r_newrefdef.areabits != null) + { + if ( ((r_newrefdef.areabits[pleaf.area >> 3] & 0xFF) & (1 << (pleaf.area & 7)) ) == 0 ) + return; // not visible + } + + int markp = 0; + + mark = pleaf.getMarkSurface(markp); // first marked surface + c = pleaf.nummarksurfaces; + + if (c != 0) + { + do + { + mark.visframe = r_framecount; + mark = pleaf.getMarkSurface(++markp); // next surface + } while (--c != 0); + } + + return; + } + + // node is just a decision point, so go down the apropriate sides + + // find which side of the node we are on + cplane_t plane = node.plane; + float dot; + switch (plane.type) + { + case Defines.PLANE_X: + dot = modelorg[0] - plane.dist; + break; + case Defines.PLANE_Y: + dot = modelorg[1] - plane.dist; + break; + case Defines.PLANE_Z: + dot = modelorg[2] - plane.dist; + break; + default: + dot = Math3D.DotProduct(modelorg, plane.normal) - plane.dist; + break; + } + + int side, sidebit; + if (dot >= 0.0f) + { + side = 0; + sidebit = 0; + } + else + { + side = 1; + sidebit = Defines.SURF_PLANEBACK; + } + + // recurse down the children, front side first + R_RecursiveWorldNode(node.children[side]); + + // draw stuff + msurface_t surf; + image_t image; + //for ( c = node.numsurfaces, surf = r_worldmodel.surfaces[node.firstsurface]; c != 0 ; c--, surf++) + for ( c = 0; c < node.numsurfaces; c++) + { + surf = r_worldmodel.surfaces[node.firstsurface + c]; + if (surf.visframe != r_framecount) + continue; + + if ( (surf.flags & Defines.SURF_PLANEBACK) != sidebit ) + continue; // wrong side + + if ((surf.texinfo.flags & Defines.SURF_SKY) != 0) + { // just adds to visible sky bounds + R_AddSkySurface(surf); + } + else if ((surf.texinfo.flags & (Defines.SURF_TRANS33 | Defines.SURF_TRANS66)) != 0) + { // add to the translucent chain + surf.texturechain = r_alpha_surfaces; + r_alpha_surfaces = surf; + } + else + { + if ( ( surf.flags & Defines.SURF_DRAWTURB) == 0 ) + { + GL_RenderLightmappedPoly( surf ); + } + else + { + // the polygon is visible, so add it to the texture + // sorted chain + // FIXME: this is a hack for animation + image = R_TextureAnimation(surf.texinfo); + surf.texturechain = image.texturechain; + image.texturechain = surf; + } + } + } + // recurse down the back side + R_RecursiveWorldNode(node.children[1 - side]); + } + + private final entity_t worldEntity = new entity_t(); + + /** + * R_DrawWorld + */ + void R_DrawWorld() + { + if (r_drawworld.value == 0) + return; + + if ( (r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0 ) + return; + + currentmodel = r_worldmodel; + + Math3D.VectorCopy(r_newrefdef.vieworg, modelorg); + + entity_t ent = worldEntity; + // auto cycle the world frame for texture animation + ent.clear(); + ent.frame = (int)(r_newrefdef.time*2); + currententity = ent; + + gl_state.currenttextures[0] = gl_state.currenttextures[1] = -1; + + GL11.glColor3f (1,1,1); + // memset (gl_lms.lightmap_surfaces, 0, sizeof(gl_lms.lightmap_surfaces)); + // TODO wird bei multitexture nicht gebraucht + //gl_lms.clearLightmapSurfaces(); + + R_ClearSkyBox(); + + GL_EnableMultitexture( true ); + + GL_SelectTexture( GL_TEXTURE0); + GL_TexEnv( GL11.GL_REPLACE ); + GL11.glInterleavedArrays(GL11.GL_T2F_V3F, Polygon.BYTE_STRIDE, globalPolygonInterleavedBuf); + GL_SelectTexture( GL_TEXTURE1); + GL11.glTexCoordPointer(2, Polygon.BYTE_STRIDE, globalPolygonTexCoord1Buf); + GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); + + if ( gl_lightmap.value != 0) + GL_TexEnv( GL11.GL_REPLACE ); + else + GL_TexEnv( GL11.GL_MODULATE ); + + R_RecursiveWorldNode(r_worldmodel.nodes[0]); // root node + + ARBMultitexture.glClientActiveTextureARB(GL_TEXTURE1); + GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); + + GL_EnableMultitexture( false ); + + DrawTextureChains(); + R_DrawSkyBox(); + R_DrawTriangleOutlines(); + } + + final byte[] fatvis = new byte[Defines.MAX_MAP_LEAFS / 8]; + + /** + * R_MarkLeaves + * Mark the leaves and nodes that are in the PVS for the current + * cluster + */ + void R_MarkLeaves() + { + if (r_oldviewcluster == r_viewcluster && r_oldviewcluster2 == r_viewcluster2 && r_novis.value == 0 && r_viewcluster != -1) + return; + + // development aid to let you run around and see exactly where + // the pvs ends + if (gl_lockpvs.value != 0) + return; + + r_visframecount++; + r_oldviewcluster = r_viewcluster; + r_oldviewcluster2 = r_viewcluster2; + + int i; + if (r_novis.value != 0 || r_viewcluster == -1 || r_worldmodel.vis == null) + { + // mark everything + for (i=0 ; i> 3); + vis = Mod_ClusterPVS(r_viewcluster2, r_worldmodel); + c = (r_worldmodel.numleafs + 31) >> 5; + c <<= 2; + for (int k=0 ; k>3] & 0xFF) & (1 << (cluster & 7))) != 0) + { + node = (mnode_t)leaf; + do + { + if (node.visframe == r_visframecount) + break; + node.visframe = r_visframecount; + node = node.parent; + } while (node != null); + } + } + } + + /* + ============================================================================= + + LIGHTMAP ALLOCATION + + ============================================================================= + */ + + /** + * LM_InitBlock + */ + void LM_InitBlock() + { + Arrays.fill(gl_lms.allocated, 0); + } + + /** + * LM_UploadBlock + * @param dynamic + */ + void LM_UploadBlock( boolean dynamic ) + { + int texture = ( dynamic ) ? 0 : gl_lms.current_lightmap_texture; + + GL_Bind( gl_state.lightmap_textures + texture ); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); + + gl_lms.lightmap_buffer.rewind(); + if ( dynamic ) + { + int height = 0; + for (int i = 0; i < BLOCK_WIDTH; i++ ) + { + if ( gl_lms.allocated[i] > height ) + height = gl_lms.allocated[i]; + } + + GL11.glTexSubImage2D( GL11.GL_TEXTURE_2D, + 0, + 0, 0, + BLOCK_WIDTH, height, + GL_LIGHTMAP_FORMAT, + GL11.GL_UNSIGNED_BYTE, + gl_lms.lightmap_buffer ); + } + else + { + GL11.glTexImage2D( GL11.GL_TEXTURE_2D, + 0, + gl_lms.internal_format, + BLOCK_WIDTH, BLOCK_HEIGHT, + 0, + GL_LIGHTMAP_FORMAT, + GL11.GL_UNSIGNED_BYTE, + gl_lms.lightmap_buffer ); + if ( ++gl_lms.current_lightmap_texture == MAX_LIGHTMAPS ) + Com.Error( Defines.ERR_DROP, "LM_UploadBlock() - MAX_LIGHTMAPS exceeded\n" ); + + //debugLightmap(gl_lms.lightmap_buffer, 128, 128, 4); + } + } + + /** + * LM_AllocBlock + * @param w + * @param h + * @param pos + * @return a texture number and the position inside it + */ + boolean LM_AllocBlock (int w, int h, pos_t pos) + { + int best = BLOCK_HEIGHT; + + int best2; + int i, j; + for (i=0 ; i= best) + break; + if (gl_lms.allocated[i+j] > best2) + best2 = gl_lms.allocated[i+j]; + } + if (j == w) + { // this is a valid spot + pos.x = i; + pos.y = best = best2; + } + } + + if (best + h > BLOCK_HEIGHT) + return false; + + for (i=0 ; i 0) + { + r_pedge = pedges[lindex]; + vec = currentmodel.vertexes[r_pedge.v[0]].position; + } + else + { + r_pedge = pedges[-lindex]; + vec = currentmodel.vertexes[r_pedge.v[1]].position; + } + s = Math3D.DotProduct (vec, fa.texinfo.vecs[0]) + fa.texinfo.vecs[0][3]; + s /= fa.texinfo.image.width; + + t = Math3D.DotProduct (vec, fa.texinfo.vecs[1]) + fa.texinfo.vecs[1][3]; + t /= fa.texinfo.image.height; + + poly.x(i, vec[0]); + poly.y(i, vec[1]); + poly.z(i, vec[2]); + + poly.s1(i, s); + poly.t1(i, t); + + // + // lightmap texture coordinates + // + s = Math3D.DotProduct (vec, fa.texinfo.vecs[0]) + fa.texinfo.vecs[0][3]; + s -= fa.texturemins[0]; + s += fa.light_s*16; + s += 8; + s /= BLOCK_WIDTH*16; //fa.texinfo.texture.width; + + t = Math3D.DotProduct (vec, fa.texinfo.vecs[1]) + fa.texinfo.vecs[1][3]; + t -= fa.texturemins[1]; + t += fa.light_t*16; + t += 8; + t /= BLOCK_HEIGHT*16; //fa.texinfo.texture.height; + + poly.s2(i, s); + poly.t2(i, t); + } + } + + /** + * GL_CreateSurfaceLightmap + */ + void GL_CreateSurfaceLightmap(msurface_t surf) + { + if ( (surf.flags & (Defines.SURF_DRAWSKY | Defines.SURF_DRAWTURB)) != 0) + return; + + int smax = (surf.extents[0]>>4)+1; + int tmax = (surf.extents[1]>>4)+1; + + pos_t lightPos = new pos_t(surf.light_s, surf.light_t); + + if ( !LM_AllocBlock( smax, tmax, lightPos ) ) + { + LM_UploadBlock( false ); + LM_InitBlock(); + lightPos = new pos_t(surf.light_s, surf.light_t); + if ( !LM_AllocBlock( smax, tmax, lightPos ) ) + { + Com.Error( Defines.ERR_FATAL, "Consecutive calls to LM_AllocBlock(" + smax +"," + tmax +") failed\n"); + } + } + + // kopiere die koordinaten zurueck + surf.light_s = lightPos.x; + surf.light_t = lightPos.y; + + surf.lightmaptexturenum = gl_lms.current_lightmap_texture; + + IntBuffer base = gl_lms.lightmap_buffer; + base.position(surf.light_t * BLOCK_WIDTH + surf.light_s); + + R_SetCacheState( surf ); + R_BuildLightMap(surf, base.slice(), BLOCK_WIDTH); + } + + lightstyle_t[] lightstyles; + private final IntBuffer dummy = BufferUtils.createIntBuffer(128*128); + + /** + * GL_BeginBuildingLightmaps + */ + void GL_BeginBuildingLightmaps(model_t m) + { + // static lightstyle_t lightstyles[MAX_LIGHTSTYLES]; + int i; + + // init lightstyles + if ( lightstyles == null ) { + lightstyles = new lightstyle_t[Defines.MAX_LIGHTSTYLES]; + for (i = 0; i < lightstyles.length; i++) + { + lightstyles[i] = new lightstyle_t(); + } + } + + // memset( gl_lms.allocated, 0, sizeof(gl_lms.allocated) ); + Arrays.fill(gl_lms.allocated, 0); + + r_framecount = 1; // no dlightcache + + GL_EnableMultitexture( true ); + GL_SelectTexture( GL_TEXTURE1); + + /* + ** setup the base lightstyles so the lightmaps won't have to be regenerated + ** the first time they're seen + */ + for (i=0 ; i < Defines.MAX_LIGHTSTYLES ; i++) + { + lightstyles[i].rgb[0] = 1; + lightstyles[i].rgb[1] = 1; + lightstyles[i].rgb[2] = 1; + lightstyles[i].white = 3; + } + r_newrefdef.lightstyles = lightstyles; + + if (gl_state.lightmap_textures == 0) + { + gl_state.lightmap_textures = TEXNUM_LIGHTMAPS; + } + + gl_lms.current_lightmap_texture = 1; + + /* + ** if mono lightmaps are enabled and we want to use alpha + ** blending (a,1-a) then we're likely running on a 3DLabs + ** Permedia2. In a perfect world we'd use a GL_ALPHA lightmap + ** in order to conserve space and maximize bandwidth, however + ** this isn't a perfect world. + ** + ** So we have to use alpha lightmaps, but stored in GL_RGBA format, + ** which means we only get 1/16th the color resolution we should when + ** using alpha lightmaps. If we find another board that supports + ** only alpha lightmaps but that can at least support the GL_ALPHA + ** format then we should change this code to use real alpha maps. + */ + + char format = gl_monolightmap.string.toUpperCase().charAt(0); + + if ( format == 'A' ) + { + gl_lms.internal_format = gl_tex_alpha_format; + } + /* + ** try to do hacked colored lighting with a blended texture + */ + else if ( format == 'C' ) + { + gl_lms.internal_format = gl_tex_alpha_format; + } + else if ( format == 'I' ) + { + gl_lms.internal_format = GL11.GL_INTENSITY8; + } + else if ( format == 'L' ) + { + gl_lms.internal_format = GL11.GL_LUMINANCE8; + } + else + { + gl_lms.internal_format = gl_tex_solid_format; + } + + /* + ** initialize the dynamic lightmap texture + */ + GL_Bind( gl_state.lightmap_textures + 0 ); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); + GL11.glTexImage2D( GL11.GL_TEXTURE_2D, + 0, + gl_lms.internal_format, + BLOCK_WIDTH, BLOCK_HEIGHT, + 0, + GL_LIGHTMAP_FORMAT, + GL11.GL_UNSIGNED_BYTE, + dummy ); + } + + /** + * GL_EndBuildingLightmaps + */ + void GL_EndBuildingLightmaps() + { + LM_UploadBlock( false ); + GL_EnableMultitexture( false ); + } + + /* + * new buffers for vertex array handling + */ + static FloatBuffer globalPolygonInterleavedBuf = Polygon.getInterleavedBuffer(); + static FloatBuffer globalPolygonTexCoord1Buf = null; + + static { + globalPolygonInterleavedBuf.position(Polygon.STRIDE - 2); + globalPolygonTexCoord1Buf = globalPolygonInterleavedBuf.slice(); + globalPolygonInterleavedBuf.position(0); + }; + + //ImageFrame frame; + +// void debugLightmap(byte[] buf, int w, int h, float scale) { +// IntBuffer pix = ByteBuffer.wrap(buf).order(ByteOrder.LITTLE_ENDIAN).asIntBuffer(); +// +// int[] pixel = new int[w * h]; +// +// pix.get(pixel); +// +// BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR); +// image.setRGB(0, 0, w, h, pixel, 0, w); +// AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(scale, scale), AffineTransformOp.TYPE_NEAREST_NEIGHBOR); +// BufferedImage tmp = op.filter(image, null); +// +// if (frame == null) { +// frame = new ImageFrame(null); +// frame.show(); +// } +// frame.showImage(tmp); +// +// } } diff --git a/src/main/java/lwjake2/render/lwjgl/Warp.java b/src/main/java/lwjake2/render/lwjgl/Warp.java index 7208516..b60eb9f 100644 --- a/src/main/java/lwjake2/render/lwjgl/Warp.java +++ b/src/main/java/lwjake2/render/lwjgl/Warp.java @@ -35,173 +35,173 @@ import org.lwjgl.opengl.GL11; * @author cwei */ public abstract class Warp extends Model { - // warpsin.h - public static final float[] SIN = { - 0f, 0.19633f, 0.392541f, 0.588517f, 0.784137f, 0.979285f, 1.17384f, 1.3677f, - 1.56072f, 1.75281f, 1.94384f, 2.1337f, 2.32228f, 2.50945f, 2.69512f, 2.87916f, - 3.06147f, 3.24193f, 3.42044f, 3.59689f, 3.77117f, 3.94319f, 4.11282f, 4.27998f, - 4.44456f, 4.60647f, 4.76559f, 4.92185f, 5.07515f, 5.22538f, 5.37247f, 5.51632f, - 5.65685f, 5.79398f, 5.92761f, 6.05767f, 6.18408f, 6.30677f, 6.42566f, 6.54068f, - 6.65176f, 6.75883f, 6.86183f, 6.9607f, 7.05537f, 7.14579f, 7.23191f, 7.31368f, - 7.39104f, 7.46394f, 7.53235f, 7.59623f, 7.65552f, 7.71021f, 7.76025f, 7.80562f, - 7.84628f, 7.88222f, 7.91341f, 7.93984f, 7.96148f, 7.97832f, 7.99036f, 7.99759f, - 8f, 7.99759f, 7.99036f, 7.97832f, 7.96148f, 7.93984f, 7.91341f, 7.88222f, - 7.84628f, 7.80562f, 7.76025f, 7.71021f, 7.65552f, 7.59623f, 7.53235f, 7.46394f, - 7.39104f, 7.31368f, 7.23191f, 7.14579f, 7.05537f, 6.9607f, 6.86183f, 6.75883f, - 6.65176f, 6.54068f, 6.42566f, 6.30677f, 6.18408f, 6.05767f, 5.92761f, 5.79398f, - 5.65685f, 5.51632f, 5.37247f, 5.22538f, 5.07515f, 4.92185f, 4.76559f, 4.60647f, - 4.44456f, 4.27998f, 4.11282f, 3.94319f, 3.77117f, 3.59689f, 3.42044f, 3.24193f, - 3.06147f, 2.87916f, 2.69512f, 2.50945f, 2.32228f, 2.1337f, 1.94384f, 1.75281f, - 1.56072f, 1.3677f, 1.17384f, 0.979285f, 0.784137f, 0.588517f, 0.392541f, 0.19633f, - 9.79717e-16f, -0.19633f, -0.392541f, -0.588517f, -0.784137f, -0.979285f, -1.17384f, -1.3677f, - -1.56072f, -1.75281f, -1.94384f, -2.1337f, -2.32228f, -2.50945f, -2.69512f, -2.87916f, - -3.06147f, -3.24193f, -3.42044f, -3.59689f, -3.77117f, -3.94319f, -4.11282f, -4.27998f, - -4.44456f, -4.60647f, -4.76559f, -4.92185f, -5.07515f, -5.22538f, -5.37247f, -5.51632f, - -5.65685f, -5.79398f, -5.92761f, -6.05767f, -6.18408f, -6.30677f, -6.42566f, -6.54068f, - -6.65176f, -6.75883f, -6.86183f, -6.9607f, -7.05537f, -7.14579f, -7.23191f, -7.31368f, - -7.39104f, -7.46394f, -7.53235f, -7.59623f, -7.65552f, -7.71021f, -7.76025f, -7.80562f, - -7.84628f, -7.88222f, -7.91341f, -7.93984f, -7.96148f, -7.97832f, -7.99036f, -7.99759f, - -8f, -7.99759f, -7.99036f, -7.97832f, -7.96148f, -7.93984f, -7.91341f, -7.88222f, - -7.84628f, -7.80562f, -7.76025f, -7.71021f, -7.65552f, -7.59623f, -7.53235f, -7.46394f, - -7.39104f, -7.31368f, -7.23191f, -7.14579f, -7.05537f, -6.9607f, -6.86183f, -6.75883f, - -6.65176f, -6.54068f, -6.42566f, -6.30677f, -6.18408f, -6.05767f, -5.92761f, -5.79398f, - -5.65685f, -5.51632f, -5.37247f, -5.22538f, -5.07515f, -4.92185f, -4.76559f, -4.60647f, - -4.44456f, -4.27998f, -4.11282f, -3.94319f, -3.77117f, -3.59689f, -3.42044f, -3.24193f, - -3.06147f, -2.87916f, -2.69512f, -2.50945f, -2.32228f, -2.1337f, -1.94384f, -1.75281f, - -1.56072f, -1.3677f, -1.17384f, -0.979285f, -0.784137f, -0.588517f, -0.392541f, -0.19633f - }; - - String skyname; - float skyrotate; - float[] skyaxis = {0, 0, 0}; - image_t[] sky_images = new image_t[6]; + // warpsin.h + public static final float[] SIN = { + 0f, 0.19633f, 0.392541f, 0.588517f, 0.784137f, 0.979285f, 1.17384f, 1.3677f, + 1.56072f, 1.75281f, 1.94384f, 2.1337f, 2.32228f, 2.50945f, 2.69512f, 2.87916f, + 3.06147f, 3.24193f, 3.42044f, 3.59689f, 3.77117f, 3.94319f, 4.11282f, 4.27998f, + 4.44456f, 4.60647f, 4.76559f, 4.92185f, 5.07515f, 5.22538f, 5.37247f, 5.51632f, + 5.65685f, 5.79398f, 5.92761f, 6.05767f, 6.18408f, 6.30677f, 6.42566f, 6.54068f, + 6.65176f, 6.75883f, 6.86183f, 6.9607f, 7.05537f, 7.14579f, 7.23191f, 7.31368f, + 7.39104f, 7.46394f, 7.53235f, 7.59623f, 7.65552f, 7.71021f, 7.76025f, 7.80562f, + 7.84628f, 7.88222f, 7.91341f, 7.93984f, 7.96148f, 7.97832f, 7.99036f, 7.99759f, + 8f, 7.99759f, 7.99036f, 7.97832f, 7.96148f, 7.93984f, 7.91341f, 7.88222f, + 7.84628f, 7.80562f, 7.76025f, 7.71021f, 7.65552f, 7.59623f, 7.53235f, 7.46394f, + 7.39104f, 7.31368f, 7.23191f, 7.14579f, 7.05537f, 6.9607f, 6.86183f, 6.75883f, + 6.65176f, 6.54068f, 6.42566f, 6.30677f, 6.18408f, 6.05767f, 5.92761f, 5.79398f, + 5.65685f, 5.51632f, 5.37247f, 5.22538f, 5.07515f, 4.92185f, 4.76559f, 4.60647f, + 4.44456f, 4.27998f, 4.11282f, 3.94319f, 3.77117f, 3.59689f, 3.42044f, 3.24193f, + 3.06147f, 2.87916f, 2.69512f, 2.50945f, 2.32228f, 2.1337f, 1.94384f, 1.75281f, + 1.56072f, 1.3677f, 1.17384f, 0.979285f, 0.784137f, 0.588517f, 0.392541f, 0.19633f, + 9.79717e-16f, -0.19633f, -0.392541f, -0.588517f, -0.784137f, -0.979285f, -1.17384f, -1.3677f, + -1.56072f, -1.75281f, -1.94384f, -2.1337f, -2.32228f, -2.50945f, -2.69512f, -2.87916f, + -3.06147f, -3.24193f, -3.42044f, -3.59689f, -3.77117f, -3.94319f, -4.11282f, -4.27998f, + -4.44456f, -4.60647f, -4.76559f, -4.92185f, -5.07515f, -5.22538f, -5.37247f, -5.51632f, + -5.65685f, -5.79398f, -5.92761f, -6.05767f, -6.18408f, -6.30677f, -6.42566f, -6.54068f, + -6.65176f, -6.75883f, -6.86183f, -6.9607f, -7.05537f, -7.14579f, -7.23191f, -7.31368f, + -7.39104f, -7.46394f, -7.53235f, -7.59623f, -7.65552f, -7.71021f, -7.76025f, -7.80562f, + -7.84628f, -7.88222f, -7.91341f, -7.93984f, -7.96148f, -7.97832f, -7.99036f, -7.99759f, + -8f, -7.99759f, -7.99036f, -7.97832f, -7.96148f, -7.93984f, -7.91341f, -7.88222f, + -7.84628f, -7.80562f, -7.76025f, -7.71021f, -7.65552f, -7.59623f, -7.53235f, -7.46394f, + -7.39104f, -7.31368f, -7.23191f, -7.14579f, -7.05537f, -6.9607f, -6.86183f, -6.75883f, + -6.65176f, -6.54068f, -6.42566f, -6.30677f, -6.18408f, -6.05767f, -5.92761f, -5.79398f, + -5.65685f, -5.51632f, -5.37247f, -5.22538f, -5.07515f, -4.92185f, -4.76559f, -4.60647f, + -4.44456f, -4.27998f, -4.11282f, -3.94319f, -3.77117f, -3.59689f, -3.42044f, -3.24193f, + -3.06147f, -2.87916f, -2.69512f, -2.50945f, -2.32228f, -2.1337f, -1.94384f, -1.75281f, + -1.56072f, -1.3677f, -1.17384f, -0.979285f, -0.784137f, -0.588517f, -0.392541f, -0.19633f + }; + + String skyname; + float skyrotate; + float[] skyaxis = {0, 0, 0}; + image_t[] sky_images = new image_t[6]; - msurface_t warpface; + msurface_t warpface; - static final int SUBDIVIDE_SIZE = 64; + static final int SUBDIVIDE_SIZE = 64; - /** - * BoundPoly - * @param numverts - * @param verts - * @param mins - * @param maxs - */ - void BoundPoly(int numverts, float[][] verts, float[] mins, float[] maxs) { - mins[0] = mins[1] = mins[2] = 9999; - maxs[0] = maxs[1] = maxs[2] = -9999; + /** + * BoundPoly + * @param numverts + * @param verts + * @param mins + * @param maxs + */ + void BoundPoly(int numverts, float[][] verts, float[] mins, float[] maxs) { + mins[0] = mins[1] = mins[2] = 9999; + maxs[0] = maxs[1] = maxs[2] = -9999; - int j; - float[] v; - for (int i=0 ; i maxs[j]) - maxs[j] = v[j]; - } - } - } + int j; + float[] v; + for (int i=0 ; i maxs[j]) + maxs[j] = v[j]; + } + } + } - /** - * SubdividePolygon - * @param numverts - * @param verts - */ - void SubdividePolygon(int numverts, float[][] verts) - { - int i, j, k; - float m; - float[][] front = new float[64][3]; - float[][] back = new float[64][3]; + /** + * SubdividePolygon + * @param numverts + * @param verts + */ + void SubdividePolygon(int numverts, float[][] verts) + { + int i, j, k; + float m; + float[][] front = new float[64][3]; + float[][] back = new float[64][3]; - int f, b; - float[] dist = new float[64]; - float frac; + int f, b; + float[] dist = new float[64]; + float frac; - if (numverts > 60) - Com.Error(Defines.ERR_DROP, "numverts = " + numverts); + if (numverts > 60) + Com.Error(Defines.ERR_DROP, "numverts = " + numverts); - float[] mins = Vec3Cache.get(); - float[] maxs = Vec3Cache.get(); + float[] mins = Vec3Cache.get(); + float[] maxs = Vec3Cache.get(); - BoundPoly(numverts, verts, mins, maxs); - float[] v; - // x,y und z - for (i=0 ; i<3 ; i++) - { - m = (mins[i] + maxs[i]) * 0.5f; - m = SUBDIVIDE_SIZE * (float)Math.floor(m / SUBDIVIDE_SIZE + 0.5f); - if (maxs[i] - m < 8) - continue; - if (m - mins[i] < 8) - continue; + BoundPoly(numverts, verts, mins, maxs); + float[] v; + // x,y und z + for (i=0 ; i<3 ; i++) + { + m = (mins[i] + maxs[i]) * 0.5f; + m = SUBDIVIDE_SIZE * (float)Math.floor(m / SUBDIVIDE_SIZE + 0.5f); + if (maxs[i] - m < 8) + continue; + if (m - mins[i] < 8) + continue; - // cut it - for (j=0 ; j= 0) - { - Math3D.VectorCopy(v, front[f]); - f++; - } - if (dist[j] <= 0) - { - Math3D.VectorCopy(v, back[b]); - b++; - } - if (dist[j] == 0 || dist[j+1] == 0) continue; - - if ( (dist[j] > 0) != (dist[j+1] > 0) ) - { - // clip point - frac = dist[j] / (dist[j] - dist[j+1]); - for (k=0 ; k<3 ; k++) - front[f][k] = back[b][k] = v[k] + frac*(verts[j+1][k] - v[k]); - - f++; - b++; - } - } + Math3D.VectorCopy(verts[0], verts[numverts]); + + f = b = 0; + for (j=0 ; j= 0) + { + Math3D.VectorCopy(v, front[f]); + f++; + } + if (dist[j] <= 0) + { + Math3D.VectorCopy(v, back[b]); + b++; + } + if (dist[j] == 0 || dist[j+1] == 0) continue; + + if ( (dist[j] > 0) != (dist[j+1] > 0) ) + { + // clip point + frac = dist[j] / (dist[j] - dist[j+1]); + for (k=0 ; k<3 ; k++) + front[f][k] = back[b][k] = v[k] + frac*(verts[j+1][k] - v[k]); + + f++; + b++; + } + } - SubdividePolygon(f, front); - SubdividePolygon(b, back); - - Vec3Cache.release(2); // mins, maxs - return; - } - - Vec3Cache.release(2); // mins, maxs - - // add a point in the center to help keep warp valid - - // wird im Konstruktor erschlagen - // poly = Hunk_Alloc (sizeof(glpoly_t) + ((numverts-4)+2) * VERTEXSIZE*sizeof(float)); + SubdividePolygon(f, front); + SubdividePolygon(b, back); + + Vec3Cache.release(2); // mins, maxs + return; + } + + Vec3Cache.release(2); // mins, maxs + + // add a point in the center to help keep warp valid + + // wird im Konstruktor erschlagen + // poly = Hunk_Alloc (sizeof(glpoly_t) + ((numverts-4)+2) * VERTEXSIZE*sizeof(float)); - // init polys - glpoly_t poly = Polygon.create(numverts + 2); + // init polys + glpoly_t poly = Polygon.create(numverts + 2); - poly.next = warpface.polys; - warpface.polys = poly; - - float[] total = Vec3Cache.get(); - Math3D.VectorClear(total); - float total_s = 0; - float total_t = 0; - float s, t; - for (i = 0; i < numverts; i++) { + poly.next = warpface.polys; + warpface.polys = poly; + + float[] total = Vec3Cache.get(); + Math3D.VectorClear(total); + float total_s = 0; + float total_t = 0; + float s, t; + for (i = 0; i < numverts; i++) { poly.x(i + 1, verts[i][0]); poly.y(i + 1, verts[i][1]); poly.z(i + 1, verts[i][2]); @@ -232,15 +232,15 @@ public abstract class Warp extends Model { poly.t2(i + 1, poly.t2(1)); Vec3Cache.release(); // total - } + } - private final float[][] tmpVerts = new float[64][3]; - /** - * GL_SubdivideSurface - * Breaks a polygon up along axial 64 unit - * boundaries so that turbulent and sky warps - * can be done reasonably. - */ + private final float[][] tmpVerts = new float[64][3]; + /** + * GL_SubdivideSurface + * Breaks a polygon up along axial 64 unit + * boundaries so that turbulent and sky warps + * can be done reasonably. + */ void GL_SubdivideSurface(msurface_t fa) { float[][] verts = tmpVerts; float[] vec; @@ -263,25 +263,25 @@ public abstract class Warp extends Model { } // ========================================================= - static final float TURBSCALE = (float)(256.0f / (2 * Math.PI)); + static final float TURBSCALE = (float)(256.0f / (2 * Math.PI)); - /** - * EmitWaterPolys - * Does a water warp on the pre-fragmented glpoly_t chain - */ - void EmitWaterPolys(msurface_t fa) - { - float rdt = r_newrefdef.time; + /** + * EmitWaterPolys + * Does a water warp on the pre-fragmented glpoly_t chain + */ + void EmitWaterPolys(msurface_t fa) + { + float rdt = r_newrefdef.time; - float scroll; - if ((fa.texinfo.flags & Defines.SURF_FLOWING) != 0) - scroll = -64 * ( (r_newrefdef.time*0.5f) - (int)(r_newrefdef.time*0.5f) ); - else - scroll = 0; - - int i; - float s, t, os, ot; - glpoly_t p, bp; + float scroll; + if ((fa.texinfo.flags & Defines.SURF_FLOWING) != 0) + scroll = -64 * ( (r_newrefdef.time*0.5f) - (int)(r_newrefdef.time*0.5f) ); + else + scroll = 0; + + int i; + float s, t, os, ot; + glpoly_t p, bp; for (bp = fa.polys; bp != null; bp = bp.next) { p = bp; @@ -304,243 +304,243 @@ public abstract class Warp extends Model { } GL11.glEnd(); } - } + } -// =================================================================== +// =================================================================== - float[][] skyclip = { - { 1, 1, 0}, - { 1, -1, 0}, - { 0, -1, 1}, - { 0, 1, 1}, - { 1, 0, 1}, - {-1, 0, 1} - }; + float[][] skyclip = { + { 1, 1, 0}, + { 1, -1, 0}, + { 0, -1, 1}, + { 0, 1, 1}, + { 1, 0, 1}, + {-1, 0, 1} + }; - int c_sky; + int c_sky; - // 1 = s, 2 = t, 3 = 2048 - int[][] st_to_vec = - { - {3,-1,2}, - {-3,1,2}, + // 1 = s, 2 = t, 3 = 2048 + int[][] st_to_vec = + { + {3,-1,2}, + {-3,1,2}, - {1,3,2}, - {-1,-3,2}, + {1,3,2}, + {-1,-3,2}, - {-2,-1,3}, // 0 degrees yaw, look straight up - {2,-1,-3} // look straight down + {-2,-1,3}, // 0 degrees yaw, look straight up + {2,-1,-3} // look straight down - }; + }; - int[][] vec_to_st = - { - {-2,3,1}, - {2,3,-1}, + int[][] vec_to_st = + { + {-2,3,1}, + {2,3,-1}, - {1,3,2}, - {-1,3,-2}, + {1,3,2}, + {-1,3,-2}, - {-2,-1,3}, - {-2,1,-3} + {-2,-1,3}, + {-2,1,-3} - }; + }; - float[][] skymins = new float[2][6]; - float[][] skymaxs = new float[2][6]; - float sky_min, sky_max; + float[][] skymins = new float[2][6]; + float[][] skymaxs = new float[2][6]; + float sky_min, sky_max; - // stack variable - private final float[] v = {0, 0, 0}; - private final float[] av = {0, 0, 0}; - /** - * DrawSkyPolygon - * @param nump - * @param vecs - */ - void DrawSkyPolygon(int nump, float[][] vecs) - { - c_sky++; - // decide which face it maps to - Math3D.VectorCopy(Globals.vec3_origin, v); - int i, axis; - for (i=0; i av[1] && av[0] > av[2]) - { - if (v[0] < 0) - axis = 1; - else - axis = 0; - } - else if (av[1] > av[2] && av[1] > av[0]) - { - if (v[1] < 0) - axis = 3; - else - axis = 2; - } - else - { - if (v[2] < 0) - axis = 5; - else - axis = 4; - } + // stack variable + private final float[] v = {0, 0, 0}; + private final float[] av = {0, 0, 0}; + /** + * DrawSkyPolygon + * @param nump + * @param vecs + */ + void DrawSkyPolygon(int nump, float[][] vecs) + { + c_sky++; + // decide which face it maps to + Math3D.VectorCopy(Globals.vec3_origin, v); + int i, axis; + for (i=0; i av[1] && av[0] > av[2]) + { + if (v[0] < 0) + axis = 1; + else + axis = 0; + } + else if (av[1] > av[2] && av[1] > av[0]) + { + if (v[1] < 0) + axis = 3; + else + axis = 2; + } + else + { + if (v[2] < 0) + axis = 5; + else + axis = 4; + } - // project new texture coords - float s, t, dv; - int j; - for (i=0 ; i 0) - dv = vecs[i][j - 1]; - else - dv = -vecs[i][-j - 1]; - if (dv < 0.001f) - continue; // don't divide by zero - j = vec_to_st[axis][0]; - if (j < 0) - s = -vecs[i][-j -1] / dv; - else - s = vecs[i][j-1] / dv; - j = vec_to_st[axis][1]; - if (j < 0) - t = -vecs[i][-j -1] / dv; - else - t = vecs[i][j-1] / dv; + // project new texture coords + float s, t, dv; + int j; + for (i=0 ; i 0) + dv = vecs[i][j - 1]; + else + dv = -vecs[i][-j - 1]; + if (dv < 0.001f) + continue; // don't divide by zero + j = vec_to_st[axis][0]; + if (j < 0) + s = -vecs[i][-j -1] / dv; + else + s = vecs[i][j-1] / dv; + j = vec_to_st[axis][1]; + if (j < 0) + t = -vecs[i][-j -1] / dv; + else + t = vecs[i][j-1] / dv; - if (s < skymins[0][axis]) - skymins[0][axis] = s; - if (t < skymins[1][axis]) - skymins[1][axis] = t; - if (s > skymaxs[0][axis]) - skymaxs[0][axis] = s; - if (t > skymaxs[1][axis]) - skymaxs[1][axis] = t; - } - } + if (s < skymins[0][axis]) + skymins[0][axis] = s; + if (t < skymins[1][axis]) + skymins[1][axis] = t; + if (s > skymaxs[0][axis]) + skymaxs[0][axis] = s; + if (t > skymaxs[1][axis]) + skymaxs[1][axis] = t; + } + } - static final float ON_EPSILON = 0.1f; // point on plane side epsilon - static final int MAX_CLIP_VERTS = 64; - - static final int SIDE_BACK = 1; - static final int SIDE_FRONT = 0; - static final int SIDE_ON = 2; - - float[] dists = new float[MAX_CLIP_VERTS]; - int[] sides = new int[MAX_CLIP_VERTS]; - float[][][][] newv = new float[6][2][MAX_CLIP_VERTS][3]; + static final float ON_EPSILON = 0.1f; // point on plane side epsilon + static final int MAX_CLIP_VERTS = 64; + + static final int SIDE_BACK = 1; + static final int SIDE_FRONT = 0; + static final int SIDE_ON = 2; + + float[] dists = new float[MAX_CLIP_VERTS]; + int[] sides = new int[MAX_CLIP_VERTS]; + float[][][][] newv = new float[6][2][MAX_CLIP_VERTS][3]; - /** - * ClipSkyPolygon - * @param nump - * @param vecs - * @param stage - */ - void ClipSkyPolygon(int nump, float[][] vecs, int stage) - { - if (nump > MAX_CLIP_VERTS-2) - Com.Error(Defines.ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS"); - if (stage == 6) - { // fully clipped, so draw it - DrawSkyPolygon(nump, vecs); - return; - } + /** + * ClipSkyPolygon + * @param nump + * @param vecs + * @param stage + */ + void ClipSkyPolygon(int nump, float[][] vecs, int stage) + { + if (nump > MAX_CLIP_VERTS-2) + Com.Error(Defines.ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS"); + if (stage == 6) + { // fully clipped, so draw it + DrawSkyPolygon(nump, vecs); + return; + } - boolean front = false; - boolean back = false; - float[] norm = skyclip[stage]; + boolean front = false; + boolean back = false; + float[] norm = skyclip[stage]; - int i; - float d; - for (i=0 ; i ON_EPSILON) - { - front = true; - sides[i] = SIDE_FRONT; - } - else if (d < -ON_EPSILON) - { - back = true; - sides[i] = SIDE_BACK; - } - else - sides[i] = SIDE_ON; - dists[i] = d; - } + int i; + float d; + for (i=0 ; i ON_EPSILON) + { + front = true; + sides[i] = SIDE_FRONT; + } + else if (d < -ON_EPSILON) + { + back = true; + sides[i] = SIDE_BACK; + } + else + sides[i] = SIDE_ON; + dists[i] = d; + } - if (!front || !back) - { // not clipped - ClipSkyPolygon (nump, vecs, stage+1); - return; - } + if (!front || !back) + { // not clipped + ClipSkyPolygon (nump, vecs, stage+1); + return; + } - // clip it - sides[i] = sides[0]; - dists[i] = dists[0]; - Math3D.VectorCopy(vecs[0], vecs[i]); + // clip it + sides[i] = sides[0]; + dists[i] = dists[0]; + Math3D.VectorCopy(vecs[0], vecs[i]); - int newc0 = 0; int newc1 = 0; - float[] v; - float e; - int j; - for (i=0; i sky_max) - s = sky_max; - if (t < sky_min) - t = sky_min; - else if (t > sky_max) - t = sky_max; + if (s < sky_min) + s = sky_min; + else if (s > sky_max) + s = sky_max; + if (t < sky_min) + t = sky_min; + else if (t > sky_max) + t = sky_max; - t = 1.0f - t; - GL11.glTexCoord2f (s, t); - GL11.glVertex3f(v1[0], v1[1], v1[2]); - } + t = 1.0f - t; + GL11.glTexCoord2f (s, t); + GL11.glVertex3f(v1[0], v1[1], v1[2]); + } - int[] skytexorder = {0,2,1,3,4,5}; + int[] skytexorder = {0,2,1,3,4,5}; - /** - * R_DrawSkyBox - */ - void R_DrawSkyBox() - { - int i; + /** + * R_DrawSkyBox + */ + void R_DrawSkyBox() + { + int i; - if (skyrotate != 0) - { // check for no sky at all - for (i=0 ; i<6 ; i++) - if (skymins[0][i] < skymaxs[0][i] - && skymins[1][i] < skymaxs[1][i]) - break; - if (i == 6) - return; // nothing visible - } + if (skyrotate != 0) + { // check for no sky at all + for (i=0 ; i<6 ; i++) + if (skymins[0][i] < skymaxs[0][i] + && skymins[1][i] < skymaxs[1][i]) + break; + if (i == 6) + return; // nothing visible + } - GL11.glPushMatrix (); - GL11.glTranslatef (r_origin[0], r_origin[1], r_origin[2]); - GL11.glRotatef (r_newrefdef.time * skyrotate, skyaxis[0], skyaxis[1], skyaxis[2]); + GL11.glPushMatrix (); + GL11.glTranslatef (r_origin[0], r_origin[1], r_origin[2]); + GL11.glRotatef (r_newrefdef.time * skyrotate, skyaxis[0], skyaxis[1], skyaxis[2]); - for (i=0 ; i<6 ; i++) - { - if (skyrotate != 0) - { // hack, forces full sky to draw when rotating - skymins[0][i] = -1; - skymins[1][i] = -1; - skymaxs[0][i] = 1; - skymaxs[1][i] = 1; - } + for (i=0 ; i<6 ; i++) + { + if (skyrotate != 0) + { // hack, forces full sky to draw when rotating + skymins[0][i] = -1; + skymins[1][i] = -1; + skymaxs[0][i] = 1; + skymaxs[1][i] = 1; + } - if (skymins[0][i] >= skymaxs[0][i] - || skymins[1][i] >= skymaxs[1][i]) - continue; + if (skymins[0][i] >= skymaxs[0][i] + || skymins[1][i] >= skymaxs[1][i]) + continue; - GL_Bind(sky_images[skytexorder[i]].texnum); + GL_Bind(sky_images[skytexorder[i]].texnum); - GL11.glBegin(GL11.GL_QUADS); - MakeSkyVec(skymins[0][i], skymins[1][i], i); - MakeSkyVec(skymins[0][i], skymaxs[1][i], i); - MakeSkyVec(skymaxs[0][i], skymaxs[1][i], i); - MakeSkyVec(skymaxs[0][i], skymins[1][i], i); - GL11.glEnd (); - } - GL11.glPopMatrix (); - } + GL11.glBegin(GL11.GL_QUADS); + MakeSkyVec(skymins[0][i], skymins[1][i], i); + MakeSkyVec(skymins[0][i], skymaxs[1][i], i); + MakeSkyVec(skymaxs[0][i], skymaxs[1][i], i); + MakeSkyVec(skymaxs[0][i], skymins[1][i], i); + GL11.glEnd (); + } + GL11.glPopMatrix (); + } - // 3dstudio environment map names - String[] suf = {"rt", "bk", "lf", "ft", "up", "dn"}; - - /** - * R_SetSky - * @param name - * @param rotate - * @param axis - */ - protected void R_SetSky(String name, float rotate, float[] axis) - { - assert (axis.length == 3) : "vec3_t bug"; - String pathname; - skyname = name; + // 3dstudio environment map names + String[] suf = {"rt", "bk", "lf", "ft", "up", "dn"}; + + /** + * R_SetSky + * @param name + * @param rotate + * @param axis + */ + protected void R_SetSky(String name, float rotate, float[] axis) + { + assert (axis.length == 3) : "vec3_t bug"; + String pathname; + skyname = name; - skyrotate = rotate; - Math3D.VectorCopy(axis, skyaxis); + skyrotate = rotate; + Math3D.VectorCopy(axis, skyaxis); - for (int i=0 ; i<6 ; i++) - { - // chop down rotating skies for less memory - if (gl_skymip.value != 0 || skyrotate != 0) - gl_picmip.value++; + for (int i=0 ; i<6 ; i++) + { + // chop down rotating skies for less memory + if (gl_skymip.value != 0 || skyrotate != 0) + gl_picmip.value++; - if ( qglColorTableEXT && gl_ext_palettedtexture.value != 0) { - // Com_sprintf (pathname, sizeof(pathname), "env/%s%s.pcx", skyname, suf[i]); - pathname = "env/" + skyname + suf[i] + ".pcx"; - } else { - // Com_sprintf (pathname, sizeof(pathname), "env/%s%s.tga", skyname, suf[i]); - pathname = "env/" + skyname + suf[i] + ".tga"; - } + if ( qglColorTableEXT && gl_ext_palettedtexture.value != 0) { + // Com_sprintf (pathname, sizeof(pathname), "env/%s%s.pcx", skyname, suf[i]); + pathname = "env/" + skyname + suf[i] + ".pcx"; + } else { + // Com_sprintf (pathname, sizeof(pathname), "env/%s%s.tga", skyname, suf[i]); + pathname = "env/" + skyname + suf[i] + ".tga"; + } - sky_images[i] = GL_FindImage(pathname, it_sky); + sky_images[i] = GL_FindImage(pathname, it_sky); - if (sky_images[i] == null) - sky_images[i] = r_notexture; + if (sky_images[i] == null) + sky_images[i] = r_notexture; - if (gl_skymip.value != 0 || skyrotate != 0) - { // take less memory - gl_picmip.value--; - sky_min = 1.0f / 256; - sky_max = 255.0f / 256; - } - else - { - sky_min = 1.0f / 512; - sky_max = 511.0f / 512; - } - } - } + if (gl_skymip.value != 0 || skyrotate != 0) + { // take less memory + gl_picmip.value--; + sky_min = 1.0f / 256; + sky_max = 255.0f / 256; + } + else + { + sky_min = 1.0f / 512; + sky_max = 511.0f / 512; + } + } + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/render/mleaf_t.java b/src/main/java/lwjake2/render/mleaf_t.java index da4f8ad..a757869 100644 --- a/src/main/java/lwjake2/render/mleaf_t.java +++ b/src/main/java/lwjake2/render/mleaf_t.java @@ -20,36 +20,36 @@ package lwjake2.render; public class mleaf_t extends mnode_t { - // common with node - /* - public int contents; // wil be a negative contents number - public int visframe; // node needs to be traversed if current + // common with node + /* + public int contents; // wil be a negative contents number + public int visframe; // node needs to be traversed if current - public float minmaxs[] = new float[6]; // for bounding box culling + public float minmaxs[] = new float[6]; // for bounding box culling - public mnode_t parent; - */ + public mnode_t parent; + */ - // leaf specific - public int cluster; - public int area; + // leaf specific + public int cluster; + public int area; - //public msurface_t firstmarksurface; - public int nummarksurfaces; - - // added by cwei - int markIndex; - msurface_t[] markSurfaces; - - public void setMarkSurface(int markIndex, msurface_t[] markSurfaces) { - this.markIndex = markIndex; - this.markSurfaces = markSurfaces; - } + //public msurface_t firstmarksurface; + public int nummarksurfaces; + + // added by cwei + int markIndex; + msurface_t[] markSurfaces; + + public void setMarkSurface(int markIndex, msurface_t[] markSurfaces) { + this.markIndex = markIndex; + this.markSurfaces = markSurfaces; + } - public msurface_t getMarkSurface(int index) { - assert (index >= 0 && index <= nummarksurfaces) : "mleaf: markSurface bug (index = " + index +"; num = " + nummarksurfaces + ")"; - // TODO code in Surf.R_RecursiveWorldNode aendern (der Pointer wird wie in C zu weit gezaehlt) - return (index < nummarksurfaces) ? markSurfaces[markIndex + index] : null; - } + public msurface_t getMarkSurface(int index) { + assert (index >= 0 && index <= nummarksurfaces) : "mleaf: markSurface bug (index = " + index +"; num = " + nummarksurfaces + ")"; + // TODO code in Surf.R_RecursiveWorldNode aendern (der Pointer wird wie in C zu weit gezaehlt) + return (index < nummarksurfaces) ? markSurfaces[markIndex + index] : null; + } } diff --git a/src/main/java/lwjake2/render/mmodel_t.java b/src/main/java/lwjake2/render/mmodel_t.java index 8015a36..3fb89f7 100644 --- a/src/main/java/lwjake2/render/mmodel_t.java +++ b/src/main/java/lwjake2/render/mmodel_t.java @@ -20,10 +20,10 @@ package lwjake2.render; public class mmodel_t { - public float[] mins = { 0, 0, 0 }, maxs = { 0, 0, 0 }; - public float[] origin = { 0, 0, 0 }; // for sounds or lights - public float radius; - public int headnode; - public int visleafs; // not including the solid leaf 0 - public int firstface, numfaces; + public float[] mins = { 0, 0, 0 }, maxs = { 0, 0, 0 }; + public float[] origin = { 0, 0, 0 }; // for sounds or lights + public float radius; + public int headnode; + public int visleafs; // not including the solid leaf 0 + public int firstface, numfaces; } diff --git a/src/main/java/lwjake2/render/mnode_t.java b/src/main/java/lwjake2/render/mnode_t.java index 8e340d1..ccb7c50 100644 --- a/src/main/java/lwjake2/render/mnode_t.java +++ b/src/main/java/lwjake2/render/mnode_t.java @@ -21,22 +21,22 @@ package lwjake2.render; import lwjake2.game.cplane_t; public class mnode_t { - // common with leaf - public int contents; // -1, to differentiate from leafs - public int visframe; // node needs to be traversed if current + // common with leaf + public int contents; // -1, to differentiate from leafs + public int visframe; // node needs to be traversed if current - //public float minmaxs[] = new float[6]; // for bounding box culling - public float mins[] = new float[3]; // for bounding box culling - public float maxs[] = new float[3]; // for bounding box culling + //public float minmaxs[] = new float[6]; // for bounding box culling + public float mins[] = new float[3]; // for bounding box culling + public float maxs[] = new float[3]; // for bounding box culling - public mnode_t parent; + public mnode_t parent; - // node specific - public cplane_t plane; - public mnode_t children[] = new mnode_t[2]; + // node specific + public cplane_t plane; + public mnode_t children[] = new mnode_t[2]; - // unsigned short - public int firstsurface; - public int numsurfaces; + // unsigned short + public int firstsurface; + public int numsurfaces; } diff --git a/src/main/java/lwjake2/render/model_t.java b/src/main/java/lwjake2/render/model_t.java index a0a451f..88cb4af 100644 --- a/src/main/java/lwjake2/render/model_t.java +++ b/src/main/java/lwjake2/render/model_t.java @@ -27,167 +27,167 @@ import lwjake2.util.Math3D; import java.util.Arrays; public class model_t implements Cloneable { - - public String name = ""; + + public String name = ""; - public int registration_sequence; + public int registration_sequence; - // was enum modtype_t - public int type; - public int numframes; + // was enum modtype_t + public int type; + public int numframes; - public int flags; + public int flags; - // - // volume occupied by the model graphics - // - public float[] mins = { 0, 0, 0 }, maxs = { 0, 0, 0 }; - public float radius; + // + // volume occupied by the model graphics + // + public float[] mins = { 0, 0, 0 }, maxs = { 0, 0, 0 }; + public float radius; - // - // solid volume for clipping - // - public boolean clipbox; - public float clipmins[] = { 0, 0, 0 }, clipmaxs[] = { 0, 0, 0 }; + // + // solid volume for clipping + // + public boolean clipbox; + public float clipmins[] = { 0, 0, 0 }, clipmaxs[] = { 0, 0, 0 }; - // - // brush model - // - public int firstmodelsurface, nummodelsurfaces; - public int lightmap; // only for submodels + // + // brush model + // + public int firstmodelsurface, nummodelsurfaces; + public int lightmap; // only for submodels - public int numsubmodels; - public mmodel_t submodels[]; + public int numsubmodels; + public mmodel_t submodels[]; - public int numplanes; - public cplane_t planes[]; + public int numplanes; + public cplane_t planes[]; - public int numleafs; // number of visible leafs, not counting 0 - public mleaf_t leafs[]; + public int numleafs; // number of visible leafs, not counting 0 + public mleaf_t leafs[]; - public int numvertexes; - public mvertex_t vertexes[]; + public int numvertexes; + public mvertex_t vertexes[]; - public int numedges; - public medge_t edges[]; + public int numedges; + public medge_t edges[]; - public int numnodes; - public int firstnode; - public mnode_t nodes[]; + public int numnodes; + public int firstnode; + public mnode_t nodes[]; - public int numtexinfo; - public mtexinfo_t texinfo[]; + public int numtexinfo; + public mtexinfo_t texinfo[]; - public int numsurfaces; - public msurface_t surfaces[]; + public int numsurfaces; + public msurface_t surfaces[]; - public int numsurfedges; - public int surfedges[]; + public int numsurfedges; + public int surfedges[]; - public int nummarksurfaces; - public msurface_t marksurfaces[]; + public int nummarksurfaces; + public msurface_t marksurfaces[]; - public qfiles.dvis_t vis; + public qfiles.dvis_t vis; - public byte lightdata[]; + public byte lightdata[]; - // for alias models and skins - // was image_t *skins[]; (array of pointers) - public image_t skins[] = new image_t[Defines.MAX_MD2SKINS]; + // for alias models and skins + // was image_t *skins[]; (array of pointers) + public image_t skins[] = new image_t[Defines.MAX_MD2SKINS]; - public int extradatasize; + public int extradatasize; - // or whatever - public Object extradata; - - public void clear() { - name = ""; - registration_sequence = 0; + // or whatever + public Object extradata; + + public void clear() { + name = ""; + registration_sequence = 0; - // was enum modtype_t - type = 0; - numframes = 0; - flags = 0; + // was enum modtype_t + type = 0; + numframes = 0; + flags = 0; - // - // volume occupied by the model graphics - // - Math3D.VectorClear(mins); - Math3D.VectorClear(maxs); - radius = 0; + // + // volume occupied by the model graphics + // + Math3D.VectorClear(mins); + Math3D.VectorClear(maxs); + radius = 0; - // - // solid volume for clipping - // - clipbox = false; - Math3D.VectorClear(clipmins); - Math3D.VectorClear(clipmaxs); + // + // solid volume for clipping + // + clipbox = false; + Math3D.VectorClear(clipmins); + Math3D.VectorClear(clipmaxs); - // - // brush model - // - firstmodelsurface = nummodelsurfaces = 0; - lightmap = 0; // only for submodels + // + // brush model + // + firstmodelsurface = nummodelsurfaces = 0; + lightmap = 0; // only for submodels - numsubmodels = 0; - submodels = null; + numsubmodels = 0; + submodels = null; - numplanes = 0; - planes = null; + numplanes = 0; + planes = null; - numleafs = 0; // number of visible leafs, not counting 0 - leafs = null; + numleafs = 0; // number of visible leafs, not counting 0 + leafs = null; - numvertexes = 0; - vertexes = null; + numvertexes = 0; + vertexes = null; - numedges = 0; - edges = null; + numedges = 0; + edges = null; - numnodes = 0; - firstnode = 0; - nodes = null; + numnodes = 0; + firstnode = 0; + nodes = null; - numtexinfo = 0; - texinfo = null; + numtexinfo = 0; + texinfo = null; - numsurfaces = 0; - surfaces = null; + numsurfaces = 0; + surfaces = null; - numsurfedges = 0; - surfedges = null; + numsurfedges = 0; + surfedges = null; - nummarksurfaces = 0; - marksurfaces = null; + nummarksurfaces = 0; + marksurfaces = null; - vis = null; + vis = null; - lightdata = null; + lightdata = null; - // for alias models and skins - // was image_t *skins[]; (array of pointers) - Arrays.fill(skins, null); + // for alias models and skins + // was image_t *skins[]; (array of pointers) + Arrays.fill(skins, null); - extradatasize = 0; - // or whatever - extradata = null; - } - - // TODO replace with set(model_t from) - public model_t copy() { - model_t theClone = null; - try - { - theClone = (model_t)super.clone(); - theClone.mins = Lib.clone(this.mins); - theClone.maxs = Lib.clone(this.maxs); - theClone.clipmins = Lib.clone(this.clipmins); - theClone.clipmaxs = Lib.clone(this.clipmaxs); - - } - catch (CloneNotSupportedException e) - { - } - return theClone; - } + extradatasize = 0; + // or whatever + extradata = null; + } + + // TODO replace with set(model_t from) + public model_t copy() { + model_t theClone = null; + try + { + theClone = (model_t)super.clone(); + theClone.mins = Lib.clone(this.mins); + theClone.maxs = Lib.clone(this.maxs); + theClone.clipmins = Lib.clone(this.clipmins); + theClone.clipmaxs = Lib.clone(this.clipmaxs); + + } + catch (CloneNotSupportedException e) + { + } + return theClone; + } } diff --git a/src/main/java/lwjake2/render/msurface_t.java b/src/main/java/lwjake2/render/msurface_t.java index 62e4217..9d6f093 100644 --- a/src/main/java/lwjake2/render/msurface_t.java +++ b/src/main/java/lwjake2/render/msurface_t.java @@ -26,73 +26,73 @@ import java.nio.ByteBuffer; public class msurface_t { - public int visframe; // should be drawn when node is crossed + public int visframe; // should be drawn when node is crossed - public cplane_t plane; - public int flags; + public cplane_t plane; + public int flags; - public int firstedge; // look up in model->surfedges[], negative numbers - public int numedges; // are backwards edges + public int firstedge; // look up in model->surfedges[], negative numbers + public int numedges; // are backwards edges - public short texturemins[] = { 0, 0 }; - public short extents[] = { 0, 0 }; + public short texturemins[] = { 0, 0 }; + public short extents[] = { 0, 0 }; - public int light_s, light_t; // gl lightmap coordinates - public int dlight_s, dlight_t; - // gl lightmap coordinates for dynamic lightmaps + public int light_s, light_t; // gl lightmap coordinates + public int dlight_s, dlight_t; + // gl lightmap coordinates for dynamic lightmaps - public glpoly_t polys; // multiple if warped - public msurface_t texturechain; - public msurface_t lightmapchain; + public glpoly_t polys; // multiple if warped + public msurface_t texturechain; + public msurface_t lightmapchain; - // TODO check this - public mtexinfo_t texinfo = new mtexinfo_t(); + // TODO check this + public mtexinfo_t texinfo = new mtexinfo_t(); - // lighting info - public int dlightframe; - public int dlightbits; + // lighting info + public int dlightframe; + public int dlightbits; - public int lightmaptexturenum; - public byte styles[] = new byte[Defines.MAXLIGHTMAPS]; - public float cached_light[] = new float[Defines.MAXLIGHTMAPS]; - // values currently used in lightmap - //public byte samples[]; // [numstyles*surfsize] - public ByteBuffer samples; // [numstyles*surfsize] - - public void clear() { - visframe = 0; - plane.clear(); - flags = 0; + public int lightmaptexturenum; + public byte styles[] = new byte[Defines.MAXLIGHTMAPS]; + public float cached_light[] = new float[Defines.MAXLIGHTMAPS]; + // values currently used in lightmap + //public byte samples[]; // [numstyles*surfsize] + public ByteBuffer samples; // [numstyles*surfsize] + + public void clear() { + visframe = 0; + plane.clear(); + flags = 0; - firstedge = 0; - numedges = 0; + firstedge = 0; + numedges = 0; - texturemins[0] = texturemins[1] = -1; - extents[0] = extents[1] = 0; + texturemins[0] = texturemins[1] = -1; + extents[0] = extents[1] = 0; - light_s = light_t = 0; - dlight_s = dlight_t = 0; + light_s = light_t = 0; + dlight_s = dlight_t = 0; - polys = null; - texturechain = null; - lightmapchain = null; + polys = null; + texturechain = null; + lightmapchain = null; - //texinfo = new mtexinfo_t(); - texinfo.clear(); + //texinfo = new mtexinfo_t(); + texinfo.clear(); - dlightframe = 0; - dlightbits = 0; + dlightframe = 0; + dlightbits = 0; - lightmaptexturenum = 0; - - for (int i = 0; i < styles.length; i++) - { - styles[i] = 0; - } - for (int i = 0; i < cached_light.length; i++) - { - cached_light[i] = 0; - } - if (samples != null) samples.clear(); - } + lightmaptexturenum = 0; + + for (int i = 0; i < styles.length; i++) + { + styles[i] = 0; + } + for (int i = 0; i < cached_light.length; i++) + { + cached_light[i] = 0; + } + if (samples != null) samples.clear(); + } } diff --git a/src/main/java/lwjake2/render/mtexinfo_t.java b/src/main/java/lwjake2/render/mtexinfo_t.java index 4e36969..271464b 100644 --- a/src/main/java/lwjake2/render/mtexinfo_t.java +++ b/src/main/java/lwjake2/render/mtexinfo_t.java @@ -21,24 +21,24 @@ package lwjake2.render; import java.util.Arrays; public class mtexinfo_t { - // [s/t][xyz offset] - public float vecs[][] = { - { 0, 0, 0, 0 }, - { 0, 0, 0, 0 } - }; - public int flags; - public int numframes; - public mtexinfo_t next; // animation chain - public image_t image; - - public void clear() { - Arrays.fill(vecs[0], 0); - Arrays.fill(vecs[1], 0); - - flags = 0; - numframes = 0; - next = null; - image = null; - } - + // [s/t][xyz offset] + public float vecs[][] = { + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 } + }; + public int flags; + public int numframes; + public mtexinfo_t next; // animation chain + public image_t image; + + public void clear() { + Arrays.fill(vecs[0], 0); + Arrays.fill(vecs[1], 0); + + flags = 0; + numframes = 0; + next = null; + image = null; + } + } diff --git a/src/main/java/lwjake2/server/SV.java b/src/main/java/lwjake2/server/SV.java index eaa83dd..9a6696c 100644 --- a/src/main/java/lwjake2/server/SV.java +++ b/src/main/java/lwjake2/server/SV.java @@ -58,7 +58,7 @@ public final class SV { int i; // - // bound velocity + // bound velocity // for (i = 0; i < 3; i++) { if (ent.velocity[i] > GameBase.sv_maxvelocity.value) @@ -175,7 +175,7 @@ public final class SV { } // - // run the impact function + // run the impact function // SV_Impact(ent, trace); if (!ent.inuse) @@ -194,7 +194,7 @@ public final class SV { numplanes++; // - // modify original_velocity so it parallels all of the clip planes + // modify original_velocity so it parallels all of the clip planes // for (i = 0; i < numplanes; i++) { GameBase.ClipVelocity(original_velocity, planes[i], @@ -214,7 +214,7 @@ public final class SV { Math3D.VectorCopy(new_velocity, ent.velocity); } else { // go along the crease if (numplanes != 2) { - // gi.dprintf ("clip velocity, numplanes == + // gi.dprintf ("clip velocity, numplanes == // %i\n",numplanes); Math3D.VectorCopy(Globals.vec3_origin, ent.velocity); return 7; @@ -225,8 +225,8 @@ public final class SV { } // - // if original velocity is against the original velocity, stop dead - // to avoid tiny occilations in sloping corners + // if original velocity is against the original velocity, stop dead + // to avoid tiny occilations in sloping corners // if (Math3D.DotProduct(ent.velocity, primal_velocity) <= 0) { Math3D.VectorCopy(Globals.vec3_origin, ent.velocity); @@ -329,11 +329,11 @@ public final class SV { maxs[i] = pusher.absmax[i] + move[i]; } - // we need this for pushing things later + // we need this for pushing things later Math3D.VectorSubtract(Globals.vec3_origin, amove, org); Math3D.AngleVectors(org, forward, right, up); - // save the pusher's original position + // save the pusher's original position GameBase.pushed[GameBase.pushed_p].ent = pusher; Math3D.VectorCopy(pusher.s.origin, GameBase.pushed[GameBase.pushed_p].origin); @@ -345,12 +345,12 @@ public final class SV { GameBase.pushed_p++; - // move the pusher to it's final position + // move the pusher to it's final position Math3D.VectorAdd(pusher.s.origin, move, pusher.s.origin); Math3D.VectorAdd(pusher.s.angles, amove, pusher.s.angles); GameBase.gi.linkentity(pusher); - // see if any solid entities are inside the final position + // see if any solid entities are inside the final position //check= g_edicts + 1; for (e = 1; e < GameBase.num_edicts; e++) { @@ -447,7 +447,7 @@ public final class SV { return false; } - // FIXME: is there a better way to handle this? + // FIXME: is there a better way to handle this? // see if anything we moved has touched a trigger for (int ip = GameBase.pushed_p - 1; ip >= 0; ip--) GameBase.G_TouchTriggers(GameBase.pushed[ip].ent); @@ -471,7 +471,7 @@ public final class SV { // make sure all team slaves can move before commiting // any moves or calling any think functions // if the move is blocked, all moved objects will be backed out - // retry: + // retry: GameBase.pushed_p = 0; for (part = ent; part != null; part = part.teamchain) { if (part.velocity[0] != 0 || part.velocity[1] != 0 @@ -521,7 +521,7 @@ public final class SV { * A moving object that doesn't obey physics. */ public static void SV_Physics_Noclip(edict_t ent) { - // regular thinking + // regular thinking if (!SV_RunThink(ent)) return; @@ -546,7 +546,7 @@ public final class SV { boolean isinwater; float[] old_origin = { 0, 0, 0 }; - // regular thinking + // regular thinking SV_RunThink(ent); // if not a team captain, so movement will be handled elsewhere @@ -556,12 +556,12 @@ public final class SV { if (ent.velocity[2] > 0) ent.groundentity = null; - // check for the groundentity going away + // check for the groundentity going away if (ent.groundentity != null) if (!ent.groundentity.inuse) ent.groundentity = null; - // if onground, return without moving + // if onground, return without moving if (ent.groundentity != null) return; @@ -569,16 +569,16 @@ public final class SV { SV_CheckVelocity(ent); - // add gravity + // add gravity if (ent.movetype != Defines.MOVETYPE_FLY && ent.movetype != Defines.MOVETYPE_FLYMISSILE) SV_AddGravity(ent); - // move angles + // move angles Math3D.VectorMA(ent.s.angles, Defines.FRAMETIME, ent.avelocity, ent.s.angles); - // move origin + // move origin Math3D.VectorScale(ent.velocity, Defines.FRAMETIME, move); trace = SV_PushEntity(ent, move); if (!ent.inuse) @@ -605,10 +605,10 @@ public final class SV { } // if (ent.touch) - // ent.touch (ent, trace.ent, &trace.plane, trace.surface); + // ent.touch (ent, trace.ent, &trace.plane, trace.surface); } - // check for water transition + // check for water transition wasinwater = (ent.watertype & Defines.MASK_WATER) != 0; ent.watertype = GameBase.gi.pointcontents.pointcontents(ent.s.origin); isinwater = (ent.watertype & Defines.MASK_WATER) != 0; @@ -625,7 +625,7 @@ public final class SV { GameBase.gi.positioned_sound(ent.s.origin, ent, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/h2ohit1.wav"), 1, 1, 0); - // move teamslaves + // move teamslaves for (slave = ent.teamchain; slave != null; slave = slave.teamchain) { Math3D.VectorCopy(ent.s.origin, slave.s.origin); GameBase.gi.linkentity(slave); @@ -771,7 +771,7 @@ public final class SV { if (!wasonground) if (hitsound) GameBase.gi.sound(ent, 0, - GameBase.gi.soundindex("world/land.wav"), 1, 1, 0); + GameBase.gi.soundindex("world/land.wav"), 1, 1, 0); } // regular thinking @@ -799,11 +799,11 @@ public final class SV { float[] test = { 0, 0, 0 }; int contents; - // try the move + // try the move Math3D.VectorCopy(ent.s.origin, oldorg); Math3D.VectorAdd(ent.s.origin, move, neworg); - // flying monsters don't step up + // flying monsters don't step up if ((ent.flags & (Defines.FL_SWIM | Defines.FL_FLY)) != 0) { // try one move with vertical motion, then one without for (i = 0; i < 2; i++) { @@ -872,7 +872,7 @@ public final class SV { return false; } - // push down from a step height above the wished position + // push down from a step height above the wished position if ((ent.monsterinfo.aiflags & Defines.AI_NOSTEP) == 0) stepsize = GameBase.STEPSIZE; else @@ -922,7 +922,7 @@ public final class SV { return false; // walked off an edge } - // check point traces down for dangling corners + // check point traces down for dangling corners Math3D.VectorCopy(trace.endpos, ent.s.origin); if (!M.M_CheckBottom(ent)) { @@ -945,7 +945,7 @@ public final class SV { ent.groundentity = trace.ent; ent.groundentity_linkcount = trace.ent.linkcount; - // the move is ok + // the move is ok if (relink) { GameBase.gi.linkentity(ent); GameBase.G_TouchTriggers(ent); @@ -1022,7 +1022,7 @@ public final class SV { else d[2] = DI_NODIR; - // try direct route + // try direct route if (d[1] != DI_NODIR && d[2] != DI_NODIR) { if (d[1] == 0) tdir = d[2] == 90 ? 45 : 315; @@ -1033,7 +1033,7 @@ public final class SV { return; } - // try other directions + // try other directions if (((Lib.rand() & 3) & 1) != 0 || Math.abs(deltay) > Math.abs(deltax)) { tdir = d[1]; d[1] = d[2]; @@ -1093,5 +1093,5 @@ public final class SV { return true; } - public static int DI_NODIR = -1; + public static int DI_NODIR = -1; } \ No newline at end of file diff --git a/src/main/java/lwjake2/server/SV_CCMDS.java b/src/main/java/lwjake2/server/SV_CCMDS.java index b9f1feb..87ed5d8 100644 --- a/src/main/java/lwjake2/server/SV_CCMDS.java +++ b/src/main/java/lwjake2/server/SV_CCMDS.java @@ -51,1004 +51,1004 @@ import java.util.Calendar; @Slf4j public class SV_CCMDS { - private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); - /* - =============================================================================== - - OPERATOR CONSOLE ONLY COMMANDS - - These commands can only be entered from stdin or by a remote operator datagram - =============================================================================== - */ - - /* - ==================== - SV_SetMaster_f - - Specify a list of master servers - ==================== - */ - public static void SV_SetMaster_f() { - int i, slot; - - // only dedicated servers send heartbeats - if (Globals.dedicated.value == 0) { - Com.Printf("Only dedicated servers use masters.\n"); - return; - } - - // make sure the server is listed public - Cvar.Set("public", "1"); - - for (i = 1; i < Defines.MAX_MASTERS; i++) - SV_MAIN.master_adr[i] = new netadr_t(); - - slot = 1; // slot 0 will always contain the id master - for (i = 1; i < Cmd.Argc(); i++) { - if (slot == Defines.MAX_MASTERS) - break; - - if (!NET.StringToAdr(Cmd.Argv(i), SV_MAIN.master_adr[i])) { - Com.Printf("Bad address: " + Cmd.Argv(i) + "\n"); - continue; - } - if (SV_MAIN.master_adr[slot].port == 0) - SV_MAIN.master_adr[slot].port = Defines.PORT_MASTER; - - Com.Printf("Master server at " + NET.AdrToString(SV_MAIN.master_adr[slot]) + "\n"); - Com.Printf("Sending a ping.\n"); - - Netchan.OutOfBandPrint(Defines.NS_SERVER, SV_MAIN.master_adr[slot], "ping"); - - slot++; - } - - SV_INIT.svs.last_heartbeat = -9999999; - } - /* - ================== - SV_SetPlayer - - Sets sv_client and sv_player to the player with idnum Cmd.Argv(1) - ================== - */ - public static boolean SV_SetPlayer() { - client_t cl; - int i; - int idnum; - String s; - - if (Cmd.Argc() < 2) - return false; - - s = Cmd.Argv(1); - - // numeric values are just slot numbers - if (s.charAt(0) >= '0' && s.charAt(0) <= '9') { - idnum = Lib.atoi(Cmd.Argv(1)); - if (idnum < 0 || idnum >= SV_MAIN.maxclients.value) { - Com.Printf("Bad client slot: " + idnum + "\n"); - return false; - } - - SV_MAIN.sv_client = SV_INIT.svs.clients[idnum]; - SV_USER.sv_player = SV_MAIN.sv_client.edict; - if (0 == SV_MAIN.sv_client.state) { - Com.Printf("Client " + idnum + " is not active\n"); - return false; - } - return true; - } - - // check for a name match - for (i = 0; i < SV_MAIN.maxclients.value; i++) { - cl = SV_INIT.svs.clients[i]; - if (0 == cl.state) - continue; - if (0 == Lib.strcmp(cl.name, s)) { - SV_MAIN.sv_client = cl; - SV_USER.sv_player = SV_MAIN.sv_client.edict; - return true; - } - } - - Com.Printf("Userid " + s + " is not on the server\n"); - return false; - } - /* - =============================================================================== - - SAVEGAME FILES - - =============================================================================== - */ - - public static void remove(String name) { - try { - new File(name).delete(); - } - catch (Exception e) { - } - } - - /** Delete save files save/(number)/. */ - public static void SV_WipeSavegame(String savename) { - - String name; - - Com.DPrintf("SV_WipeSaveGame(" + savename + ")\n"); - - name = fileSystem.getGamedir() + "/save/" + savename + "/server.ssv"; - remove(name); - - name = fileSystem.getGamedir() + "/save/" + savename + "/game.ssv"; - remove(name); - - name = fileSystem.getGamedir() + "/save/" + savename + "/*.sav"; - - File f = Sys.FindFirst(name, 0, 0); - while (f != null) { - f.delete(); - f = Sys.FindNext(); - } - Sys.FindClose(); - - name = fileSystem.getGamedir() + "/save/" + savename + "/*.sv2"; - - f = Sys.FindFirst(name, 0, 0); - - while (f != null) { - f.delete(); - f = Sys.FindNext(); - } - Sys.FindClose(); - } - /* - ================ - CopyFile - ================ - */ - public static void CopyFile(String src, String dst) { - RandomAccessFile f1, f2; - int l = -1; - byte buffer[] = new byte[65536]; - - //Com.DPrintf("CopyFile (" + src + ", " + dst + ")\n"); - try { - f1 = new RandomAccessFile(src, "r"); - } - catch (Exception e) { - return; - } - try { - f2 = new RandomAccessFile(dst, "rw"); - } - catch (Exception e) { - try { - f1.close(); - } - catch (IOException e1) { - e1.printStackTrace(); - } - return; - } - - while (true) { - - try { - l = f1.read(buffer, 0, 65536); - } - catch (IOException e1) { - - e1.printStackTrace(); - } - if (l == -1) - break; - try { - f2.write(buffer, 0, l); - } - catch (IOException e2) { - - e2.printStackTrace(); - } - } - - try { - f1.close(); - } - catch (IOException e1) { - - e1.printStackTrace(); - } - try { - f2.close(); - } - catch (IOException e2) { - - e2.printStackTrace(); - } - } - /* - ================ - SV_CopySaveGame - ================ - */ - public static void SV_CopySaveGame(String src, String dst) { - File found; - - String name, name2; - - Com.DPrintf("SV_CopySaveGame(" + src + "," + dst + ")\n"); - - SV_WipeSavegame(dst); - - // copy the savegame over - name = fileSystem.getGamedir() + "/save/" + src + "/server.ssv"; - name2 = fileSystem.getGamedir() + "/save/" + dst + "/server.ssv"; - fileSystem.createPath(name2); - CopyFile(name, name2); - - name = fileSystem.getGamedir() + "/save/" + src + "/game.ssv"; - name2 = fileSystem.getGamedir() + "/save/" + dst + "/game.ssv"; - CopyFile(name, name2); - - String name1 = fileSystem.getGamedir() + "/save/" + src + "/"; - name = fileSystem.getGamedir() + "/save/" + src + "/*.sav"; - - found = Sys.FindFirst(name, 0, 0); - - while (found != null) { - name = name1 + found.getName(); - name2 = fileSystem.getGamedir() + "/save/" + dst + "/" + found.getName(); - - CopyFile(name, name2); - - // change sav to sv2 - name = name.substring(0, name.length() - 3) + "sv2"; - name2 = name2.substring(0, name2.length() - 3) + "sv2"; - - CopyFile(name, name2); - - found = Sys.FindNext(); - } - Sys.FindClose(); - } - /* - ============== - SV_WriteLevelFile - - ============== - */ - public static void SV_WriteLevelFile() { - - String name; - QuakeFile f; - - Com.DPrintf("SV_WriteLevelFile()\n"); - - name = fileSystem.getGamedir() + "/save/current/" + SV_INIT.sv.name + ".sv2"; - - try { - f = new QuakeFile(name, "rw"); - - for (int i = 0; i < Defines.MAX_CONFIGSTRINGS; i++) - f.writeString(SV_INIT.sv.configstrings[i]); - - CM.CM_WritePortalState(f); - f.close(); - } - catch (Exception e) { - Com.Printf("Failed to open " + name + "\n"); - e.printStackTrace(); - } - - name = fileSystem.getGamedir() + "/save/current/" + SV_INIT.sv.name + ".sav"; - GameSave.WriteLevel(name); - } - /* - ============== - SV_ReadLevelFile - - ============== - */ - public static void SV_ReadLevelFile() { - //char name[MAX_OSPATH]; - String name; - QuakeFile f; - - Com.DPrintf("SV_ReadLevelFile()\n"); - - name = fileSystem.getGamedir() + "/save/current/" + SV_INIT.sv.name + ".sv2"; - try { - f = new QuakeFile(name, "r"); - - for (int n = 0; n < Defines.MAX_CONFIGSTRINGS; n++) - SV_INIT.sv.configstrings[n] = f.readString(); - - CM.CM_ReadPortalState(f); - - f.close(); - } - catch (IOException e1) { - Com.Printf("Failed to open " + name + "\n"); - e1.printStackTrace(); - } - - name = fileSystem.getGamedir() + "/save/current/" + SV_INIT.sv.name + ".sav"; - GameSave.ReadLevel(name); - } - /* - ============== - SV_WriteServerFile - - ============== - */ - public static void SV_WriteServerFile(boolean autosave) { - QuakeFile f; - cvar_t var; - - String filename, name, string, comment; - - Com.DPrintf("SV_WriteServerFile(" + (autosave ? "true" : "false") + ")\n"); - - filename = fileSystem.getGamedir() + "/save/current/server.ssv"; - try { - f = new QuakeFile(filename, "rw"); - - if (!autosave) { - Calendar c = Calendar.getInstance(); - comment = - Com.sprintf( - "%2i:%2i %2i/%2i ", - new Vargs().add(c.get(Calendar.HOUR_OF_DAY)).add(c.get(Calendar.MINUTE)).add( - c.get(Calendar.MONTH) + 1).add( - c.get(Calendar.DAY_OF_MONTH))); - comment += SV_INIT.sv.configstrings[Defines.CS_NAME]; - } - else { - // autosaved - comment = "ENTERING " + SV_INIT.sv.configstrings[Defines.CS_NAME]; - } - - f.writeString(comment); - f.writeString(SV_INIT.svs.mapcmd); - - // write the mapcmd - - // write all CVAR_LATCH cvars - // these will be things like coop, skill, deathmatch, etc - for (var = Globals.cvar_vars; var != null; var = var.next) { - if (0 == (var.flags & Defines.CVAR_LATCH)) - continue; - if (var.name.length() >= Defines.MAX_OSPATH - 1 || var.string.length() >= 128 - 1) { - Com.Printf("Cvar too long: " + var.name + " = " + var.string + "\n"); - continue; - } - - name = var.name; - string = var.string; - try { - f.writeString(name); - f.writeString(string); - } - catch (IOException e2) { - } - - } - // rst: for termination. - f.writeString(null); - f.close(); - } - catch (Exception e) { - Com.Printf("Couldn't write " + filename + "\n"); - } - - // write game state - filename = fileSystem.getGamedir() + "/save/current/game.ssv"; - GameSave.WriteGame(filename, autosave); - } - /* - ============== - SV_ReadServerFile - - ============== - */ - public static void SV_ReadServerFile() { - String filename="", name = "", string, mapcmd; - try { - QuakeFile f; - - mapcmd = ""; - - Com.DPrintf("SV_ReadServerFile()\n"); - - filename = fileSystem.getGamedir() + "/save/current/server.ssv"; - - f = new QuakeFile(filename, "r"); - - // read the mapcmd - mapcmd = f.readString(); - - // read all CVAR_LATCH cvars - // these will be things like coop, skill, deathmatch, etc - while (true) { - name = f.readString(); - if (name == null) - break; - string = f.readString(); - - Com.DPrintf("Set " + name + " = " + string + "\n"); - Cvar.ForceSet(name, string); - } - - f.close(); - - // start a new game fresh with new cvars - SV_INIT.SV_InitGame(); - - SV_INIT.svs.mapcmd = mapcmd; - - // read game state - filename = fileSystem.getGamedir() + "/save/current/game.ssv"; - GameSave.ReadGame(filename); - } - catch (Exception e) { - Com.Printf("Couldn't read file " + filename + "\n"); - e.printStackTrace(); - } - } - //========================================================= - - /* - ================== - SV_DemoMap_f - - Puts the server in demo mode on a specific map/cinematic - ================== - */ - public static void SV_DemoMap_f() { - SV_INIT.SV_Map(true, Cmd.Argv(1), false); - } - /* - ================== - SV_GameMap_f - - Saves the state of the map just being exited and goes to a new map. - - If the initial character of the map string is '*', the next map is - in a new unit, so the current savegame directory is cleared of - map files. - - Example: - - *inter.cin+jail - - Clears the archived maps, plays the inter.cin cinematic, then - goes to map jail.bsp. - ================== - */ - public static void SV_GameMap_f() { - String map; - int i; - client_t cl; - boolean savedInuse[]; - - if (Cmd.Argc() != 2) { - Com.Printf("USAGE: gamemap \n"); - return; - } - - Com.DPrintf("SV_GameMap(" + Cmd.Argv(1) + ")\n"); - - fileSystem.createPath(fileSystem.getGamedir() + "/save/current/"); - - // check for clearing the current savegame - map = Cmd.Argv(1); - if (map.charAt(0) == '*') { - // wipe all the *.sav files - SV_WipeSavegame("current"); - } - else { // save the map just exited - if (SV_INIT.sv.state == Defines.ss_game) { - // clear all the client inuse flags before saving so that - // when the level is re-entered, the clients will spawn - // at spawn points instead of occupying body shells - savedInuse = new boolean[(int) SV_MAIN.maxclients.value]; - for (i = 0; i < SV_MAIN.maxclients.value; i++) { - cl = SV_INIT.svs.clients[i]; - savedInuse[i] = cl.edict.inuse; - cl.edict.inuse = false; - } - - SV_WriteLevelFile(); - - // we must restore these for clients to transfer over correctly - for (i = 0; i < SV_MAIN.maxclients.value; i++) { - cl = SV_INIT.svs.clients[i]; - cl.edict.inuse = savedInuse[i]; - - } - savedInuse = null; - } - } - - // start up the next map - SV_INIT.SV_Map(false, Cmd.Argv(1), false); - - // archive server state - SV_INIT.svs.mapcmd = Cmd.Argv(1); - - // copy off the level to the autosave slot - if (0 == Globals.dedicated.value) { - SV_WriteServerFile(true); - SV_CopySaveGame("current", "save0"); - } - } - /* - ================== - SV_Map_f - - Goes directly to a given map without any savegame archiving. - For development work - ================== - */ - public static void SV_Map_f() { - String map; - //char expanded[MAX_QPATH]; - String expanded; - - // if not a pcx, demo, or cinematic, check to make sure the level exists - map = Cmd.Argv(1); - if (map.indexOf(".") < 0) { - expanded = "maps/" + map + ".bsp"; - if (fileSystem.loadFile(expanded) == null) { - - Com.Printf("Can't find " + expanded + "\n"); - return; - } - } - - SV_INIT.sv.state = Defines.ss_dead; // don't save current level when changing - - SV_WipeSavegame("current"); - SV_GameMap_f(); - } - /* - ===================================================================== - - SAVEGAMES - - ===================================================================== - */ - - /* - ============== - SV_Loadgame_f - - ============== - */ - public static void SV_Loadgame_f() { - - String name; - RandomAccessFile f; - String dir; - - if (Cmd.Argc() != 2) { - Com.Printf("USAGE: loadgame \n"); - return; - } - - Com.Printf("Loading game...\n"); - - dir = Cmd.Argv(1); - if ( (dir.indexOf("..") > -1) || (dir.indexOf("/") > -1) || (dir.indexOf("\\") > -1)) { - Com.Printf("Bad savedir.\n"); - } - - // make sure the server.ssv file exists - name = fileSystem.getGamedir() + "/save/" + Cmd.Argv(1) + "/server.ssv"; - try { - f = new RandomAccessFile(name, "r"); - } - catch (FileNotFoundException e) { - Com.Printf("No such savegame: " + name + "\n"); - return; - } - - try { - f.close(); - } - catch (IOException e1) { - e1.printStackTrace(); - } - - SV_CopySaveGame(Cmd.Argv(1), "current"); - SV_ReadServerFile(); - - // go to the map - SV_INIT.sv.state = Defines.ss_dead; // don't save current level when changing - SV_INIT.SV_Map(false, SV_INIT.svs.mapcmd, true); - } - /* - ============== - SV_Savegame_f - - ============== - */ - public static void SV_Savegame_f() { - String dir; - - if (SV_INIT.sv.state != Defines.ss_game) { - Com.Printf("You must be in a game to save.\n"); - return; - } - - if (Cmd.Argc() != 2) { - Com.Printf("USAGE: savegame \n"); - return; - } - - if (Cvar.VariableValue("deathmatch") != 0) { - Com.Printf("Can't savegame in a deathmatch\n"); - return; - } - - if (0 == Lib.strcmp(Cmd.Argv(1), "current")) { - Com.Printf("Can't save to 'current'\n"); - return; - } - - if (SV_MAIN.maxclients.value == 1 && SV_INIT.svs.clients[0].edict.client.ps.stats[Defines.STAT_HEALTH] <= 0) { - Com.Printf("\nCan't savegame while dead!\n"); - return; - } - - dir = Cmd.Argv(1); - if ( (dir.indexOf("..") > -1) || (dir.indexOf("/") > -1) || (dir.indexOf("\\") > -1)) { - Com.Printf("Bad savedir.\n"); - } - - Com.Printf("Saving game...\n"); - - // archive current level, including all client edicts. - // when the level is reloaded, they will be shells awaiting - // a connecting client - SV_WriteLevelFile(); - - // save server state - try { - SV_WriteServerFile(false); - } - catch (Exception e) { - Com.Printf("IOError in SV_WriteServerFile: " + e); - } - - // copy it off - SV_CopySaveGame("current", dir); - Com.Printf("Done.\n"); - } - //=============================================================== - /* - ================== - SV_Kick_f - - Kick a user off of the server - ================== - */ - public static void SV_Kick_f() { - if (!SV_INIT.svs.initialized) { - Com.Printf("No server running.\n"); - return; - } - - if (Cmd.Argc() != 2) { - Com.Printf("Usage: kick \n"); - return; - } - - if (!SV_SetPlayer()) - return; - - SV_SEND.SV_BroadcastPrintf(Defines.PRINT_HIGH, SV_MAIN.sv_client.name + " was kicked\n"); - // print directly, because the dropped client won't get the - // SV_BroadcastPrintf message - SV_SEND.SV_ClientPrintf(SV_MAIN.sv_client, Defines.PRINT_HIGH, "You were kicked from the game\n"); - SV_MAIN.SV_DropClient(SV_MAIN.sv_client); - SV_MAIN.sv_client.lastmessage = SV_INIT.svs.realtime; // min case there is a funny zombie - } - /* - ================ - SV_Status_f - ================ - */ - public static void SV_Status_f() { - int i, j, l; - client_t cl; - String s; - int ping; - if (SV_INIT.svs.clients == null) { - Com.Printf("No server running.\n"); - return; - } - log.info("map : {}", SV_INIT.sv.name); - - log.info("num score ping name lastmsg address qport "); - log.info("--- ----- ---- --------------- ------- --------------------- ------"); - for (i = 0; i < SV_MAIN.maxclients.value; i++) { - cl = SV_INIT.svs.clients[i]; - if (0 == cl.state) - continue; - - StringBuilder sb = new StringBuilder(); - sb.append(String.format("%3d ", i)) - .append(String.format("%5d ", cl.edict.client.ps.stats[Defines.STAT_FRAGS])); - - if (cl.state == Defines.cs_connected) - sb.append("CNCT "); - else if (cl.state == Defines.cs_zombie) - sb.append("ZMBI "); - else { - ping = cl.ping < 9999 ? cl.ping : 9999; - sb.append(String.format("%4d ", ping)); - } - - sb.append(cl.name); - l = 16 - cl.name.length(); - for (j = 0; j < l; j++) - sb.append(' '); - - sb.append(String.format("%7d ", (SV_INIT.svs.realtime - cl.lastmessage))); - - s = NET.AdrToString(cl.netchan.remote_address); - sb.append(s); - l = 22 - s.length(); - for (j = 0; j < l; j++) - sb.append(' '); - - sb.append(String.format("%5d", cl.netchan.qport)); - - log.info(sb.toString()); - } - log.info(""); - } - /* - ================== - SV_ConSay_f - ================== - */ - public static void SV_ConSay_f() { - client_t client; - int j; - String p; - String text; // char[1024]; - - if (Cmd.Argc() < 2) - return; - - text = "console: "; - p = Cmd.Args(); - - if (p.charAt(0) == '"') { - p = p.substring(1, p.length() - 1); - } - - text += p; - - for (j = 0; j < SV_MAIN.maxclients.value; j++) { - client = SV_INIT.svs.clients[j]; - if (client.state != Defines.cs_spawned) - continue; - SV_SEND.SV_ClientPrintf(client, Defines.PRINT_CHAT, text + "\n"); - } - } - /* - ================== - SV_Heartbeat_f - ================== - */ - public static void SV_Heartbeat_f() { - SV_INIT.svs.last_heartbeat = -9999999; - } - /* - =========== - SV_Serverinfo_f - - Examine or change the serverinfo string - =========== - */ - public static void SV_Serverinfo_f() { - Com.Printf("Server info settings:\n"); - Info.Print(Cvar.Serverinfo()); - } - /* - =========== - SV_DumpUser_f - - Examine all a users info strings - =========== - */ - public static void SV_DumpUser_f() { - if (Cmd.Argc() != 2) { - Com.Printf("Usage: info \n"); - return; - } - - if (!SV_SetPlayer()) - return; - - Com.Printf("userinfo\n"); - Com.Printf("--------\n"); - Info.Print(SV_MAIN.sv_client.userinfo); - - } - /* - ============== - SV_ServerRecord_f - - Begins server demo recording. Every entity and every message will be - recorded, but no playerinfo will be stored. Primarily for demo merging. - ============== - */ - public static void SV_ServerRecord_f() { - //char name[MAX_OSPATH]; - String name; - byte buf_data[] = new byte[32768]; - sizebuf_t buf = new sizebuf_t(); - int len; - int i; - - if (Cmd.Argc() != 2) { - Com.Printf("serverrecord \n"); - return; - } - - if (SV_INIT.svs.demofile != null) { - Com.Printf("Already recording.\n"); - return; - } - - if (SV_INIT.sv.state != Defines.ss_game) { - Com.Printf("You must be in a level to record.\n"); - return; - } - - // - // open the demo file - // - name = fileSystem.getGamedir() + "/demos/" + Cmd.Argv(1) + ".dm2"; - - Com.Printf("recording to " + name + ".\n"); - fileSystem.createPath(name); - try { - SV_INIT.svs.demofile = new RandomAccessFile(name, "rw"); - } - catch (Exception e) { - Com.Printf("ERROR: couldn't open.\n"); - return; - } - - // setup a buffer to catch all multicasts - SZ.Init(SV_INIT.svs.demo_multicast, SV_INIT.svs.demo_multicast_buf, SV_INIT.svs.demo_multicast_buf.length); - - // - // write a single giant fake message with all the startup info - // - SZ.Init(buf, buf_data, buf_data.length); - - // - // serverdata needs to go over for all types of servers - // to make sure the protocol is right, and to set the gamedir - // - // send the serverdata - MSG.WriteByte(buf, Defines.svc_serverdata); - MSG.WriteLong(buf, Defines.PROTOCOL_VERSION); - MSG.WriteLong(buf, SV_INIT.svs.spawncount); - // 2 means server demo - MSG.WriteByte(buf, 2); // demos are always attract loops - MSG.WriteString(buf, Cvar.VariableString("gamedir")); - MSG.WriteShort(buf, -1); - // send full levelname - MSG.WriteString(buf, SV_INIT.sv.configstrings[Defines.CS_NAME]); - - for (i = 0; i < Defines.MAX_CONFIGSTRINGS; i++) - if (SV_INIT.sv.configstrings[i].length() == 0) { - MSG.WriteByte(buf, Defines.svc_configstring); - MSG.WriteShort(buf, i); - MSG.WriteString(buf, SV_INIT.sv.configstrings[i]); - } - - // write it to the demo file - Com.DPrintf("signon message length: " + buf.cursize + "\n"); - len = EndianHandler.swapInt(buf.cursize); - //fwrite(len, 4, 1, svs.demofile); - //fwrite(buf.data, buf.cursize, 1, svs.demofile); - try { - SV_INIT.svs.demofile.writeInt(len); - SV_INIT.svs.demofile.write(buf.data, 0, buf.cursize); - } - catch (IOException e1) { - // TODO: do quake2 error handling! - e1.printStackTrace(); - } - - // the rest of the demo file will be individual frames - } - /* - ============== - SV_ServerStop_f - - Ends server demo recording - ============== - */ - public static void SV_ServerStop_f() { - if (SV_INIT.svs.demofile == null) { - Com.Printf("Not doing a serverrecord.\n"); - return; - } - try { - SV_INIT.svs.demofile.close(); - } - catch (IOException e) { - e.printStackTrace(); - } - SV_INIT.svs.demofile = null; - Com.Printf("Recording completed.\n"); - } - /* - =============== - SV_KillServer_f - - Kick everyone off, possibly in preparation for a new game - - =============== - */ - public static void SV_KillServer_f() { - if (!SV_INIT.svs.initialized) - return; - SV_MAIN.SV_Shutdown("Server was killed.\n", false); - NET.Config(false); // close network sockets - } - /* - =============== - SV_ServerCommand_f - - Let the game dll handle a command - =============== - */ - public static void SV_ServerCommand_f() { - - GameSVCmds.ServerCommand(); - } - //=========================================================== - - /* - ================== - SV_InitOperatorCommands - ================== - */ - public static void SV_InitOperatorCommands() { - Cmd.AddCommand("heartbeat", SV_CCMDS::SV_Heartbeat_f); - Cmd.AddCommand("kick", SV_CCMDS::SV_Kick_f); - Cmd.AddCommand("status", SV_CCMDS::SV_Status_f); - Cmd.AddCommand("serverinfo", SV_CCMDS::SV_Serverinfo_f); - Cmd.AddCommand("dumpuser", SV_CCMDS::SV_DumpUser_f); - - Cmd.AddCommand("map", SV_CCMDS::SV_Map_f); - Cmd.AddCommand("demomap", SV_CCMDS::SV_DemoMap_f); - Cmd.AddCommand("gamemap", SV_CCMDS::SV_GameMap_f); - Cmd.AddCommand("setmaster", SV_CCMDS::SV_SetMaster_f); - - if (Globals.dedicated.value != 0) - Cmd.AddCommand("say", SV_CCMDS::SV_ConSay_f); - - Cmd.AddCommand("serverrecord", SV_CCMDS::SV_ServerRecord_f); - Cmd.AddCommand("serverstop", SV_CCMDS::SV_ServerStop_f); - - Cmd.AddCommand("save", SV_CCMDS::SV_Savegame_f); - Cmd.AddCommand("load", SV_CCMDS::SV_Loadgame_f); - - Cmd.AddCommand("killserver", SV_CCMDS::SV_KillServer_f); - - Cmd.AddCommand("sv", SV_CCMDS::SV_ServerCommand_f); - } + private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); + /* + =============================================================================== + + OPERATOR CONSOLE ONLY COMMANDS + + These commands can only be entered from stdin or by a remote operator datagram + =============================================================================== + */ + + /* + ==================== + SV_SetMaster_f + + Specify a list of master servers + ==================== + */ + public static void SV_SetMaster_f() { + int i, slot; + + // only dedicated servers send heartbeats + if (Globals.dedicated.value == 0) { + Com.Printf("Only dedicated servers use masters.\n"); + return; + } + + // make sure the server is listed public + Cvar.Set("public", "1"); + + for (i = 1; i < Defines.MAX_MASTERS; i++) + SV_MAIN.master_adr[i] = new netadr_t(); + + slot = 1; // slot 0 will always contain the id master + for (i = 1; i < Cmd.Argc(); i++) { + if (slot == Defines.MAX_MASTERS) + break; + + if (!NET.StringToAdr(Cmd.Argv(i), SV_MAIN.master_adr[i])) { + Com.Printf("Bad address: " + Cmd.Argv(i) + "\n"); + continue; + } + if (SV_MAIN.master_adr[slot].port == 0) + SV_MAIN.master_adr[slot].port = Defines.PORT_MASTER; + + Com.Printf("Master server at " + NET.AdrToString(SV_MAIN.master_adr[slot]) + "\n"); + Com.Printf("Sending a ping.\n"); + + Netchan.OutOfBandPrint(Defines.NS_SERVER, SV_MAIN.master_adr[slot], "ping"); + + slot++; + } + + SV_INIT.svs.last_heartbeat = -9999999; + } + /* + ================== + SV_SetPlayer + + Sets sv_client and sv_player to the player with idnum Cmd.Argv(1) + ================== + */ + public static boolean SV_SetPlayer() { + client_t cl; + int i; + int idnum; + String s; + + if (Cmd.Argc() < 2) + return false; + + s = Cmd.Argv(1); + + // numeric values are just slot numbers + if (s.charAt(0) >= '0' && s.charAt(0) <= '9') { + idnum = Lib.atoi(Cmd.Argv(1)); + if (idnum < 0 || idnum >= SV_MAIN.maxclients.value) { + Com.Printf("Bad client slot: " + idnum + "\n"); + return false; + } + + SV_MAIN.sv_client = SV_INIT.svs.clients[idnum]; + SV_USER.sv_player = SV_MAIN.sv_client.edict; + if (0 == SV_MAIN.sv_client.state) { + Com.Printf("Client " + idnum + " is not active\n"); + return false; + } + return true; + } + + // check for a name match + for (i = 0; i < SV_MAIN.maxclients.value; i++) { + cl = SV_INIT.svs.clients[i]; + if (0 == cl.state) + continue; + if (0 == Lib.strcmp(cl.name, s)) { + SV_MAIN.sv_client = cl; + SV_USER.sv_player = SV_MAIN.sv_client.edict; + return true; + } + } + + Com.Printf("Userid " + s + " is not on the server\n"); + return false; + } + /* + =============================================================================== + + SAVEGAME FILES + + =============================================================================== + */ + + public static void remove(String name) { + try { + new File(name).delete(); + } + catch (Exception e) { + } + } + + /** Delete save files save/(number)/. */ + public static void SV_WipeSavegame(String savename) { + + String name; + + Com.DPrintf("SV_WipeSaveGame(" + savename + ")\n"); + + name = fileSystem.getGamedir() + "/save/" + savename + "/server.ssv"; + remove(name); + + name = fileSystem.getGamedir() + "/save/" + savename + "/game.ssv"; + remove(name); + + name = fileSystem.getGamedir() + "/save/" + savename + "/*.sav"; + + File f = Sys.FindFirst(name, 0, 0); + while (f != null) { + f.delete(); + f = Sys.FindNext(); + } + Sys.FindClose(); + + name = fileSystem.getGamedir() + "/save/" + savename + "/*.sv2"; + + f = Sys.FindFirst(name, 0, 0); + + while (f != null) { + f.delete(); + f = Sys.FindNext(); + } + Sys.FindClose(); + } + /* + ================ + CopyFile + ================ + */ + public static void CopyFile(String src, String dst) { + RandomAccessFile f1, f2; + int l = -1; + byte buffer[] = new byte[65536]; + + //Com.DPrintf("CopyFile (" + src + ", " + dst + ")\n"); + try { + f1 = new RandomAccessFile(src, "r"); + } + catch (Exception e) { + return; + } + try { + f2 = new RandomAccessFile(dst, "rw"); + } + catch (Exception e) { + try { + f1.close(); + } + catch (IOException e1) { + e1.printStackTrace(); + } + return; + } + + while (true) { + + try { + l = f1.read(buffer, 0, 65536); + } + catch (IOException e1) { + + e1.printStackTrace(); + } + if (l == -1) + break; + try { + f2.write(buffer, 0, l); + } + catch (IOException e2) { + + e2.printStackTrace(); + } + } + + try { + f1.close(); + } + catch (IOException e1) { + + e1.printStackTrace(); + } + try { + f2.close(); + } + catch (IOException e2) { + + e2.printStackTrace(); + } + } + /* + ================ + SV_CopySaveGame + ================ + */ + public static void SV_CopySaveGame(String src, String dst) { + File found; + + String name, name2; + + Com.DPrintf("SV_CopySaveGame(" + src + "," + dst + ")\n"); + + SV_WipeSavegame(dst); + + // copy the savegame over + name = fileSystem.getGamedir() + "/save/" + src + "/server.ssv"; + name2 = fileSystem.getGamedir() + "/save/" + dst + "/server.ssv"; + fileSystem.createPath(name2); + CopyFile(name, name2); + + name = fileSystem.getGamedir() + "/save/" + src + "/game.ssv"; + name2 = fileSystem.getGamedir() + "/save/" + dst + "/game.ssv"; + CopyFile(name, name2); + + String name1 = fileSystem.getGamedir() + "/save/" + src + "/"; + name = fileSystem.getGamedir() + "/save/" + src + "/*.sav"; + + found = Sys.FindFirst(name, 0, 0); + + while (found != null) { + name = name1 + found.getName(); + name2 = fileSystem.getGamedir() + "/save/" + dst + "/" + found.getName(); + + CopyFile(name, name2); + + // change sav to sv2 + name = name.substring(0, name.length() - 3) + "sv2"; + name2 = name2.substring(0, name2.length() - 3) + "sv2"; + + CopyFile(name, name2); + + found = Sys.FindNext(); + } + Sys.FindClose(); + } + /* + ============== + SV_WriteLevelFile + + ============== + */ + public static void SV_WriteLevelFile() { + + String name; + QuakeFile f; + + Com.DPrintf("SV_WriteLevelFile()\n"); + + name = fileSystem.getGamedir() + "/save/current/" + SV_INIT.sv.name + ".sv2"; + + try { + f = new QuakeFile(name, "rw"); + + for (int i = 0; i < Defines.MAX_CONFIGSTRINGS; i++) + f.writeString(SV_INIT.sv.configstrings[i]); + + CM.CM_WritePortalState(f); + f.close(); + } + catch (Exception e) { + Com.Printf("Failed to open " + name + "\n"); + e.printStackTrace(); + } + + name = fileSystem.getGamedir() + "/save/current/" + SV_INIT.sv.name + ".sav"; + GameSave.WriteLevel(name); + } + /* + ============== + SV_ReadLevelFile + + ============== + */ + public static void SV_ReadLevelFile() { + //char name[MAX_OSPATH]; + String name; + QuakeFile f; + + Com.DPrintf("SV_ReadLevelFile()\n"); + + name = fileSystem.getGamedir() + "/save/current/" + SV_INIT.sv.name + ".sv2"; + try { + f = new QuakeFile(name, "r"); + + for (int n = 0; n < Defines.MAX_CONFIGSTRINGS; n++) + SV_INIT.sv.configstrings[n] = f.readString(); + + CM.CM_ReadPortalState(f); + + f.close(); + } + catch (IOException e1) { + Com.Printf("Failed to open " + name + "\n"); + e1.printStackTrace(); + } + + name = fileSystem.getGamedir() + "/save/current/" + SV_INIT.sv.name + ".sav"; + GameSave.ReadLevel(name); + } + /* + ============== + SV_WriteServerFile + + ============== + */ + public static void SV_WriteServerFile(boolean autosave) { + QuakeFile f; + cvar_t var; + + String filename, name, string, comment; + + Com.DPrintf("SV_WriteServerFile(" + (autosave ? "true" : "false") + ")\n"); + + filename = fileSystem.getGamedir() + "/save/current/server.ssv"; + try { + f = new QuakeFile(filename, "rw"); + + if (!autosave) { + Calendar c = Calendar.getInstance(); + comment = + Com.sprintf( + "%2i:%2i %2i/%2i ", + new Vargs().add(c.get(Calendar.HOUR_OF_DAY)).add(c.get(Calendar.MINUTE)).add( + c.get(Calendar.MONTH) + 1).add( + c.get(Calendar.DAY_OF_MONTH))); + comment += SV_INIT.sv.configstrings[Defines.CS_NAME]; + } + else { + // autosaved + comment = "ENTERING " + SV_INIT.sv.configstrings[Defines.CS_NAME]; + } + + f.writeString(comment); + f.writeString(SV_INIT.svs.mapcmd); + + // write the mapcmd + + // write all CVAR_LATCH cvars + // these will be things like coop, skill, deathmatch, etc + for (var = Globals.cvar_vars; var != null; var = var.next) { + if (0 == (var.flags & Defines.CVAR_LATCH)) + continue; + if (var.name.length() >= Defines.MAX_OSPATH - 1 || var.string.length() >= 128 - 1) { + Com.Printf("Cvar too long: " + var.name + " = " + var.string + "\n"); + continue; + } + + name = var.name; + string = var.string; + try { + f.writeString(name); + f.writeString(string); + } + catch (IOException e2) { + } + + } + // rst: for termination. + f.writeString(null); + f.close(); + } + catch (Exception e) { + Com.Printf("Couldn't write " + filename + "\n"); + } + + // write game state + filename = fileSystem.getGamedir() + "/save/current/game.ssv"; + GameSave.WriteGame(filename, autosave); + } + /* + ============== + SV_ReadServerFile + + ============== + */ + public static void SV_ReadServerFile() { + String filename="", name = "", string, mapcmd; + try { + QuakeFile f; + + mapcmd = ""; + + Com.DPrintf("SV_ReadServerFile()\n"); + + filename = fileSystem.getGamedir() + "/save/current/server.ssv"; + + f = new QuakeFile(filename, "r"); + + // read the mapcmd + mapcmd = f.readString(); + + // read all CVAR_LATCH cvars + // these will be things like coop, skill, deathmatch, etc + while (true) { + name = f.readString(); + if (name == null) + break; + string = f.readString(); + + Com.DPrintf("Set " + name + " = " + string + "\n"); + Cvar.ForceSet(name, string); + } + + f.close(); + + // start a new game fresh with new cvars + SV_INIT.SV_InitGame(); + + SV_INIT.svs.mapcmd = mapcmd; + + // read game state + filename = fileSystem.getGamedir() + "/save/current/game.ssv"; + GameSave.ReadGame(filename); + } + catch (Exception e) { + Com.Printf("Couldn't read file " + filename + "\n"); + e.printStackTrace(); + } + } + //========================================================= + + /* + ================== + SV_DemoMap_f + + Puts the server in demo mode on a specific map/cinematic + ================== + */ + public static void SV_DemoMap_f() { + SV_INIT.SV_Map(true, Cmd.Argv(1), false); + } + /* + ================== + SV_GameMap_f + + Saves the state of the map just being exited and goes to a new map. + + If the initial character of the map string is '*', the next map is + in a new unit, so the current savegame directory is cleared of + map files. + + Example: + + *inter.cin+jail + + Clears the archived maps, plays the inter.cin cinematic, then + goes to map jail.bsp. + ================== + */ + public static void SV_GameMap_f() { + String map; + int i; + client_t cl; + boolean savedInuse[]; + + if (Cmd.Argc() != 2) { + Com.Printf("USAGE: gamemap \n"); + return; + } + + Com.DPrintf("SV_GameMap(" + Cmd.Argv(1) + ")\n"); + + fileSystem.createPath(fileSystem.getGamedir() + "/save/current/"); + + // check for clearing the current savegame + map = Cmd.Argv(1); + if (map.charAt(0) == '*') { + // wipe all the *.sav files + SV_WipeSavegame("current"); + } + else { // save the map just exited + if (SV_INIT.sv.state == Defines.ss_game) { + // clear all the client inuse flags before saving so that + // when the level is re-entered, the clients will spawn + // at spawn points instead of occupying body shells + savedInuse = new boolean[(int) SV_MAIN.maxclients.value]; + for (i = 0; i < SV_MAIN.maxclients.value; i++) { + cl = SV_INIT.svs.clients[i]; + savedInuse[i] = cl.edict.inuse; + cl.edict.inuse = false; + } + + SV_WriteLevelFile(); + + // we must restore these for clients to transfer over correctly + for (i = 0; i < SV_MAIN.maxclients.value; i++) { + cl = SV_INIT.svs.clients[i]; + cl.edict.inuse = savedInuse[i]; + + } + savedInuse = null; + } + } + + // start up the next map + SV_INIT.SV_Map(false, Cmd.Argv(1), false); + + // archive server state + SV_INIT.svs.mapcmd = Cmd.Argv(1); + + // copy off the level to the autosave slot + if (0 == Globals.dedicated.value) { + SV_WriteServerFile(true); + SV_CopySaveGame("current", "save0"); + } + } + /* + ================== + SV_Map_f + + Goes directly to a given map without any savegame archiving. + For development work + ================== + */ + public static void SV_Map_f() { + String map; + //char expanded[MAX_QPATH]; + String expanded; + + // if not a pcx, demo, or cinematic, check to make sure the level exists + map = Cmd.Argv(1); + if (map.indexOf(".") < 0) { + expanded = "maps/" + map + ".bsp"; + if (fileSystem.loadFile(expanded) == null) { + + Com.Printf("Can't find " + expanded + "\n"); + return; + } + } + + SV_INIT.sv.state = Defines.ss_dead; // don't save current level when changing + + SV_WipeSavegame("current"); + SV_GameMap_f(); + } + /* + ===================================================================== + + SAVEGAMES + + ===================================================================== + */ + + /* + ============== + SV_Loadgame_f + + ============== + */ + public static void SV_Loadgame_f() { + + String name; + RandomAccessFile f; + String dir; + + if (Cmd.Argc() != 2) { + Com.Printf("USAGE: loadgame \n"); + return; + } + + Com.Printf("Loading game...\n"); + + dir = Cmd.Argv(1); + if ( (dir.indexOf("..") > -1) || (dir.indexOf("/") > -1) || (dir.indexOf("\\") > -1)) { + Com.Printf("Bad savedir.\n"); + } + + // make sure the server.ssv file exists + name = fileSystem.getGamedir() + "/save/" + Cmd.Argv(1) + "/server.ssv"; + try { + f = new RandomAccessFile(name, "r"); + } + catch (FileNotFoundException e) { + Com.Printf("No such savegame: " + name + "\n"); + return; + } + + try { + f.close(); + } + catch (IOException e1) { + e1.printStackTrace(); + } + + SV_CopySaveGame(Cmd.Argv(1), "current"); + SV_ReadServerFile(); + + // go to the map + SV_INIT.sv.state = Defines.ss_dead; // don't save current level when changing + SV_INIT.SV_Map(false, SV_INIT.svs.mapcmd, true); + } + /* + ============== + SV_Savegame_f + + ============== + */ + public static void SV_Savegame_f() { + String dir; + + if (SV_INIT.sv.state != Defines.ss_game) { + Com.Printf("You must be in a game to save.\n"); + return; + } + + if (Cmd.Argc() != 2) { + Com.Printf("USAGE: savegame \n"); + return; + } + + if (Cvar.VariableValue("deathmatch") != 0) { + Com.Printf("Can't savegame in a deathmatch\n"); + return; + } + + if (0 == Lib.strcmp(Cmd.Argv(1), "current")) { + Com.Printf("Can't save to 'current'\n"); + return; + } + + if (SV_MAIN.maxclients.value == 1 && SV_INIT.svs.clients[0].edict.client.ps.stats[Defines.STAT_HEALTH] <= 0) { + Com.Printf("\nCan't savegame while dead!\n"); + return; + } + + dir = Cmd.Argv(1); + if ( (dir.indexOf("..") > -1) || (dir.indexOf("/") > -1) || (dir.indexOf("\\") > -1)) { + Com.Printf("Bad savedir.\n"); + } + + Com.Printf("Saving game...\n"); + + // archive current level, including all client edicts. + // when the level is reloaded, they will be shells awaiting + // a connecting client + SV_WriteLevelFile(); + + // save server state + try { + SV_WriteServerFile(false); + } + catch (Exception e) { + Com.Printf("IOError in SV_WriteServerFile: " + e); + } + + // copy it off + SV_CopySaveGame("current", dir); + Com.Printf("Done.\n"); + } + //=============================================================== + /* + ================== + SV_Kick_f + + Kick a user off of the server + ================== + */ + public static void SV_Kick_f() { + if (!SV_INIT.svs.initialized) { + Com.Printf("No server running.\n"); + return; + } + + if (Cmd.Argc() != 2) { + Com.Printf("Usage: kick \n"); + return; + } + + if (!SV_SetPlayer()) + return; + + SV_SEND.SV_BroadcastPrintf(Defines.PRINT_HIGH, SV_MAIN.sv_client.name + " was kicked\n"); + // print directly, because the dropped client won't get the + // SV_BroadcastPrintf message + SV_SEND.SV_ClientPrintf(SV_MAIN.sv_client, Defines.PRINT_HIGH, "You were kicked from the game\n"); + SV_MAIN.SV_DropClient(SV_MAIN.sv_client); + SV_MAIN.sv_client.lastmessage = SV_INIT.svs.realtime; // min case there is a funny zombie + } + /* + ================ + SV_Status_f + ================ + */ + public static void SV_Status_f() { + int i, j, l; + client_t cl; + String s; + int ping; + if (SV_INIT.svs.clients == null) { + Com.Printf("No server running.\n"); + return; + } + log.info("map : {}", SV_INIT.sv.name); + + log.info("num score ping name lastmsg address qport "); + log.info("--- ----- ---- --------------- ------- --------------------- ------"); + for (i = 0; i < SV_MAIN.maxclients.value; i++) { + cl = SV_INIT.svs.clients[i]; + if (0 == cl.state) + continue; + + StringBuilder sb = new StringBuilder(); + sb.append(String.format("%3d ", i)) + .append(String.format("%5d ", cl.edict.client.ps.stats[Defines.STAT_FRAGS])); + + if (cl.state == Defines.cs_connected) + sb.append("CNCT "); + else if (cl.state == Defines.cs_zombie) + sb.append("ZMBI "); + else { + ping = cl.ping < 9999 ? cl.ping : 9999; + sb.append(String.format("%4d ", ping)); + } + + sb.append(cl.name); + l = 16 - cl.name.length(); + for (j = 0; j < l; j++) + sb.append(' '); + + sb.append(String.format("%7d ", (SV_INIT.svs.realtime - cl.lastmessage))); + + s = NET.AdrToString(cl.netchan.remote_address); + sb.append(s); + l = 22 - s.length(); + for (j = 0; j < l; j++) + sb.append(' '); + + sb.append(String.format("%5d", cl.netchan.qport)); + + log.info(sb.toString()); + } + log.info(""); + } + /* + ================== + SV_ConSay_f + ================== + */ + public static void SV_ConSay_f() { + client_t client; + int j; + String p; + String text; // char[1024]; + + if (Cmd.Argc() < 2) + return; + + text = "console: "; + p = Cmd.Args(); + + if (p.charAt(0) == '"') { + p = p.substring(1, p.length() - 1); + } + + text += p; + + for (j = 0; j < SV_MAIN.maxclients.value; j++) { + client = SV_INIT.svs.clients[j]; + if (client.state != Defines.cs_spawned) + continue; + SV_SEND.SV_ClientPrintf(client, Defines.PRINT_CHAT, text + "\n"); + } + } + /* + ================== + SV_Heartbeat_f + ================== + */ + public static void SV_Heartbeat_f() { + SV_INIT.svs.last_heartbeat = -9999999; + } + /* + =========== + SV_Serverinfo_f + + Examine or change the serverinfo string + =========== + */ + public static void SV_Serverinfo_f() { + Com.Printf("Server info settings:\n"); + Info.Print(Cvar.Serverinfo()); + } + /* + =========== + SV_DumpUser_f + + Examine all a users info strings + =========== + */ + public static void SV_DumpUser_f() { + if (Cmd.Argc() != 2) { + Com.Printf("Usage: info \n"); + return; + } + + if (!SV_SetPlayer()) + return; + + Com.Printf("userinfo\n"); + Com.Printf("--------\n"); + Info.Print(SV_MAIN.sv_client.userinfo); + + } + /* + ============== + SV_ServerRecord_f + + Begins server demo recording. Every entity and every message will be + recorded, but no playerinfo will be stored. Primarily for demo merging. + ============== + */ + public static void SV_ServerRecord_f() { + //char name[MAX_OSPATH]; + String name; + byte buf_data[] = new byte[32768]; + sizebuf_t buf = new sizebuf_t(); + int len; + int i; + + if (Cmd.Argc() != 2) { + Com.Printf("serverrecord \n"); + return; + } + + if (SV_INIT.svs.demofile != null) { + Com.Printf("Already recording.\n"); + return; + } + + if (SV_INIT.sv.state != Defines.ss_game) { + Com.Printf("You must be in a level to record.\n"); + return; + } + + // + // open the demo file + // + name = fileSystem.getGamedir() + "/demos/" + Cmd.Argv(1) + ".dm2"; + + Com.Printf("recording to " + name + ".\n"); + fileSystem.createPath(name); + try { + SV_INIT.svs.demofile = new RandomAccessFile(name, "rw"); + } + catch (Exception e) { + Com.Printf("ERROR: couldn't open.\n"); + return; + } + + // setup a buffer to catch all multicasts + SZ.Init(SV_INIT.svs.demo_multicast, SV_INIT.svs.demo_multicast_buf, SV_INIT.svs.demo_multicast_buf.length); + + // + // write a single giant fake message with all the startup info + // + SZ.Init(buf, buf_data, buf_data.length); + + // + // serverdata needs to go over for all types of servers + // to make sure the protocol is right, and to set the gamedir + // + // send the serverdata + MSG.WriteByte(buf, Defines.svc_serverdata); + MSG.WriteLong(buf, Defines.PROTOCOL_VERSION); + MSG.WriteLong(buf, SV_INIT.svs.spawncount); + // 2 means server demo + MSG.WriteByte(buf, 2); // demos are always attract loops + MSG.WriteString(buf, Cvar.VariableString("gamedir")); + MSG.WriteShort(buf, -1); + // send full levelname + MSG.WriteString(buf, SV_INIT.sv.configstrings[Defines.CS_NAME]); + + for (i = 0; i < Defines.MAX_CONFIGSTRINGS; i++) + if (SV_INIT.sv.configstrings[i].length() == 0) { + MSG.WriteByte(buf, Defines.svc_configstring); + MSG.WriteShort(buf, i); + MSG.WriteString(buf, SV_INIT.sv.configstrings[i]); + } + + // write it to the demo file + Com.DPrintf("signon message length: " + buf.cursize + "\n"); + len = EndianHandler.swapInt(buf.cursize); + //fwrite(len, 4, 1, svs.demofile); + //fwrite(buf.data, buf.cursize, 1, svs.demofile); + try { + SV_INIT.svs.demofile.writeInt(len); + SV_INIT.svs.demofile.write(buf.data, 0, buf.cursize); + } + catch (IOException e1) { + // TODO: do quake2 error handling! + e1.printStackTrace(); + } + + // the rest of the demo file will be individual frames + } + /* + ============== + SV_ServerStop_f + + Ends server demo recording + ============== + */ + public static void SV_ServerStop_f() { + if (SV_INIT.svs.demofile == null) { + Com.Printf("Not doing a serverrecord.\n"); + return; + } + try { + SV_INIT.svs.demofile.close(); + } + catch (IOException e) { + e.printStackTrace(); + } + SV_INIT.svs.demofile = null; + Com.Printf("Recording completed.\n"); + } + /* + =============== + SV_KillServer_f + + Kick everyone off, possibly in preparation for a new game + + =============== + */ + public static void SV_KillServer_f() { + if (!SV_INIT.svs.initialized) + return; + SV_MAIN.SV_Shutdown("Server was killed.\n", false); + NET.Config(false); // close network sockets + } + /* + =============== + SV_ServerCommand_f + + Let the game dll handle a command + =============== + */ + public static void SV_ServerCommand_f() { + + GameSVCmds.ServerCommand(); + } + //=========================================================== + + /* + ================== + SV_InitOperatorCommands + ================== + */ + public static void SV_InitOperatorCommands() { + Cmd.AddCommand("heartbeat", SV_CCMDS::SV_Heartbeat_f); + Cmd.AddCommand("kick", SV_CCMDS::SV_Kick_f); + Cmd.AddCommand("status", SV_CCMDS::SV_Status_f); + Cmd.AddCommand("serverinfo", SV_CCMDS::SV_Serverinfo_f); + Cmd.AddCommand("dumpuser", SV_CCMDS::SV_DumpUser_f); + + Cmd.AddCommand("map", SV_CCMDS::SV_Map_f); + Cmd.AddCommand("demomap", SV_CCMDS::SV_DemoMap_f); + Cmd.AddCommand("gamemap", SV_CCMDS::SV_GameMap_f); + Cmd.AddCommand("setmaster", SV_CCMDS::SV_SetMaster_f); + + if (Globals.dedicated.value != 0) + Cmd.AddCommand("say", SV_CCMDS::SV_ConSay_f); + + Cmd.AddCommand("serverrecord", SV_CCMDS::SV_ServerRecord_f); + Cmd.AddCommand("serverstop", SV_CCMDS::SV_ServerStop_f); + + Cmd.AddCommand("save", SV_CCMDS::SV_Savegame_f); + Cmd.AddCommand("load", SV_CCMDS::SV_Loadgame_f); + + Cmd.AddCommand("killserver", SV_CCMDS::SV_KillServer_f); + + Cmd.AddCommand("sv", SV_CCMDS::SV_ServerCommand_f); + } } diff --git a/src/main/java/lwjake2/server/SV_ENTS.java b/src/main/java/lwjake2/server/SV_ENTS.java index 752ab90..1d7dbb3 100644 --- a/src/main/java/lwjake2/server/SV_ENTS.java +++ b/src/main/java/lwjake2/server/SV_ENTS.java @@ -91,7 +91,7 @@ public class SV_ENTS { } if (newnum == oldnum) { - // delta update from old position + // delta update from old position // because the force parm is false, this will not result // in any bytes being emited if the entity has not changed at // all note that players are always 'newentities', this updates @@ -105,7 +105,7 @@ public class SV_ENTS { } if (newnum < oldnum) { - // this is a new entity, send it from the baseline + // this is a new entity, send it from the baseline MSG.WriteDeltaEntity(SV_INIT.sv.baselines[newnum], newent, msg, true, true); newindex++; @@ -113,7 +113,7 @@ public class SV_ENTS { } if (newnum > oldnum) { - // the old entity isn't present in the new message + // the old entity isn't present in the new message bits = Defines.U_REMOVE; if (oldnum >= 256) bits |= Defines.U_NUMBER16 | Defines.U_MOREBITS1; @@ -390,7 +390,7 @@ public class SV_ENTS { src = CM.CM_ClusterPVS(leafs[i]); //for (j=0 ; j> 3] & (1 << (cluster & 7))))) - continue; - } + // quake2 bugfix + if (cluster == -1) + continue; + if (mask != null && (0 == (mask[cluster >> 3] & (1 << (cluster & 7))))) + continue; + } - if (reliable) - SZ.Write(client.netchan.message, SV_INIT.sv.multicast.data, SV_INIT.sv.multicast.cursize); - else - SZ.Write(client.datagram, SV_INIT.sv.multicast.data, SV_INIT.sv.multicast.cursize); - } + if (reliable) + SZ.Write(client.netchan.message, SV_INIT.sv.multicast.data, SV_INIT.sv.multicast.cursize); + else + SZ.Write(client.datagram, SV_INIT.sv.multicast.data, SV_INIT.sv.multicast.cursize); + } - SZ.Clear(SV_INIT.sv.multicast); - } + SZ.Clear(SV_INIT.sv.multicast); + } - private static final float[] origin_v = { 0, 0, 0 }; - /* - ================== - SV_StartSound - - Each entity can have eight independant sound sources, like voice, - weapon, feet, etc. - - If cahnnel & 8, the sound will be sent to everyone, not just - things in the PHS. - - FIXME: if entity isn't in PHS, they must be forced to be sent or - have the origin explicitly sent. - - Channel 0 is an auto-allocate channel, the others override anything - already running on that entity/channel pair. - - An attenuation of 0 will play full volume everywhere in the level. - Larger attenuations will drop off. (max 4 attenuation) - - Timeofs can range from 0.0 to 0.1 to cause sounds to be started - later in the frame than they normally would. - - If origin is null, the origin is determined from the entity origin - or the midpoint of the entity box for bmodels. - ================== - */ - public static void SV_StartSound( - float[] origin, - edict_t entity, - int channel, - int soundindex, - float volume, - float attenuation, - float timeofs) { - int sendchan; - int flags; - int i; - int ent; - boolean use_phs; + private static final float[] origin_v = { 0, 0, 0 }; + /* + ================== + SV_StartSound + + Each entity can have eight independant sound sources, like voice, + weapon, feet, etc. + + If cahnnel & 8, the sound will be sent to everyone, not just + things in the PHS. + + FIXME: if entity isn't in PHS, they must be forced to be sent or + have the origin explicitly sent. + + Channel 0 is an auto-allocate channel, the others override anything + already running on that entity/channel pair. + + An attenuation of 0 will play full volume everywhere in the level. + Larger attenuations will drop off. (max 4 attenuation) + + Timeofs can range from 0.0 to 0.1 to cause sounds to be started + later in the frame than they normally would. + + If origin is null, the origin is determined from the entity origin + or the midpoint of the entity box for bmodels. + ================== + */ + public static void SV_StartSound( + float[] origin, + edict_t entity, + int channel, + int soundindex, + float volume, + float attenuation, + float timeofs) { + int sendchan; + int flags; + int i; + int ent; + boolean use_phs; - if (volume < 0 || volume > 1.0) - Com.Error(Defines.ERR_FATAL, "SV_StartSound: volume = " + volume); + if (volume < 0 || volume > 1.0) + Com.Error(Defines.ERR_FATAL, "SV_StartSound: volume = " + volume); - if (attenuation < 0 || attenuation > 4) - Com.Error(Defines.ERR_FATAL, "SV_StartSound: attenuation = " + attenuation); + if (attenuation < 0 || attenuation > 4) + Com.Error(Defines.ERR_FATAL, "SV_StartSound: attenuation = " + attenuation); - // if (channel < 0 || channel > 15) - // Com_Error (ERR_FATAL, "SV_StartSound: channel = %i", channel); + // if (channel < 0 || channel > 15) + // Com_Error (ERR_FATAL, "SV_StartSound: channel = %i", channel); - if (timeofs < 0 || timeofs > 0.255) - Com.Error(Defines.ERR_FATAL, "SV_StartSound: timeofs = " + timeofs); + if (timeofs < 0 || timeofs > 0.255) + Com.Error(Defines.ERR_FATAL, "SV_StartSound: timeofs = " + timeofs); - ent = entity.index; + ent = entity.index; - // no PHS flag - if ((channel & 8) != 0) { - use_phs = false; - channel &= 7; - } - else - use_phs = true; + // no PHS flag + if ((channel & 8) != 0) { + use_phs = false; + channel &= 7; + } + else + use_phs = true; - sendchan = (ent << 3) | (channel & 7); + sendchan = (ent << 3) | (channel & 7); - flags = 0; - if (volume != Defines.DEFAULT_SOUND_PACKET_VOLUME) - flags |= Defines.SND_VOLUME; - if (attenuation != Defines.DEFAULT_SOUND_PACKET_ATTENUATION) - flags |= Defines.SND_ATTENUATION; + flags = 0; + if (volume != Defines.DEFAULT_SOUND_PACKET_VOLUME) + flags |= Defines.SND_VOLUME; + if (attenuation != Defines.DEFAULT_SOUND_PACKET_ATTENUATION) + flags |= Defines.SND_ATTENUATION; - // the client doesn't know that bmodels have weird origins - // the origin can also be explicitly set - if ((entity.svflags & Defines.SVF_NOCLIENT) != 0 || (entity.solid == Defines.SOLID_BSP) || origin != null) - flags |= Defines.SND_POS; + // the client doesn't know that bmodels have weird origins + // the origin can also be explicitly set + if ((entity.svflags & Defines.SVF_NOCLIENT) != 0 || (entity.solid == Defines.SOLID_BSP) || origin != null) + flags |= Defines.SND_POS; - // always send the entity number for channel overrides - flags |= Defines.SND_ENT; + // always send the entity number for channel overrides + flags |= Defines.SND_ENT; - if (timeofs != 0) - flags |= Defines.SND_OFFSET; + if (timeofs != 0) + flags |= Defines.SND_OFFSET; - // use the entity origin unless it is a bmodel or explicitly specified - if (origin == null) { - origin = origin_v; - if (entity.solid == Defines.SOLID_BSP) { - for (i = 0; i < 3; i++) - origin_v[i] = entity.s.origin[i] + 0.5f * (entity.mins[i] + entity.maxs[i]); - } - else { - Math3D.VectorCopy(entity.s.origin, origin_v); - } - } + // use the entity origin unless it is a bmodel or explicitly specified + if (origin == null) { + origin = origin_v; + if (entity.solid == Defines.SOLID_BSP) { + for (i = 0; i < 3; i++) + origin_v[i] = entity.s.origin[i] + 0.5f * (entity.mins[i] + entity.maxs[i]); + } + else { + Math3D.VectorCopy(entity.s.origin, origin_v); + } + } - MSG.WriteByte(SV_INIT.sv.multicast, Defines.svc_sound); - MSG.WriteByte(SV_INIT.sv.multicast, flags); - MSG.WriteByte(SV_INIT.sv.multicast, soundindex); + MSG.WriteByte(SV_INIT.sv.multicast, Defines.svc_sound); + MSG.WriteByte(SV_INIT.sv.multicast, flags); + MSG.WriteByte(SV_INIT.sv.multicast, soundindex); - if ((flags & Defines.SND_VOLUME) != 0) - MSG.WriteByte(SV_INIT.sv.multicast, volume * 255); - if ((flags & Defines.SND_ATTENUATION) != 0) - MSG.WriteByte(SV_INIT.sv.multicast, attenuation * 64); - if ((flags & Defines.SND_OFFSET) != 0) - MSG.WriteByte(SV_INIT.sv.multicast, timeofs * 1000); + if ((flags & Defines.SND_VOLUME) != 0) + MSG.WriteByte(SV_INIT.sv.multicast, volume * 255); + if ((flags & Defines.SND_ATTENUATION) != 0) + MSG.WriteByte(SV_INIT.sv.multicast, attenuation * 64); + if ((flags & Defines.SND_OFFSET) != 0) + MSG.WriteByte(SV_INIT.sv.multicast, timeofs * 1000); - if ((flags & Defines.SND_ENT) != 0) - MSG.WriteShort(SV_INIT.sv.multicast, sendchan); + if ((flags & Defines.SND_ENT) != 0) + MSG.WriteShort(SV_INIT.sv.multicast, sendchan); - if ((flags & Defines.SND_POS) != 0) - MSG.WritePos(SV_INIT.sv.multicast, origin); + if ((flags & Defines.SND_POS) != 0) + MSG.WritePos(SV_INIT.sv.multicast, origin); - // if the sound doesn't attenuate,send it to everyone - // (global radio chatter, voiceovers, etc) - if (attenuation == Defines.ATTN_NONE) - use_phs = false; + // if the sound doesn't attenuate,send it to everyone + // (global radio chatter, voiceovers, etc) + if (attenuation == Defines.ATTN_NONE) + use_phs = false; - if ((channel & Defines.CHAN_RELIABLE) != 0) { - if (use_phs) - SV_Multicast(origin, Defines.MULTICAST_PHS_R); - else - SV_Multicast(origin, Defines.MULTICAST_ALL_R); - } - else { - if (use_phs) - SV_Multicast(origin, Defines.MULTICAST_PHS); - else - SV_Multicast(origin, Defines.MULTICAST_ALL); - } - } - /* - =============================================================================== - - FRAME UPDATES - - =============================================================================== - */ + if ((channel & Defines.CHAN_RELIABLE) != 0) { + if (use_phs) + SV_Multicast(origin, Defines.MULTICAST_PHS_R); + else + SV_Multicast(origin, Defines.MULTICAST_ALL_R); + } + else { + if (use_phs) + SV_Multicast(origin, Defines.MULTICAST_PHS); + else + SV_Multicast(origin, Defines.MULTICAST_ALL); + } + } + /* + =============================================================================== + + FRAME UPDATES + + =============================================================================== + */ - private static final sizebuf_t msg = new sizebuf_t(); - /* - ======================= - SV_SendClientDatagram - ======================= - */ - public static boolean SV_SendClientDatagram(client_t client) { - //byte msg_buf[] = new byte[Defines.MAX_MSGLEN]; + private static final sizebuf_t msg = new sizebuf_t(); + /* + ======================= + SV_SendClientDatagram + ======================= + */ + public static boolean SV_SendClientDatagram(client_t client) { + //byte msg_buf[] = new byte[Defines.MAX_MSGLEN]; - SV_ENTS.SV_BuildClientFrame(client); + SV_ENTS.SV_BuildClientFrame(client); - SZ.Init(msg, msgbuf, msgbuf.length); - msg.allowoverflow = true; + SZ.Init(msg, msgbuf, msgbuf.length); + msg.allowoverflow = true; - // send over all the relevant entity_state_t - // and the player_state_t - SV_ENTS.SV_WriteFrameToClient(client, msg); + // send over all the relevant entity_state_t + // and the player_state_t + SV_ENTS.SV_WriteFrameToClient(client, msg); - // copy the accumulated multicast datagram - // for this client out to the message - // it is necessary for this to be after the WriteEntities - // so that entity references will be current - if (client.datagram.overflowed) - Com.Printf("WARNING: datagram overflowed for " + client.name + "\n"); - else - SZ.Write(msg, client.datagram.data, client.datagram.cursize); - SZ.Clear(client.datagram); + // copy the accumulated multicast datagram + // for this client out to the message + // it is necessary for this to be after the WriteEntities + // so that entity references will be current + if (client.datagram.overflowed) + Com.Printf("WARNING: datagram overflowed for " + client.name + "\n"); + else + SZ.Write(msg, client.datagram.data, client.datagram.cursize); + SZ.Clear(client.datagram); - if (msg.overflowed) { // must have room left for the packet header - Com.Printf("WARNING: msg overflowed for " + client.name + "\n"); - SZ.Clear(msg); - } + if (msg.overflowed) { // must have room left for the packet header + Com.Printf("WARNING: msg overflowed for " + client.name + "\n"); + SZ.Clear(msg); + } - // send the datagram - Netchan.Transmit(client.netchan, msg.cursize, msg.data); + // send the datagram + Netchan.Transmit(client.netchan, msg.cursize, msg.data); - // record the size for rate estimation - client.message_size[SV_INIT.sv.framenum % Defines.RATE_MESSAGES] = msg.cursize; + // record the size for rate estimation + client.message_size[SV_INIT.sv.framenum % Defines.RATE_MESSAGES] = msg.cursize; - return true; - } - /* - ================== - SV_DemoCompleted - ================== - */ - public static void SV_DemoCompleted() { - if (SV_INIT.sv.demofile != null) { - try { - SV_INIT.sv.demofile.close(); - } - catch (IOException e) { - Com.Printf("IOError closing d9emo fiele:" + e); - } - SV_INIT.sv.demofile = null; - } - SV_USER.SV_Nextserver(); - } - /* - ======================= - SV_RateDrop - - Returns true if the client is over its current - bandwidth estimation and should not be sent another packet - ======================= - */ - public static boolean SV_RateDrop(client_t c) { - int total; - int i; + return true; + } + /* + ================== + SV_DemoCompleted + ================== + */ + public static void SV_DemoCompleted() { + if (SV_INIT.sv.demofile != null) { + try { + SV_INIT.sv.demofile.close(); + } + catch (IOException e) { + Com.Printf("IOError closing d9emo fiele:" + e); + } + SV_INIT.sv.demofile = null; + } + SV_USER.SV_Nextserver(); + } + /* + ======================= + SV_RateDrop + + Returns true if the client is over its current + bandwidth estimation and should not be sent another packet + ======================= + */ + public static boolean SV_RateDrop(client_t c) { + int total; + int i; - // never drop over the loopback - if (c.netchan.remote_address.type == Defines.NA_LOOPBACK) - return false; + // never drop over the loopback + if (c.netchan.remote_address.type == Defines.NA_LOOPBACK) + return false; - total = 0; + total = 0; - for (i = 0; i < Defines.RATE_MESSAGES; i++) { - total += c.message_size[i]; - } + for (i = 0; i < Defines.RATE_MESSAGES; i++) { + total += c.message_size[i]; + } - if (total > c.rate) { - c.surpressCount++; - c.message_size[SV_INIT.sv.framenum % Defines.RATE_MESSAGES] = 0; - return true; - } + if (total > c.rate) { + c.surpressCount++; + c.message_size[SV_INIT.sv.framenum % Defines.RATE_MESSAGES] = 0; + return true; + } - return false; - } + return false; + } - private static final byte msgbuf[] = new byte[Defines.MAX_MSGLEN]; - private static final byte[] NULLBYTE = {0}; - /* - ======================= - SV_SendClientMessages - ======================= - */ - public static void SV_SendClientMessages() { - int i; - client_t c; - int msglen; - int r; + private static final byte msgbuf[] = new byte[Defines.MAX_MSGLEN]; + private static final byte[] NULLBYTE = {0}; + /* + ======================= + SV_SendClientMessages + ======================= + */ + public static void SV_SendClientMessages() { + int i; + client_t c; + int msglen; + int r; - msglen = 0; + msglen = 0; - // read the next demo message if needed - if (SV_INIT.sv.state == Defines.ss_demo && SV_INIT.sv.demofile != null) { - if (SV_MAIN.sv_paused.value != 0) - msglen = 0; - else { - // get the next message - //r = fread (&msglen, 4, 1, sv.demofile); - try { - msglen = EndianHandler.swapInt(SV_INIT.sv.demofile.readInt()); - } - catch (Exception e) { - SV_DemoCompleted(); - return; - } + // read the next demo message if needed + if (SV_INIT.sv.state == Defines.ss_demo && SV_INIT.sv.demofile != null) { + if (SV_MAIN.sv_paused.value != 0) + msglen = 0; + else { + // get the next message + //r = fread (&msglen, 4, 1, sv.demofile); + try { + msglen = EndianHandler.swapInt(SV_INIT.sv.demofile.readInt()); + } + catch (Exception e) { + SV_DemoCompleted(); + return; + } - //msglen = LittleLong (msglen); - if (msglen == -1) { - SV_DemoCompleted(); - return; - } - if (msglen > Defines.MAX_MSGLEN) - Com.Error(Defines.ERR_DROP, "SV_SendClientMessages: msglen > MAX_MSGLEN"); + //msglen = LittleLong (msglen); + if (msglen == -1) { + SV_DemoCompleted(); + return; + } + if (msglen > Defines.MAX_MSGLEN) + Com.Error(Defines.ERR_DROP, "SV_SendClientMessages: msglen > MAX_MSGLEN"); - //r = fread (msgbuf, msglen, 1, sv.demofile); - r = 0; - try { - r = SV_INIT.sv.demofile.read(msgbuf, 0, msglen); - } - catch (IOException e1) { - Com.Printf("IOError: reading demo file, " + e1); - } - if (r != msglen) { - SV_DemoCompleted(); - return; - } - } - } + //r = fread (msgbuf, msglen, 1, sv.demofile); + r = 0; + try { + r = SV_INIT.sv.demofile.read(msgbuf, 0, msglen); + } + catch (IOException e1) { + Com.Printf("IOError: reading demo file, " + e1); + } + if (r != msglen) { + SV_DemoCompleted(); + return; + } + } + } - // send a message to each connected client - for (i = 0; i < SV_MAIN.maxclients.value; i++) { - c = SV_INIT.svs.clients[i]; + // send a message to each connected client + for (i = 0; i < SV_MAIN.maxclients.value; i++) { + c = SV_INIT.svs.clients[i]; - if (c.state == 0) - continue; - // if the reliable message overflowed, - // drop the client - if (c.netchan.message.overflowed) { - SZ.Clear(c.netchan.message); - SZ.Clear(c.datagram); - SV_BroadcastPrintf(Defines.PRINT_HIGH, c.name + " overflowed\n"); - SV_MAIN.SV_DropClient(c); - } + if (c.state == 0) + continue; + // if the reliable message overflowed, + // drop the client + if (c.netchan.message.overflowed) { + SZ.Clear(c.netchan.message); + SZ.Clear(c.datagram); + SV_BroadcastPrintf(Defines.PRINT_HIGH, c.name + " overflowed\n"); + SV_MAIN.SV_DropClient(c); + } - if (SV_INIT.sv.state == Defines.ss_cinematic - || SV_INIT.sv.state == Defines.ss_demo - || SV_INIT.sv.state == Defines.ss_pic) - Netchan.Transmit(c.netchan, msglen, msgbuf); - else if (c.state == Defines.cs_spawned) { - // don't overrun bandwidth - if (SV_RateDrop(c)) - continue; + if (SV_INIT.sv.state == Defines.ss_cinematic + || SV_INIT.sv.state == Defines.ss_demo + || SV_INIT.sv.state == Defines.ss_pic) + Netchan.Transmit(c.netchan, msglen, msgbuf); + else if (c.state == Defines.cs_spawned) { + // don't overrun bandwidth + if (SV_RateDrop(c)) + continue; - SV_SendClientDatagram(c); - } - else { - // just update reliable if needed - if (c.netchan.message.cursize != 0 || Globals.curtime - c.netchan.last_sent > 1000) - Netchan.Transmit(c.netchan, 0, NULLBYTE); - } - } - } + SV_SendClientDatagram(c); + } + else { + // just update reliable if needed + if (c.netchan.message.cursize != 0 || Globals.curtime - c.netchan.last_sent > 1000) + Netchan.Transmit(c.netchan, 0, NULLBYTE); + } + } + } } diff --git a/src/main/java/lwjake2/server/SV_USER.java b/src/main/java/lwjake2/server/SV_USER.java index a912807..f66a7d9 100644 --- a/src/main/java/lwjake2/server/SV_USER.java +++ b/src/main/java/lwjake2/server/SV_USER.java @@ -378,8 +378,8 @@ public class SV_USER { // rst: this handles loading errors, no message yet visible if (SV_MAIN.sv_client.download == null) - { - return; + { + return; } SV_MAIN.sv_client.downloadsize = SV_MAIN.sv_client.download.length; @@ -391,7 +391,7 @@ public class SV_USER { if (SV_MAIN.sv_client.download == null // special check for maps, if it // came from a pak file, don't // allow - // download ZOID + // download ZOID || (name.startsWith("maps/") && fileSystem.getFileFromPak() != 0)) { Com.DPrintf("Couldn't download " + name + " to " + SV_MAIN.sv_client.name + "\n"); @@ -420,7 +420,7 @@ public class SV_USER { * ================= */ public static void SV_Disconnect_f() { - // SV_EndRedirect (); + // SV_EndRedirect (); SV_MAIN.SV_DropClient(SV_MAIN.sv_client); } @@ -483,7 +483,7 @@ public class SV_USER { Cmd.TokenizeString(s.toCharArray(), true); SV_USER.sv_player = SV_MAIN.sv_client.edict; - // SV_BeginRedirect (RD_CLIENT); + // SV_BeginRedirect (RD_CLIENT); int i = 0; for (; i < SV_USER.ucmds.length; i++) { @@ -497,7 +497,7 @@ public class SV_USER { if (i == SV_USER.ucmds.length && SV_INIT.sv.state == Defines.ss_game) Cmd.ClientCommand(SV_USER.sv_player); - // SV_EndRedirect (); + // SV_EndRedirect (); } /* @@ -620,7 +620,7 @@ public class SV_USER { //if (net_drop > 2) - // Com.Printf ("drop %i\n", net_drop); + // Com.Printf ("drop %i\n", net_drop); while (net_drop > 2) { SV_ClientThink(cl, cl.lastcmd); diff --git a/src/main/java/lwjake2/server/areanode_t.java b/src/main/java/lwjake2/server/areanode_t.java index 9e9670c..cf1edca 100644 --- a/src/main/java/lwjake2/server/areanode_t.java +++ b/src/main/java/lwjake2/server/areanode_t.java @@ -21,13 +21,13 @@ package lwjake2.server; import lwjake2.game.link_t; public class areanode_t { - int axis; // -1 = leaf node - float dist; - areanode_t children[] = new areanode_t[2]; - link_t trigger_edicts = new link_t(this); - link_t solid_edicts = new link_t(this); - - // used for debugging - float mins_rst[] = {0,0,0}; - float maxs_rst[] = {0,0,0}; + int axis; // -1 = leaf node + float dist; + areanode_t children[] = new areanode_t[2]; + link_t trigger_edicts = new link_t(this); + link_t solid_edicts = new link_t(this); + + // used for debugging + float mins_rst[] = {0,0,0}; + float maxs_rst[] = {0,0,0}; } diff --git a/src/main/java/lwjake2/server/challenge_t.java b/src/main/java/lwjake2/server/challenge_t.java index ec62651..2614b0c 100644 --- a/src/main/java/lwjake2/server/challenge_t.java +++ b/src/main/java/lwjake2/server/challenge_t.java @@ -21,8 +21,8 @@ package lwjake2.server; import lwjake2.qcommon.netadr_t; public class challenge_t { - //mem - netadr_t adr = new netadr_t(); - int challenge; - int time; + //mem + netadr_t adr = new netadr_t(); + int challenge; + int time; } diff --git a/src/main/java/lwjake2/server/client_frame_t.java b/src/main/java/lwjake2/server/client_frame_t.java index 413fb02..4171785 100644 --- a/src/main/java/lwjake2/server/client_frame_t.java +++ b/src/main/java/lwjake2/server/client_frame_t.java @@ -23,10 +23,10 @@ import lwjake2.game.player_state_t; public class client_frame_t { - int areabytes; - byte areabits[] = new byte[Defines.MAX_MAP_AREAS/8]; // portalarea visibility bits - player_state_t ps = new player_state_t(); - int num_entities; - int first_entity; // into the circular sv_packet_entities[] - int senttime; // for ping calculations + int areabytes; + byte areabits[] = new byte[Defines.MAX_MAP_AREAS/8]; // portalarea visibility bits + player_state_t ps = new player_state_t(); + int num_entities; + int first_entity; // into the circular sv_packet_entities[] + int senttime; // for ping calculations } diff --git a/src/main/java/lwjake2/server/client_t.java b/src/main/java/lwjake2/server/client_t.java index 112878d..9c7acbe 100644 --- a/src/main/java/lwjake2/server/client_t.java +++ b/src/main/java/lwjake2/server/client_t.java @@ -26,58 +26,58 @@ import lwjake2.qcommon.sizebuf_t; public class client_t { - public client_t() { - for (int n = 0; n < Defines.UPDATE_BACKUP; n++) { - frames[n] = new client_frame_t(); - } - } + public client_t() { + for (int n = 0; n < Defines.UPDATE_BACKUP; n++) { + frames[n] = new client_frame_t(); + } + } - public static final int LATENCY_COUNTS = 16; - public static final int RATE_MESSAGES = 10; + public static final int LATENCY_COUNTS = 16; + public static final int RATE_MESSAGES = 10; - int state; + int state; - String userinfo = ""; + String userinfo = ""; - int lastframe; // for delta compression - usercmd_t lastcmd = new usercmd_t(); // for filling in big drops + int lastframe; // for delta compression + usercmd_t lastcmd = new usercmd_t(); // for filling in big drops - int commandMsec; // every seconds this is reset, if user - // commands exhaust it, assume time cheating + int commandMsec; // every seconds this is reset, if user + // commands exhaust it, assume time cheating - int frame_latency[] = new int[LATENCY_COUNTS]; - int ping; + int frame_latency[] = new int[LATENCY_COUNTS]; + int ping; - int message_size[] = new int[RATE_MESSAGES]; // used to rate drop packets - int rate; - int surpressCount; // number of messages rate supressed + int message_size[] = new int[RATE_MESSAGES]; // used to rate drop packets + int rate; + int surpressCount; // number of messages rate supressed - // pointer - edict_t edict; // EDICT_NUM(clientnum+1) + // pointer + edict_t edict; // EDICT_NUM(clientnum+1) - //char name[32]; // extracted from userinfo, high bits masked - String name = ""; // extracted from userinfo, high bits masked + //char name[32]; // extracted from userinfo, high bits masked + String name = ""; // extracted from userinfo, high bits masked - int messagelevel; // for filtering printed messages + int messagelevel; // for filtering printed messages - // The datagram is written to by sound calls, prints, temp ents, etc. - // It can be harmlessly overflowed. - sizebuf_t datagram = new sizebuf_t(); - byte datagram_buf[] = new byte[Defines.MAX_MSGLEN]; + // The datagram is written to by sound calls, prints, temp ents, etc. + // It can be harmlessly overflowed. + sizebuf_t datagram = new sizebuf_t(); + byte datagram_buf[] = new byte[Defines.MAX_MSGLEN]; - client_frame_t frames[] = new client_frame_t[Defines.UPDATE_BACKUP]; // updates can be delta'd from here + client_frame_t frames[] = new client_frame_t[Defines.UPDATE_BACKUP]; // updates can be delta'd from here - byte download[]; // file being downloaded - int downloadsize; // total bytes (can't use EOF because of paks) - int downloadcount; // bytes sent + byte download[]; // file being downloaded + int downloadsize; // total bytes (can't use EOF because of paks) + int downloadcount; // bytes sent - int lastmessage; // sv.framenum when packet was last received - int lastconnect; + int lastmessage; // sv.framenum when packet was last received + int lastconnect; - int challenge; // challenge of this user, randomly generated + int challenge; // challenge of this user, randomly generated - netchan_t netchan = new netchan_t(); + netchan_t netchan = new netchan_t(); - //this was introduced by rst, since java can't calculate the index out of the address. - int serverindex; + //this was introduced by rst, since java can't calculate the index out of the address. + int serverindex; } diff --git a/src/main/java/lwjake2/server/moveclip_t.java b/src/main/java/lwjake2/server/moveclip_t.java index 5af2f04..1cbe722 100644 --- a/src/main/java/lwjake2/server/moveclip_t.java +++ b/src/main/java/lwjake2/server/moveclip_t.java @@ -24,25 +24,25 @@ import lwjake2.util.Math3D; public class moveclip_t { - float [] boxmins={0,0,0}, boxmaxs={0,0,0};// enclose the test object along entire move - float [] mins, maxs; // size of the moving object - float [] mins2={0,0,0}, maxs2={0,0,0}; // size when clipping against mosnters - float [] start, end; - // mem - trace_t trace = new trace_t(); - edict_t passedict; - int contentmask; - - public void clear() { - Math3D.VectorClear(boxmins); - Math3D.VectorClear(boxmaxs); - Math3D.VectorClear(mins); - Math3D.VectorClear(maxs); - Math3D.VectorClear(mins2); - Math3D.VectorClear(maxs2); - start = end = null; - trace.clear(); - passedict = null; - contentmask = 0; - } + float [] boxmins={0,0,0}, boxmaxs={0,0,0};// enclose the test object along entire move + float [] mins, maxs; // size of the moving object + float [] mins2={0,0,0}, maxs2={0,0,0}; // size when clipping against mosnters + float [] start, end; + // mem + trace_t trace = new trace_t(); + edict_t passedict; + int contentmask; + + public void clear() { + Math3D.VectorClear(boxmins); + Math3D.VectorClear(boxmaxs); + Math3D.VectorClear(mins); + Math3D.VectorClear(maxs); + Math3D.VectorClear(mins2); + Math3D.VectorClear(maxs2); + start = end = null; + trace.clear(); + passedict = null; + contentmask = 0; + } } diff --git a/src/main/java/lwjake2/sound/DummyDriver.java b/src/main/java/lwjake2/sound/DummyDriver.java index fdba300..f8a1c32 100644 --- a/src/main/java/lwjake2/sound/DummyDriver.java +++ b/src/main/java/lwjake2/sound/DummyDriver.java @@ -27,82 +27,82 @@ import java.nio.ByteBuffer; */ public final class DummyDriver implements Sound { - static { - S.register(new DummyDriver()); - }; - - private DummyDriver() { - } + static { + S.register(new DummyDriver()); + }; + + private DummyDriver() { + } - /* (non-Javadoc) - * @see jake2.sound.Sound#Init() - */ - public boolean Init() { - return true; - } + /* (non-Javadoc) + * @see jake2.sound.Sound#Init() + */ + public boolean Init() { + return true; + } - /* (non-Javadoc) - * @see jake2.sound.Sound#Shutdown() - */ - public void Shutdown() { - } + /* (non-Javadoc) + * @see jake2.sound.Sound#Shutdown() + */ + public void Shutdown() { + } - /* (non-Javadoc) - * @see jake2.sound.Sound#BeginRegistration() - */ - public void BeginRegistration() { - } + /* (non-Javadoc) + * @see jake2.sound.Sound#BeginRegistration() + */ + public void BeginRegistration() { + } - /* (non-Javadoc) - * @see jake2.sound.Sound#RegisterSound(java.lang.String) - */ - public sfx_t RegisterSound(String sample) { - return null; - } + /* (non-Javadoc) + * @see jake2.sound.Sound#RegisterSound(java.lang.String) + */ + public sfx_t RegisterSound(String sample) { + return null; + } - /* (non-Javadoc) - * @see jake2.sound.Sound#EndRegistration() - */ - public void EndRegistration() { - } + /* (non-Javadoc) + * @see jake2.sound.Sound#EndRegistration() + */ + public void EndRegistration() { + } - /* (non-Javadoc) - * @see jake2.sound.Sound#StartLocalSound(java.lang.String) - */ - public void StartLocalSound(String sound) { - } + /* (non-Javadoc) + * @see jake2.sound.Sound#StartLocalSound(java.lang.String) + */ + public void StartLocalSound(String sound) { + } - /* (non-Javadoc) - * @see jake2.sound.Sound#StartSound(float[], int, int, jake2.sound.sfx_t, float, float, float) - */ - public void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) { - } + /* (non-Javadoc) + * @see jake2.sound.Sound#StartSound(float[], int, int, jake2.sound.sfx_t, float, float, float) + */ + public void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) { + } - /* (non-Javadoc) - * @see jake2.sound.Sound#Update(float[], float[], float[], float[]) - */ - public void Update(float[] origin, float[] forward, float[] right, float[] up) { - } + /* (non-Javadoc) + * @see jake2.sound.Sound#Update(float[], float[], float[], float[]) + */ + public void Update(float[] origin, float[] forward, float[] right, float[] up) { + } - /* (non-Javadoc) - * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[]) - */ - public void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) { - } + /* (non-Javadoc) + * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[]) + */ + public void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) { + } public void disableStreaming() { } /* (non-Javadoc) - * @see jake2.sound.Sound#StopAllSounds() - */ - public void StopAllSounds() { - } + * @see jake2.sound.Sound#StopAllSounds() + */ + public void StopAllSounds() { + } - /* (non-Javadoc) - * @see jake2.sound.Sound#getName() - */ - public String getName() { - return "dummy"; - } + /* (non-Javadoc) + * @see jake2.sound.Sound#getName() + */ + public String getName() { + return "dummy"; + } } diff --git a/src/main/java/lwjake2/sound/S.java b/src/main/java/lwjake2/sound/S.java index 819766f..7e2585f 100644 --- a/src/main/java/lwjake2/sound/S.java +++ b/src/main/java/lwjake2/sound/S.java @@ -32,190 +32,190 @@ import java.util.Vector; */ @Slf4j public class S { - static Sound impl; - static cvar_t s_impl; - - static Vector drivers = new Vector(1); - - /** - * Searches for and initializes all known sound drivers. - */ - static { - // dummy driver (no sound) - try { - Class.forName("lwjake2.sound.DummyDriver"); - // initialize impl with the default value - // this is necessary for dedicated mode - useDriver("dummy"); - } catch (Throwable e) { - Com.DPrintf("could not init dummy sound driver class."); - } - - try { - Class.forName("org.lwjgl.openal.AL"); - Class.forName("lwjake2.sound.lwjgl.LWJGLSoundImpl"); - } catch (Throwable e) { - // ignore the lwjgl driver if runtime not in classpath - Com.DPrintf("could not init lwjgl sound driver class."); - } - }; - - /** - * Registers a new Sound Implementor. - */ - public static void register(Sound driver) { - if (driver == null) { - throw new IllegalArgumentException("Sound implementation can't be null"); - } - if (!drivers.contains(driver)) { - drivers.add(driver); - } - } - - /** - * Switches to the specific sound driver. - */ - public static void useDriver(String driverName) { - Sound driver = null; - int count = drivers.size(); - for (int i = 0; i < count; i++) { - driver = drivers.get(i); - if (driver.getName().equals(driverName)) { - impl = driver; - return; - } - } - // if driver not found use dummy - impl = drivers.lastElement(); - } - - /** - * Initializes the sound module. - */ - public static void Init() { - - log.info("------- sound initialization -------"); - - cvar_t cv = Cvar.Get("s_initsound", "1", 0); - if (cv.value == 0.0f) { - log.info("not initializing."); - useDriver("dummy"); - return; - } - - // set the last registered driver as default - String defaultDriver = "dummy"; - if (drivers.size() > 1){ - defaultDriver = (drivers.lastElement()).getName(); - } - - s_impl = Cvar.Get("s_impl", defaultDriver, Defines.CVAR_ARCHIVE); - useDriver(s_impl.string); - - if (impl.Init()) { - // driver ok - Cvar.Set("s_impl", impl.getName()); - } else { - // fallback - useDriver("dummy"); - } - - log.info("------- use sound driver \"{}\" -------", impl.getName()); - StopAllSounds(); - } - - public static void Shutdown() { - impl.Shutdown(); - } - - /** - * Called before the sounds are to be loaded and registered. - */ - public static void BeginRegistration() { - impl.BeginRegistration(); - } - - /** - * Registers and loads a sound. - */ - public static sfx_t RegisterSound(String sample) { - return impl.RegisterSound(sample); - } - - /** - * Called after all sounds are registered and loaded. - */ - public static void EndRegistration() { - impl.EndRegistration(); - } - - /** - * Starts a local sound. - */ - public static void StartLocalSound(String sound) { - impl.StartLocalSound(sound); - } - - /** - * StartSound - Validates the parms and ques the sound up - * if pos is NULL, the sound will be dynamically sourced from the entity - * Entchannel 0 will never override a playing sound - */ - public static void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) { - impl.StartSound(origin, entnum, entchannel, sfx, fvol, attenuation, timeofs); - } - - /** - * Updates the sound renderer according to the changes in the environment, - * called once each time through the main loop. - */ - public static void Update(float[] origin, float[] forward, float[] right, float[] up) { - impl.Update(origin, forward, right, up); - } - - /** - * Cinematic streaming and voice over network. - */ - public static void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) { - impl.RawSamples(samples, rate, width, channels, data); - } + static Sound impl; + static cvar_t s_impl; - /** - * Switches off the sound streaming. - */ + static Vector drivers = new Vector(1); + + /** + * Searches for and initializes all known sound drivers. + */ + static { + // dummy driver (no sound) + try { + Class.forName("lwjake2.sound.DummyDriver"); + // initialize impl with the default value + // this is necessary for dedicated mode + useDriver("dummy"); + } catch (Throwable e) { + Com.DPrintf("could not init dummy sound driver class."); + } + + try { + Class.forName("org.lwjgl.openal.AL"); + Class.forName("lwjake2.sound.lwjgl.LWJGLSoundImpl"); + } catch (Throwable e) { + // ignore the lwjgl driver if runtime not in classpath + Com.DPrintf("could not init lwjgl sound driver class."); + } + }; + + /** + * Registers a new Sound Implementor. + */ + public static void register(Sound driver) { + if (driver == null) { + throw new IllegalArgumentException("Sound implementation can't be null"); + } + if (!drivers.contains(driver)) { + drivers.add(driver); + } + } + + /** + * Switches to the specific sound driver. + */ + public static void useDriver(String driverName) { + Sound driver = null; + int count = drivers.size(); + for (int i = 0; i < count; i++) { + driver = drivers.get(i); + if (driver.getName().equals(driverName)) { + impl = driver; + return; + } + } + // if driver not found use dummy + impl = drivers.lastElement(); + } + + /** + * Initializes the sound module. + */ + public static void Init() { + + log.info("------- sound initialization -------"); + + cvar_t cv = Cvar.Get("s_initsound", "1", 0); + if (cv.value == 0.0f) { + log.info("not initializing."); + useDriver("dummy"); + return; + } + + // set the last registered driver as default + String defaultDriver = "dummy"; + if (drivers.size() > 1){ + defaultDriver = (drivers.lastElement()).getName(); + } + + s_impl = Cvar.Get("s_impl", defaultDriver, Defines.CVAR_ARCHIVE); + useDriver(s_impl.string); + + if (impl.Init()) { + // driver ok + Cvar.Set("s_impl", impl.getName()); + } else { + // fallback + useDriver("dummy"); + } + + log.info("------- use sound driver \"{}\" -------", impl.getName()); + StopAllSounds(); + } + + public static void Shutdown() { + impl.Shutdown(); + } + + /** + * Called before the sounds are to be loaded and registered. + */ + public static void BeginRegistration() { + impl.BeginRegistration(); + } + + /** + * Registers and loads a sound. + */ + public static sfx_t RegisterSound(String sample) { + return impl.RegisterSound(sample); + } + + /** + * Called after all sounds are registered and loaded. + */ + public static void EndRegistration() { + impl.EndRegistration(); + } + + /** + * Starts a local sound. + */ + public static void StartLocalSound(String sound) { + impl.StartLocalSound(sound); + } + + /** + * StartSound - Validates the parms and ques the sound up + * if pos is NULL, the sound will be dynamically sourced from the entity + * Entchannel 0 will never override a playing sound + */ + public static void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) { + impl.StartSound(origin, entnum, entchannel, sfx, fvol, attenuation, timeofs); + } + + /** + * Updates the sound renderer according to the changes in the environment, + * called once each time through the main loop. + */ + public static void Update(float[] origin, float[] forward, float[] right, float[] up) { + impl.Update(origin, forward, right, up); + } + + /** + * Cinematic streaming and voice over network. + */ + public static void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) { + impl.RawSamples(samples, rate, width, channels, data); + } + + /** + * Switches off the sound streaming. + */ public static void disableStreaming() { impl.disableStreaming(); } - /** - * Stops all sounds. - */ - public static void StopAllSounds() { - impl.StopAllSounds(); - } - - public static String getDriverName() { - return impl.getName(); - } - - /** - * Returns a string array containing all sound driver names. - */ - public static String[] getDriverNames() { - String[] names = new String[drivers.size()]; - for (int i = 0; i < names.length; i++) { - names[i] = (drivers.get(i)).getName(); - } - return names; - } - - /** - * This is used, when resampling to this default sampling rate is activated - * in the wavloader. It is placed here that sound implementors can override - * this one day. - */ - public static int getDefaultSampleRate() - { - return 44100; - } + /** + * Stops all sounds. + */ + public static void StopAllSounds() { + impl.StopAllSounds(); + } + + public static String getDriverName() { + return impl.getName(); + } + + /** + * Returns a string array containing all sound driver names. + */ + public static String[] getDriverNames() { + String[] names = new String[drivers.size()]; + for (int i = 0; i < names.length; i++) { + names[i] = (drivers.get(i)).getName(); + } + return names; + } + + /** + * This is used, when resampling to this default sampling rate is activated + * in the wavloader. It is placed here that sound implementors can override + * this one day. + */ + public static int getDefaultSampleRate() + { + return 44100; + } } \ No newline at end of file diff --git a/src/main/java/lwjake2/sound/Sound.java b/src/main/java/lwjake2/sound/Sound.java index 3a6f01d..20c126b 100644 --- a/src/main/java/lwjake2/sound/Sound.java +++ b/src/main/java/lwjake2/sound/Sound.java @@ -31,74 +31,74 @@ public interface Sound { static final int MAX_SFX = Defines.MAX_SOUNDS * 2; static final int STREAM_QUEUE = 8; - - String getName(); - - boolean Init(); - void Shutdown(); - - /* - ===================== - S_BeginRegistration - ===================== - */ - void BeginRegistration(); - - /* - ===================== - S_RegisterSound - ===================== - */ - sfx_t RegisterSound(String sample); - - /* - ===================== - S_EndRegistration - ===================== - */ - void EndRegistration(); - - /* - ================== - S_StartLocalSound - ================== - */ - void StartLocalSound(String sound); - - /* - ==================== - S_StartSound + + String getName(); + + boolean Init(); + void Shutdown(); + + /* + ===================== + S_BeginRegistration + ===================== + */ + void BeginRegistration(); + + /* + ===================== + S_RegisterSound + ===================== + */ + sfx_t RegisterSound(String sample); + + /* + ===================== + S_EndRegistration + ===================== + */ + void EndRegistration(); + + /* + ================== + S_StartLocalSound + ================== + */ + void StartLocalSound(String sound); + + /* + ==================== + S_StartSound - Validates the parms and ques the sound up - if pos is NULL, the sound will be dynamically sourced from the entity - Entchannel 0 will never override a playing sound - ==================== - */ - void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs); + Validates the parms and ques the sound up + if pos is NULL, the sound will be dynamically sourced from the entity + Entchannel 0 will never override a playing sound + ==================== + */ + void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs); - /* - ============ - S_Update + /* + ============ + S_Update - Called once each time through the main loop - ============ - */ - void Update(float[] origin, float[] forward, float[] right, float[] up); - /* - ============ - S_RawSamples - - Cinematic streaming and voice over network - ============ - */ - void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data); + Called once each time through the main loop + ============ + */ + void Update(float[] origin, float[] forward, float[] right, float[] up); + /* + ============ + S_RawSamples + + Cinematic streaming and voice over network + ============ + */ + void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data); void disableStreaming(); - /* - ================== - S_StopAllSounds - ================== - */ - void StopAllSounds(); + /* + ================== + S_StopAllSounds + ================== + */ + void StopAllSounds(); } diff --git a/src/main/java/lwjake2/sound/WaveLoader.java b/src/main/java/lwjake2/sound/WaveLoader.java index cca5b1d..f257193 100644 --- a/src/main/java/lwjake2/sound/WaveLoader.java +++ b/src/main/java/lwjake2/sound/WaveLoader.java @@ -29,99 +29,99 @@ import lwjake2.qcommon.FileSystem; */ @Slf4j public class WaveLoader { - private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); - /** - * The ResampleSfx can squeeze and stretch samples to a default sample rate. - * Since Joal and lwjgl sound drivers support this, we don't need it and the samples - * can keep their original sample rate. Use this switch for reactivating resampling. - */ - private static boolean DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL = true; - - /** - * This is the maximum sample length in bytes which has to be replaced by - * a configurable variable. - */ - private static int maxsamplebytes = 2048 * 1024; - - /** - * Loads a sound from a wav file. - */ - public static sfxcache_t LoadSound(sfx_t s) { - if (s.name.charAt(0) == '*') - return null; + private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); + /** + * The ResampleSfx can squeeze and stretch samples to a default sample rate. + * Since Joal and lwjgl sound drivers support this, we don't need it and the samples + * can keep their original sample rate. Use this switch for reactivating resampling. + */ + private static boolean DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL = true; + + /** + * This is the maximum sample length in bytes which has to be replaced by + * a configurable variable. + */ + private static int maxsamplebytes = 2048 * 1024; + + /** + * Loads a sound from a wav file. + */ + public static sfxcache_t LoadSound(sfx_t s) { + if (s.name.charAt(0) == '*') + return null; - // see if still in memory - sfxcache_t sc = s.cache; - if (sc != null) - return sc; + // see if still in memory + sfxcache_t sc = s.cache; + if (sc != null) + return sc; - String name; - // load it in - if (s.truename != null) - name = s.truename; - else - name = s.name; + String name; + // load it in + if (s.truename != null) + name = s.truename; + else + name = s.name; - String namebuffer; - if (name.charAt(0) == '#') - namebuffer = name.substring(1); - else - namebuffer = "sound/" + name; + String namebuffer; + if (name.charAt(0) == '#') + namebuffer = name.substring(1); + else + namebuffer = "sound/" + name; - byte[] data = fileSystem.loadFile(namebuffer); + byte[] data = fileSystem.loadFile(namebuffer); - if (data == null) { - Com.DPrintf("Couldn't load " + namebuffer + "\n"); - return null; - } - - int size = data.length; + if (data == null) { + Com.DPrintf("Couldn't load " + namebuffer + "\n"); + return null; + } + + int size = data.length; - wavinfo_t info = GetWavinfo(s.name, data, size); + wavinfo_t info = GetWavinfo(s.name, data, size); - if (info.channels != 1) - { - Com.Printf(s.name + " is a stereo sample - ignoring\n"); - return null; - } + if (info.channels != 1) + { + Com.Printf(s.name + " is a stereo sample - ignoring\n"); + return null; + } - float stepscale; - if (DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL) - stepscale = 1; - else - stepscale = (float)info.rate / S.getDefaultSampleRate(); - - int len = (int) (info.samples / stepscale); - len = len * info.width * info.channels; + float stepscale; + if (DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL) + stepscale = 1; + else + stepscale = (float)info.rate / S.getDefaultSampleRate(); + + int len = (int) (info.samples / stepscale); + len = len * info.width * info.channels; - // TODO: handle max sample bytes with a cvar - if (len >= maxsamplebytes) - { - Com.Printf(s.name + " is too long: " + len + " bytes?! ignoring.\n"); - return null; - } + // TODO: handle max sample bytes with a cvar + if (len >= maxsamplebytes) + { + Com.Printf(s.name + " is too long: " + len + " bytes?! ignoring.\n"); + return null; + } - sc = s.cache = new sfxcache_t(len); - + sc = s.cache = new sfxcache_t(len); + sc.length = info.samples; sc.loopstart = info.loopstart; sc.speed = info.rate; sc.width = info.width; sc.stereo = info.channels; - ResampleSfx(s, sc.speed, sc.width, data, info.dataofs); - data = null; + ResampleSfx(s, sc.speed, sc.width, data, info.dataofs); + data = null; - return sc; - } + return sc; + } - /** - * Converts sample data with respect to the endianess and adjusts - * the sample rate of a loaded sample, see flag DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL. - */ - public static void ResampleSfx (sfx_t sfx, int inrate, int inwidth, byte data[], int offset) - { + /** + * Converts sample data with respect to the endianess and adjusts + * the sample rate of a loaded sample, see flag DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL. + */ + public static void ResampleSfx (sfx_t sfx, int inrate, int inwidth, byte data[], int offset) + { int outcount; int srcsample; int i; @@ -131,16 +131,16 @@ public class WaveLoader { sc = sfx.cache; if (sc == null) - return; + return; // again calculate the stretching factor. // this is usually 0.5, 1, or 2 float stepscale; if (DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL) - stepscale = 1; + stepscale = 1; else - stepscale = (float)inrate / S.getDefaultSampleRate(); + stepscale = (float)inrate / S.getDefaultSampleRate(); outcount = (int) (sc.length/stepscale); sc.length = outcount; @@ -149,7 +149,7 @@ public class WaveLoader { // if resampled, sample has now the default sample rate if (DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL == false) - sc.speed = S.getDefaultSampleRate(); + sc.speed = S.getDefaultSampleRate(); sc.width = inwidth; sc.stereo = 0; @@ -182,169 +182,169 @@ public class WaveLoader { } - static byte[] data_b; - static int data_p; - static int iff_end; - static int last_chunk; - static int iff_data; - static int iff_chunk_len; + static byte[] data_b; + static int data_p; + static int iff_end; + static int last_chunk; + static int iff_data; + static int iff_chunk_len; - static short GetLittleShort() { - int val = 0; - val = data_b[data_p] & 0xFF; - data_p++; - val |= ((data_b[data_p] & 0xFF) << 8); - data_p++; - return (short)val; - } + static short GetLittleShort() { + int val = 0; + val = data_b[data_p] & 0xFF; + data_p++; + val |= ((data_b[data_p] & 0xFF) << 8); + data_p++; + return (short)val; + } - static int GetLittleLong() { - int val = 0; - val = data_b[data_p] & 0xFF; - data_p++; - val |= ((data_b[data_p] & 0xFF) << 8); - data_p++; - val |= ((data_b[data_p] & 0xFF) << 16); - data_p++; - val |= ((data_b[data_p] & 0xFF) << 24); - data_p++; - return val; - } + static int GetLittleLong() { + int val = 0; + val = data_b[data_p] & 0xFF; + data_p++; + val |= ((data_b[data_p] & 0xFF) << 8); + data_p++; + val |= ((data_b[data_p] & 0xFF) << 16); + data_p++; + val |= ((data_b[data_p] & 0xFF) << 24); + data_p++; + return val; + } - static void FindNextChunk(String name) { - while (true) { - data_p = last_chunk; + static void FindNextChunk(String name) { + while (true) { + data_p = last_chunk; - if (data_p >= iff_end) { // didn't find the chunk - data_p = 0; - return; - } + if (data_p >= iff_end) { // didn't find the chunk + data_p = 0; + return; + } - data_p += 4; + data_p += 4; - iff_chunk_len = GetLittleLong(); - - if (iff_chunk_len < 0) { - data_p = 0; - return; - } - if (iff_chunk_len > 1024*1024) { - log.warn("Warning: FindNextChunk: length is past the 1 meg sanity limit"); - } - data_p -= 8; - last_chunk = data_p + 8 + ((iff_chunk_len + 1) & ~1); - String s = new String(data_b, data_p, 4); - if (s.equals(name)) - return; - } - } + iff_chunk_len = GetLittleLong(); + + if (iff_chunk_len < 0) { + data_p = 0; + return; + } + if (iff_chunk_len > 1024*1024) { + log.warn("Warning: FindNextChunk: length is past the 1 meg sanity limit"); + } + data_p -= 8; + last_chunk = data_p + 8 + ((iff_chunk_len + 1) & ~1); + String s = new String(data_b, data_p, 4); + if (s.equals(name)) + return; + } + } - static void FindChunk(String name) { - last_chunk = iff_data; - FindNextChunk(name); - } + static void FindChunk(String name) { + last_chunk = iff_data; + FindNextChunk(name); + } - /* - ============ - GetWavinfo - ============ - */ - static wavinfo_t GetWavinfo(String name, byte[] wav, int wavlength) { - wavinfo_t info = new wavinfo_t(); - int i; - int format; - int samples; + /* + ============ + GetWavinfo + ============ + */ + static wavinfo_t GetWavinfo(String name, byte[] wav, int wavlength) { + wavinfo_t info = new wavinfo_t(); + int i; + int format; + int samples; - if (wav == null) - return info; + if (wav == null) + return info; - iff_data = 0; - iff_end = wavlength; - data_b = wav; + iff_data = 0; + iff_end = wavlength; + data_b = wav; - // find "RIFF" chunk - FindChunk("RIFF"); - String s = new String(data_b, data_p + 8, 4); - if (!s.equals("WAVE")) { - Com.Printf("Missing RIFF/WAVE chunks\n"); - return info; - } + // find "RIFF" chunk + FindChunk("RIFF"); + String s = new String(data_b, data_p + 8, 4); + if (!s.equals("WAVE")) { + Com.Printf("Missing RIFF/WAVE chunks\n"); + return info; + } - // get "fmt " chunk - iff_data = data_p + 12; - // DumpChunks (); + // get "fmt " chunk + iff_data = data_p + 12; + // DumpChunks (); - FindChunk("fmt "); - if (data_p == 0) { - Com.Printf("Missing fmt chunk\n"); - return info; - } - data_p += 8; - format = GetLittleShort(); - if (format != 1) { - Com.Printf("Microsoft PCM format only\n"); - return info; - } + FindChunk("fmt "); + if (data_p == 0) { + Com.Printf("Missing fmt chunk\n"); + return info; + } + data_p += 8; + format = GetLittleShort(); + if (format != 1) { + Com.Printf("Microsoft PCM format only\n"); + return info; + } - info.channels = GetLittleShort(); - info.rate = GetLittleLong(); - data_p += 4 + 2; - info.width = GetLittleShort() / 8; + info.channels = GetLittleShort(); + info.rate = GetLittleLong(); + data_p += 4 + 2; + info.width = GetLittleShort() / 8; - // get cue chunk - FindChunk("cue "); - if (data_p != 0) { - data_p += 32; - info.loopstart = GetLittleLong(); - // Com_Printf("loopstart=%d\n", sfx->loopstart); + // get cue chunk + FindChunk("cue "); + if (data_p != 0) { + data_p += 32; + info.loopstart = GetLittleLong(); + // Com_Printf("loopstart=%d\n", sfx->loopstart); - // if the next chunk is a LIST chunk, look for a cue length marker - FindNextChunk("LIST"); - if (data_p != 0) { - if (data_b.length >= data_p + 32) { - s = new String(data_b, data_p + 28, 4); - if (s.equals("MARK")) { // this is not a proper parse, but - // it works with cooledit... - data_p += 24; - i = GetLittleLong(); // samples in loop - info.samples = info.loopstart + i; - // Com_Printf("looped length: %i\n", i); - } - } - } - } else - info.loopstart = -1; + // if the next chunk is a LIST chunk, look for a cue length marker + FindNextChunk("LIST"); + if (data_p != 0) { + if (data_b.length >= data_p + 32) { + s = new String(data_b, data_p + 28, 4); + if (s.equals("MARK")) { // this is not a proper parse, but + // it works with cooledit... + data_p += 24; + i = GetLittleLong(); // samples in loop + info.samples = info.loopstart + i; + // Com_Printf("looped length: %i\n", i); + } + } + } + } else + info.loopstart = -1; - // find data chunk - FindChunk("data"); - if (data_p == 0) { - Com.Printf("Missing data chunk\n"); - return info; - } + // find data chunk + FindChunk("data"); + if (data_p == 0) { + Com.Printf("Missing data chunk\n"); + return info; + } - data_p += 4; - samples = GetLittleLong() / info.width; + data_p += 4; + samples = GetLittleLong() / info.width; - if (info.samples != 0) { - if (samples < info.samples) - Com.Error(Defines.ERR_DROP, "Sound " + name + " has a bad loop length"); - } else { - info.samples = samples; - if (info.loopstart > 0) info.samples -= info.loopstart; - } - - info.dataofs = data_p; + if (info.samples != 0) { + if (samples < info.samples) + Com.Error(Defines.ERR_DROP, "Sound " + name + " has a bad loop length"); + } else { + info.samples = samples; + if (info.loopstart > 0) info.samples -= info.loopstart; + } + + info.dataofs = data_p; - return info; - } + return info; + } - static class wavinfo_t { - int rate; - int width; - int channels; - int loopstart; - int samples; - int dataofs; // chunk starts this many bytes from file start - } + static class wavinfo_t { + int rate; + int width; + int channels; + int loopstart; + int samples; + int dataofs; // chunk starts this many bytes from file start + } } diff --git a/src/main/java/lwjake2/sound/lwjgl/Channel.java b/src/main/java/lwjake2/sound/lwjgl/Channel.java index b135c23..6373921 100644 --- a/src/main/java/lwjake2/sound/lwjgl/Channel.java +++ b/src/main/java/lwjake2/sound/lwjgl/Channel.java @@ -47,101 +47,101 @@ import org.lwjgl.openal.EFX10; */ public class Channel { - final static int LISTENER = 0; - final static int FIXED = 1; - final static int DYNAMIC = 2; - final static int MAX_CHANNELS = 128; - - private static Channel[] channels = new Channel[MAX_CHANNELS]; - private static IntBuffer sources = Lib.newIntBuffer(MAX_CHANNELS); - // a reference of LWJGLSoundImpl.buffers - private static IntBuffer buffers; - private static Map looptable = new Hashtable(MAX_CHANNELS); + final static int LISTENER = 0; + final static int FIXED = 1; + final static int DYNAMIC = 2; + final static int MAX_CHANNELS = 128; + + private static Channel[] channels = new Channel[MAX_CHANNELS]; + private static IntBuffer sources = Lib.newIntBuffer(MAX_CHANNELS); + // a reference of LWJGLSoundImpl.buffers + private static IntBuffer buffers; + private static Map looptable = new Hashtable(MAX_CHANNELS); - private static int numChannels; + private static int numChannels; // stream handling private static boolean streamingEnabled = false; private static int streamQueue = 0; - - // sound attributes - private int type; - private int entnum; - private int entchannel; - private int bufferId; - private int sourceId; - private float volume; - private float rolloff; - private float[] origin = {0, 0, 0}; + + // sound attributes + private int type; + private int entnum; + private int entchannel; + private int bufferId; + private int sourceId; + private float volume; + private float rolloff; + private float[] origin = {0, 0, 0}; - // update flags - private boolean autosound; - private boolean active; - private boolean modified; - private boolean bufferChanged; - private boolean volumeChanged; + // update flags + private boolean autosound; + private boolean active; + private boolean modified; + private boolean bufferChanged; + private boolean volumeChanged; - private Channel(int sourceId) { - this.sourceId = sourceId; - clear(); - volumeChanged = false; - volume = 1.0f; - } + private Channel(int sourceId) { + this.sourceId = sourceId; + clear(); + volumeChanged = false; + volume = 1.0f; + } - private void clear() { - entnum = entchannel = bufferId = -1; - bufferChanged = false; - rolloff = 0; - autosound = false; - active = false; - modified = false; - } - - private static IntBuffer tmp = Lib.newIntBuffer(1); + private void clear() { + entnum = entchannel = bufferId = -1; + bufferChanged = false; + rolloff = 0; + autosound = false; + active = false; + modified = false; + } + + private static IntBuffer tmp = Lib.newIntBuffer(1); - static int init(IntBuffer buffers) { - Channel.buffers = buffers; - // create channels - int sourceId; - for (int i = 0; i < MAX_CHANNELS; i++) { - - AL10.alGenSources(tmp); - sourceId = tmp.get(0); - + static int init(IntBuffer buffers) { + Channel.buffers = buffers; + // create channels + int sourceId; + for (int i = 0; i < MAX_CHANNELS; i++) { + + AL10.alGenSources(tmp); + sourceId = tmp.get(0); + // can't generate more sources - if (sourceId <= 0) break; - - sources.put(i, sourceId); + if (sourceId <= 0) break; + + sources.put(i, sourceId); - channels[i] = new Channel(sourceId); - numChannels++; - - // set default values for AL sources - AL10.alSourcef (sourceId, AL10.AL_GAIN, 1.0f); - AL10.alSourcef (sourceId, AL10.AL_PITCH, 1.0f); - AL10.alSourcei (sourceId, AL10.AL_SOURCE_ABSOLUTE, AL10.AL_TRUE); - AL10.alSource3f(sourceId, AL10.AL_VELOCITY, 0, 0, 0); - AL10.alSourcei (sourceId, AL10.AL_LOOPING, AL10.AL_FALSE); - AL10.alSourcef (sourceId, AL10.AL_REFERENCE_DISTANCE, 200.0f); - AL10.alSourcef (sourceId, AL10.AL_MIN_GAIN, 0.0005f); - AL10.alSourcef (sourceId, AL10.AL_MAX_GAIN, 1.0f); - } - return numChannels; - } - - static void reset() { - for (int i = 0; i < numChannels; i++) { - AL10.alSourceStop(sources.get(i)); - AL10.alSourcei(sources.get(i), AL10.AL_BUFFER, 0); - channels[i].clear(); - } - } - - static void shutdown() { - AL10.alDeleteSources(sources); - numChannels = 0; - } - + channels[i] = new Channel(sourceId); + numChannels++; + + // set default values for AL sources + AL10.alSourcef (sourceId, AL10.AL_GAIN, 1.0f); + AL10.alSourcef (sourceId, AL10.AL_PITCH, 1.0f); + AL10.alSourcei (sourceId, AL10.AL_SOURCE_ABSOLUTE, AL10.AL_TRUE); + AL10.alSource3f(sourceId, AL10.AL_VELOCITY, 0, 0, 0); + AL10.alSourcei (sourceId, AL10.AL_LOOPING, AL10.AL_FALSE); + AL10.alSourcef (sourceId, AL10.AL_REFERENCE_DISTANCE, 200.0f); + AL10.alSourcef (sourceId, AL10.AL_MIN_GAIN, 0.0005f); + AL10.alSourcef (sourceId, AL10.AL_MAX_GAIN, 1.0f); + } + return numChannels; + } + + static void reset() { + for (int i = 0; i < numChannels; i++) { + AL10.alSourceStop(sources.get(i)); + AL10.alSourcei(sources.get(i), AL10.AL_BUFFER, 0); + channels[i].clear(); + } + } + + static void shutdown() { + AL10.alDeleteSources(sources); + numChannels = 0; + } + static void enableStreaming() { if (streamingEnabled) return; @@ -218,54 +218,54 @@ public class Channel { } } - static void addPlaySounds() { - while (Channel.assign(PlaySound.nextPlayableSound())); - } - - private static boolean assign(PlaySound ps) { - if (ps == null) return false; - Channel ch = null; - int i; - for (i = 0; i < numChannels; i++) { - ch = channels[i]; + static void addPlaySounds() { + while (Channel.assign(PlaySound.nextPlayableSound())); + } + + private static boolean assign(PlaySound ps) { + if (ps == null) return false; + Channel ch = null; + int i; + for (i = 0; i < numChannels; i++) { + ch = channels[i]; - if (ps.entchannel != 0 && ch.entnum == ps.entnum && ch.entchannel == ps.entchannel) { - // always override sound from same entity - if (ch.bufferId != ps.bufferId) { - AL10.alSourceStop(ch.sourceId); - } - break; - } + if (ps.entchannel != 0 && ch.entnum == ps.entnum && ch.entchannel == ps.entchannel) { + // always override sound from same entity + if (ch.bufferId != ps.bufferId) { + AL10.alSourceStop(ch.sourceId); + } + break; + } - // don't let monster sounds override player sounds - if ((ch.entnum == Globals.cl.playernum+1) && (ps.entnum != Globals.cl.playernum+1) && ch.bufferId != -1) - continue; + // don't let monster sounds override player sounds + if ((ch.entnum == Globals.cl.playernum+1) && (ps.entnum != Globals.cl.playernum+1) && ch.bufferId != -1) + continue; - // looking for a free AL source - if (!ch.active) { - break; - } - } - - if (i == numChannels) - return false; - - ch.type = ps.type; - if (ps.type == Channel.FIXED) - Math3D.VectorCopy(ps.origin, ch.origin); - ch.entnum = ps.entnum; - ch.entchannel = ps.entchannel; - ch.bufferChanged = (ch.bufferId != ps.bufferId); - ch.bufferId = ps.bufferId; - ch.rolloff = ps.attenuation * 2; - ch.volumeChanged = (ch.volume != ps.volume); - ch.volume = ps.volume; - ch.active = true; - ch.modified = true; - return true; - } - - private static Channel pickForLoop(int bufferId, float attenuation) { + // looking for a free AL source + if (!ch.active) { + break; + } + } + + if (i == numChannels) + return false; + + ch.type = ps.type; + if (ps.type == Channel.FIXED) + Math3D.VectorCopy(ps.origin, ch.origin); + ch.entnum = ps.entnum; + ch.entchannel = ps.entchannel; + ch.bufferChanged = (ch.bufferId != ps.bufferId); + ch.bufferId = ps.bufferId; + ch.rolloff = ps.attenuation * 2; + ch.volumeChanged = (ch.volume != ps.volume); + ch.volume = ps.volume; + ch.active = true; + ch.modified = true; + return true; + } + + private static Channel pickForLoop(int bufferId, float attenuation) { Channel ch; for (int i = 0; i < numChannels; i++) { ch = channels[i]; @@ -273,11 +273,11 @@ public class Channel { if (!ch.active) { ch.entnum = 0; ch.entchannel = 0; - ch.bufferChanged = (ch.bufferId != bufferId); + ch.bufferChanged = (ch.bufferId != bufferId); ch.bufferId = bufferId; - ch.volumeChanged = (ch.volume != 1.0f); - ch.volume = 1.0f; - ch.rolloff = attenuation * 2; + ch.volumeChanged = (ch.volume != 1.0f); + ch.volume = 1.0f; + ch.rolloff = attenuation * 2; ch.active = true; ch.modified = true; return ch; @@ -285,155 +285,155 @@ public class Channel { } return null; } - - private static FloatBuffer sourceOriginBuffer = Lib.newFloatBuffer(3); + + private static FloatBuffer sourceOriginBuffer = Lib.newFloatBuffer(3); - //stack variable - private static float[] entityOrigin = {0, 0, 0}; + //stack variable + private static float[] entityOrigin = {0, 0, 0}; - static void playAllSounds(FloatBuffer listenerOrigin, int currentEffectIndex, int currentFilterIndex) { - FloatBuffer sourceOrigin = sourceOriginBuffer; - Channel ch; - int sourceId; - int state; + static void playAllSounds(FloatBuffer listenerOrigin, int currentEffectIndex, int currentFilterIndex) { + FloatBuffer sourceOrigin = sourceOriginBuffer; + Channel ch; + int sourceId; + int state; - for (int i = 0; i < numChannels; i++) { - ch = channels[i]; - if (ch.active) { - sourceId = ch.sourceId; - switch (ch.type) { - case Channel.LISTENER: - sourceOrigin.put(0, listenerOrigin.get(0)); - sourceOrigin.put(1, listenerOrigin.get(1)); - sourceOrigin.put(2, listenerOrigin.get(2)); - break; - case Channel.DYNAMIC: - CL_ents.GetEntitySoundOrigin(ch.entnum, entityOrigin); - convertVector(entityOrigin, sourceOrigin); - break; - case Channel.FIXED: - convertVector(ch.origin, sourceOrigin); - break; - } + for (int i = 0; i < numChannels; i++) { + ch = channels[i]; + if (ch.active) { + sourceId = ch.sourceId; + switch (ch.type) { + case Channel.LISTENER: + sourceOrigin.put(0, listenerOrigin.get(0)); + sourceOrigin.put(1, listenerOrigin.get(1)); + sourceOrigin.put(2, listenerOrigin.get(2)); + break; + case Channel.DYNAMIC: + CL_ents.GetEntitySoundOrigin(ch.entnum, entityOrigin); + convertVector(entityOrigin, sourceOrigin); + break; + case Channel.FIXED: + convertVector(ch.origin, sourceOrigin); + break; + } - if (ch.modified) { - if (ch.bufferChanged) { - AL10.alSourcei(sourceId, AL10.AL_BUFFER, ch.bufferId); - } - if (ch.volumeChanged) { - AL10.alSourcef (sourceId, AL10.AL_GAIN, ch.volume); - } - AL10.alSourcef (sourceId, AL10.AL_ROLLOFF_FACTOR, ch.rolloff); - AL10.alSource3f(sourceId, AL10.AL_POSITION, sourceOrigin.get(), sourceOrigin.get(), sourceOrigin.get()); - AL11.alSource3i(sourceId, EFX10.AL_AUXILIARY_SEND_FILTER, currentEffectIndex, 0, EFX10.AL_FILTER_NULL); - AL10.alSourcei(sourceId, EFX10.AL_DIRECT_FILTER, currentFilterIndex); - AL10.alSourcePlay(sourceId); - sourceOrigin.rewind(); - ch.modified = false; - } else { - state = AL10.alGetSourcei(sourceId, AL10.AL_SOURCE_STATE); - if (state == AL10.AL_PLAYING) { - AL10.alSource3f(sourceId, AL10.AL_POSITION, sourceOrigin.get(), sourceOrigin.get(), sourceOrigin.get()); - sourceOrigin.rewind(); - } else { - ch.clear(); - } - } - ch.autosound = false; - } - } - } - - /* - * adddLoopSounds - * Entities with a ->sound field will generated looped sounds - * that are automatically started, stopped, and merged together - * as the entities are sent to the client - */ - static void addLoopSounds() { - - if ((Globals.cl_paused.value != 0.0f) || (Globals.cls.state != Globals.ca_active) || !Globals.cl.sound_prepped) { - removeUnusedLoopSounds(); - return; - } - - Channel ch; - sfx_t sfx; - sfxcache_t sc; - int num; - entity_state_t ent; - int key; - int sound = 0; + if (ch.modified) { + if (ch.bufferChanged) { + AL10.alSourcei(sourceId, AL10.AL_BUFFER, ch.bufferId); + } + if (ch.volumeChanged) { + AL10.alSourcef (sourceId, AL10.AL_GAIN, ch.volume); + } + AL10.alSourcef (sourceId, AL10.AL_ROLLOFF_FACTOR, ch.rolloff); + AL10.alSource3f(sourceId, AL10.AL_POSITION, sourceOrigin.get(), sourceOrigin.get(), sourceOrigin.get()); + AL11.alSource3i(sourceId, EFX10.AL_AUXILIARY_SEND_FILTER, currentEffectIndex, 0, EFX10.AL_FILTER_NULL); + AL10.alSourcei(sourceId, EFX10.AL_DIRECT_FILTER, currentFilterIndex); + AL10.alSourcePlay(sourceId); + sourceOrigin.rewind(); + ch.modified = false; + } else { + state = AL10.alGetSourcei(sourceId, AL10.AL_SOURCE_STATE); + if (state == AL10.AL_PLAYING) { + AL10.alSource3f(sourceId, AL10.AL_POSITION, sourceOrigin.get(), sourceOrigin.get(), sourceOrigin.get()); + sourceOrigin.rewind(); + } else { + ch.clear(); + } + } + ch.autosound = false; + } + } + } + + /* + * adddLoopSounds + * Entities with a ->sound field will generated looped sounds + * that are automatically started, stopped, and merged together + * as the entities are sent to the client + */ + static void addLoopSounds() { + + if ((Globals.cl_paused.value != 0.0f) || (Globals.cls.state != Globals.ca_active) || !Globals.cl.sound_prepped) { + removeUnusedLoopSounds(); + return; + } + + Channel ch; + sfx_t sfx; + sfxcache_t sc; + int num; + entity_state_t ent; + int key; + int sound = 0; - for (int i=0 ; i iter = looptable.values().iterator(); iter.hasNext();) { - ch = iter.next(); - if (!ch.autosound) { - AL10.alSourceStop(ch.sourceId); - AL10.alSourcei(ch.sourceId, AL10.AL_LOOPING, AL10.AL_FALSE); - iter.remove(); - ch.clear(); - } - } - } + } + + private static void removeUnusedLoopSounds() { + Channel ch; + // stop unused loopsounds + for (Iterator iter = looptable.values().iterator(); iter.hasNext();) { + ch = iter.next(); + if (!ch.autosound) { + AL10.alSourceStop(ch.sourceId); + AL10.alSourcei(ch.sourceId, AL10.AL_LOOPING, AL10.AL_FALSE); + iter.remove(); + ch.clear(); + } + } + } - static void convertVector(float[] from, FloatBuffer to) { - to.put(0, from[0]); - to.put(1, from[2]); - to.put(2, -from[1]); - } + static void convertVector(float[] from, FloatBuffer to) { + to.put(0, from[0]); + to.put(1, from[2]); + to.put(2, -from[1]); + } - static void convertOrientation(float[] forward, float[] up, FloatBuffer orientation) { - orientation.put(0, forward[0]); - orientation.put(1, forward[2]); - orientation.put(2, -forward[1]); - orientation.put(3, up[0]); - orientation.put(4, up[2]); - orientation.put(5, -up[1]); - } + static void convertOrientation(float[] forward, float[] up, FloatBuffer orientation) { + orientation.put(0, forward[0]); + orientation.put(1, forward[2]); + orientation.put(2, -forward[1]); + orientation.put(3, up[0]); + orientation.put(4, up[2]); + orientation.put(5, -up[1]); + } } diff --git a/src/main/java/lwjake2/sound/lwjgl/LWJGLSoundImpl.java b/src/main/java/lwjake2/sound/lwjgl/LWJGLSoundImpl.java index aee5a03..59bc6fb 100644 --- a/src/main/java/lwjake2/sound/lwjgl/LWJGLSoundImpl.java +++ b/src/main/java/lwjake2/sound/lwjgl/LWJGLSoundImpl.java @@ -55,14 +55,14 @@ import org.lwjgl.openal.OpenALException; */ @Slf4j public final class LWJGLSoundImpl implements Sound { - private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); - static { - S.register(new LWJGLSoundImpl()); - }; - - private cvar_t s_volume; - - // the last 4 buffers are used for cinematics streaming + private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); + static { + S.register(new LWJGLSoundImpl()); + }; + + private cvar_t s_volume; + + // the last 4 buffers are used for cinematics streaming private IntBuffer buffers = Lib.newIntBuffer(MAX_SFX + STREAM_QUEUE); /** EFX Variables */ @@ -70,437 +70,437 @@ public final class LWJGLSoundImpl implements Sound { private int currentFilterIndex; private EFXFilterLowPass underwaterFilter; - // singleton - private LWJGLSoundImpl() { - } + // singleton + private LWJGLSoundImpl() { + } - /* (non-Javadoc) - * @see jake2.sound.SoundImpl#Init() - */ - public boolean Init() { - - try { - initOpenAL(); - checkError(); - initOpenALExtensions(); - } catch (OpenALException e) { - log.error(e.getMessage()); - return false; - } catch (Exception e) { - Com.DPrintf(e.getMessage() + '\n'); - return false; - } - - // set the listerner (master) volume - s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE); - AL10.alGenBuffers(buffers); - int count = Channel.init(buffers); - log.info("... using {} channels", count); - AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED); - Cmd.AddCommand("play", this::Play); - Cmd.AddCommand("stopsound", this::StopAllSounds); - Cmd.AddCommand("soundlist", this::SoundList); - Cmd.AddCommand("soundinfo", this::SoundInfo_f); + /* (non-Javadoc) + * @see jake2.sound.SoundImpl#Init() + */ + public boolean Init() { + + try { + initOpenAL(); + checkError(); + initOpenALExtensions(); + } catch (OpenALException e) { + log.error(e.getMessage()); + return false; + } catch (Exception e) { + Com.DPrintf(e.getMessage() + '\n'); + return false; + } + + // set the listerner (master) volume + s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE); + AL10.alGenBuffers(buffers); + int count = Channel.init(buffers); + log.info("... using {} channels", count); + AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED); + Cmd.AddCommand("play", this::Play); + Cmd.AddCommand("stopsound", this::StopAllSounds); + Cmd.AddCommand("soundlist", this::SoundList); + Cmd.AddCommand("soundinfo", this::SoundInfo_f); - num_sfx = 0; + num_sfx = 0; - log.info("sound sampling rate: 44100Hz"); + log.info("sound sampling rate: 44100Hz"); - StopAllSounds(); - log.info("------------------------------------"); - return true; - } - - - private void initOpenAL() throws OpenALException - { - try { AL.create(); } catch (LWJGLException e) { throw new OpenALException(e); } - String deviceName = null; + StopAllSounds(); + log.info("------------------------------------"); + return true; + } + + + private void initOpenAL() throws OpenALException + { + try { AL.create(); } catch (LWJGLException e) { throw new OpenALException(e); } + String deviceName = null; - String os = System.getProperty("os.name"); - if (os.startsWith("Windows")) { - deviceName = "DirectSound3D"; - } - - String defaultSpecifier = ALC10.alcGetString(AL.getDevice(), ALC10.ALC_DEFAULT_DEVICE_SPECIFIER); + String os = System.getProperty("os.name"); + if (os.startsWith("Windows")) { + deviceName = "DirectSound3D"; + } + + String defaultSpecifier = ALC10.alcGetString(AL.getDevice(), ALC10.ALC_DEFAULT_DEVICE_SPECIFIER); - log.info("{} using {}", os, ((deviceName == null) ? defaultSpecifier : deviceName)); + log.info("{} using {}", os, ((deviceName == null) ? defaultSpecifier : deviceName)); - // Check for an error. - if (ALC10.alcGetError(AL.getDevice()) != ALC10.ALC_NO_ERROR) - { - Com.DPrintf("Error with SoundDevice"); - } - } - - /** Initializes OpenAL EFX effects. */ - private void initOpenALExtensions() - { - log.info("... using EFX effects:"); - underwaterFilter = new EFXFilterLowPass(); - underwaterFilter.setGain(1.0f); - underwaterFilter.setGainHF(0.0f); - } - - - void exitOpenAL() - { - // Unload EFX Effects - underwaterFilter.killFilter(); - - // Release the context and the device. - AL.destroy(); - } - - // TODO check the sfx direct buffer size - // 2MB sfx buffer - private ByteBuffer sfxDataBuffer = Lib.newByteBuffer(2 * 1024 * 1024); - - /* (non-Javadoc) - * @see jake2.sound.SoundImpl#RegisterSound(jake2.sound.sfx_t) - */ - private void initBuffer(byte[] samples, int bufferId, int freq) { - ByteBuffer data = sfxDataBuffer.slice(); - data.put(samples).flip(); - AL10.alBufferData(buffers.get(bufferId), AL10.AL_FORMAT_MONO16, - data, freq); - } + // Check for an error. + if (ALC10.alcGetError(AL.getDevice()) != ALC10.ALC_NO_ERROR) + { + Com.DPrintf("Error with SoundDevice"); + } + } + + /** Initializes OpenAL EFX effects. */ + private void initOpenALExtensions() + { + log.info("... using EFX effects:"); + underwaterFilter = new EFXFilterLowPass(); + underwaterFilter.setGain(1.0f); + underwaterFilter.setGainHF(0.0f); + } + + + void exitOpenAL() + { + // Unload EFX Effects + underwaterFilter.killFilter(); + + // Release the context and the device. + AL.destroy(); + } + + // TODO check the sfx direct buffer size + // 2MB sfx buffer + private ByteBuffer sfxDataBuffer = Lib.newByteBuffer(2 * 1024 * 1024); + + /* (non-Javadoc) + * @see jake2.sound.SoundImpl#RegisterSound(jake2.sound.sfx_t) + */ + private void initBuffer(byte[] samples, int bufferId, int freq) { + ByteBuffer data = sfxDataBuffer.slice(); + data.put(samples).flip(); + AL10.alBufferData(buffers.get(bufferId), AL10.AL_FORMAT_MONO16, + data, freq); + } - private void checkError() { - Com.DPrintf("AL Error: " + alErrorString() +'\n'); - } - - private String alErrorString(){ - int error; - String message = ""; - if ((error = AL10.alGetError()) != AL10.AL_NO_ERROR) { - switch(error) { - case AL10.AL_INVALID_OPERATION: message = "invalid operation"; break; - case AL10.AL_INVALID_VALUE: message = "invalid value"; break; - case AL10.AL_INVALID_ENUM: message = "invalid enum"; break; - case AL10.AL_INVALID_NAME: message = "invalid name"; break; - default: message = "" + error; - } - } - return message; - } + private void checkError() { + Com.DPrintf("AL Error: " + alErrorString() +'\n'); + } + + private String alErrorString(){ + int error; + String message = ""; + if ((error = AL10.alGetError()) != AL10.AL_NO_ERROR) { + switch(error) { + case AL10.AL_INVALID_OPERATION: message = "invalid operation"; break; + case AL10.AL_INVALID_VALUE: message = "invalid value"; break; + case AL10.AL_INVALID_ENUM: message = "invalid enum"; break; + case AL10.AL_INVALID_NAME: message = "invalid name"; break; + default: message = "" + error; + } + } + return message; + } - /* (non-Javadoc) - * @see jake2.sound.SoundImpl#Shutdown() - */ - public void Shutdown() { - StopAllSounds(); - Channel.shutdown(); - AL10.alDeleteBuffers(buffers); - exitOpenAL(); + /* (non-Javadoc) + * @see jake2.sound.SoundImpl#Shutdown() + */ + public void Shutdown() { + StopAllSounds(); + Channel.shutdown(); + AL10.alDeleteBuffers(buffers); + exitOpenAL(); - Cmd.RemoveCommand("play"); - Cmd.RemoveCommand("stopsound"); - Cmd.RemoveCommand("soundlist"); - Cmd.RemoveCommand("soundinfo"); + Cmd.RemoveCommand("play"); + Cmd.RemoveCommand("stopsound"); + Cmd.RemoveCommand("soundlist"); + Cmd.RemoveCommand("soundinfo"); - // free all sounds - for (int i = 0; i < num_sfx; i++) { - if (known_sfx[i].name == null) - continue; - known_sfx[i].clear(); - } - num_sfx = 0; - } - - /* (non-Javadoc) - * @see jake2.sound.SoundImpl#StartSound(float[], int, int, jake2.sound.sfx_t, float, float, float) - */ - public void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) { + // free all sounds + for (int i = 0; i < num_sfx; i++) { + if (known_sfx[i].name == null) + continue; + known_sfx[i].clear(); + } + num_sfx = 0; + } + + /* (non-Javadoc) + * @see jake2.sound.SoundImpl#StartSound(float[], int, int, jake2.sound.sfx_t, float, float, float) + */ + public void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) { - if (sfx == null) - return; - - if (sfx.name.charAt(0) == '*') - sfx = RegisterSexedSound(Globals.cl_entities[entnum].current, sfx.name); - - if (LoadSound(sfx) == null) - return; // can't load sound + if (sfx == null) + return; + + if (sfx.name.charAt(0) == '*') + sfx = RegisterSexedSound(Globals.cl_entities[entnum].current, sfx.name); + + if (LoadSound(sfx) == null) + return; // can't load sound - if (attenuation != Defines.ATTN_STATIC) - attenuation *= 0.5f; + if (attenuation != Defines.ATTN_STATIC) + attenuation *= 0.5f; - PlaySound.allocate(origin, entnum, entchannel, buffers.get(sfx.bufferId), fvol, attenuation, timeofs); - } - - private FloatBuffer listenerOrigin = Lib.newFloatBuffer(3); - private FloatBuffer listenerOrientation = Lib.newFloatBuffer(6); + PlaySound.allocate(origin, entnum, entchannel, buffers.get(sfx.bufferId), fvol, attenuation, timeofs); + } + + private FloatBuffer listenerOrigin = Lib.newFloatBuffer(3); + private FloatBuffer listenerOrientation = Lib.newFloatBuffer(6); - /* (non-Javadoc) - * @see jake2.sound.SoundImpl#Update(float[], float[], float[], float[]) - */ - public void Update(float[] origin, float[] forward, float[] right, float[] up) { - - Channel.convertVector(origin, listenerOrigin); - AL10.alListener(AL10.AL_POSITION, listenerOrigin); + /* (non-Javadoc) + * @see jake2.sound.SoundImpl#Update(float[], float[], float[], float[]) + */ + public void Update(float[] origin, float[] forward, float[] right, float[] up) { + + Channel.convertVector(origin, listenerOrigin); + AL10.alListener(AL10.AL_POSITION, listenerOrigin); - Channel.convertOrientation(forward, up, listenerOrientation); - AL10.alListener(AL10.AL_ORIENTATION, listenerOrientation); - - // set the master volume - AL10.alListenerf(AL10.AL_GAIN, s_volume.value); - - // Detect EFX Conditions - if ((GameBase.gi.pointcontents.pointcontents(origin)& Defines.MASK_WATER)!= 0) { - currentFilterIndex = underwaterFilter.getIndex(); - } - else { - currentEffectIndex = EFX10.AL_EFFECTSLOT_NULL; - currentFilterIndex = EFX10.AL_FILTER_NULL; - } - - Channel.addLoopSounds(); - Channel.addPlaySounds(); - Channel.playAllSounds(listenerOrigin, currentEffectIndex, currentFilterIndex); - } + Channel.convertOrientation(forward, up, listenerOrientation); + AL10.alListener(AL10.AL_ORIENTATION, listenerOrientation); + + // set the master volume + AL10.alListenerf(AL10.AL_GAIN, s_volume.value); + + // Detect EFX Conditions + if ((GameBase.gi.pointcontents.pointcontents(origin)& Defines.MASK_WATER)!= 0) { + currentFilterIndex = underwaterFilter.getIndex(); + } + else { + currentEffectIndex = EFX10.AL_EFFECTSLOT_NULL; + currentFilterIndex = EFX10.AL_FILTER_NULL; + } + + Channel.addLoopSounds(); + Channel.addPlaySounds(); + Channel.playAllSounds(listenerOrigin, currentEffectIndex, currentFilterIndex); + } - /* (non-Javadoc) - * @see jake2.sound.SoundImpl#StopAllSounds() - */ - public void StopAllSounds() { - // mute the listener (master) - AL10.alListenerf(AL10.AL_GAIN, 0); - PlaySound.reset(); - Channel.reset(); - } - - /* (non-Javadoc) - * @see jake2.sound.Sound#getName() - */ - public String getName() { - return "lwjgl"; - } + /* (non-Javadoc) + * @see jake2.sound.SoundImpl#StopAllSounds() + */ + public void StopAllSounds() { + // mute the listener (master) + AL10.alListenerf(AL10.AL_GAIN, 0); + PlaySound.reset(); + Channel.reset(); + } + + /* (non-Javadoc) + * @see jake2.sound.Sound#getName() + */ + public String getName() { + return "lwjgl"; + } - int s_registration_sequence; - boolean s_registering; + int s_registration_sequence; + boolean s_registering; - /* (non-Javadoc) - * @see jake2.sound.Sound#BeginRegistration() - */ - public void BeginRegistration() { - s_registration_sequence++; - s_registering = true; - } + /* (non-Javadoc) + * @see jake2.sound.Sound#BeginRegistration() + */ + public void BeginRegistration() { + s_registration_sequence++; + s_registering = true; + } - /* (non-Javadoc) - * @see jake2.sound.Sound#RegisterSound(java.lang.String) - */ - public sfx_t RegisterSound(String name) { - sfx_t sfx = FindName(name, true); - sfx.registration_sequence = s_registration_sequence; + /* (non-Javadoc) + * @see jake2.sound.Sound#RegisterSound(java.lang.String) + */ + public sfx_t RegisterSound(String name) { + sfx_t sfx = FindName(name, true); + sfx.registration_sequence = s_registration_sequence; - if (!s_registering) - LoadSound(sfx); - - return sfx; - } + if (!s_registering) + LoadSound(sfx); + + return sfx; + } - /* (non-Javadoc) - * @see jake2.sound.Sound#EndRegistration() - */ - public void EndRegistration() { - int i; - sfx_t sfx; + /* (non-Javadoc) + * @see jake2.sound.Sound#EndRegistration() + */ + public void EndRegistration() { + int i; + sfx_t sfx; - // free any sounds not from this registration sequence - for (i = 0; i < num_sfx; i++) { - sfx = known_sfx[i]; - if (sfx.name == null) - continue; - if (sfx.registration_sequence != s_registration_sequence) { - // don't need this sound - sfx.clear(); - } - } + // free any sounds not from this registration sequence + for (i = 0; i < num_sfx; i++) { + sfx = known_sfx[i]; + if (sfx.name == null) + continue; + if (sfx.registration_sequence != s_registration_sequence) { + // don't need this sound + sfx.clear(); + } + } - // load everything in - for (i = 0; i < num_sfx; i++) { - sfx = known_sfx[i]; - if (sfx.name == null) - continue; - LoadSound(sfx); - } + // load everything in + for (i = 0; i < num_sfx; i++) { + sfx = known_sfx[i]; + if (sfx.name == null) + continue; + LoadSound(sfx); + } - s_registering = false; - } - - sfx_t RegisterSexedSound(entity_state_t ent, String base) { + s_registering = false; + } + + sfx_t RegisterSexedSound(entity_state_t ent, String base) { - sfx_t sfx = null; + sfx_t sfx = null; - // determine what model the client is using - String model = null; - int n = Globals.CS_PLAYERSKINS + ent.number - 1; - if (Globals.cl.configstrings[n] != null) { - int p = Globals.cl.configstrings[n].indexOf('\\'); - if (p >= 0) { - p++; - model = Globals.cl.configstrings[n].substring(p); - //strcpy(model, p); - p = model.indexOf('/'); - if (p > 0) - model = model.substring(0, p); - } - } - // if we can't figure it out, they're male - if (model == null || model.length() == 0) - model = "male"; + // determine what model the client is using + String model = null; + int n = Globals.CS_PLAYERSKINS + ent.number - 1; + if (Globals.cl.configstrings[n] != null) { + int p = Globals.cl.configstrings[n].indexOf('\\'); + if (p >= 0) { + p++; + model = Globals.cl.configstrings[n].substring(p); + //strcpy(model, p); + p = model.indexOf('/'); + if (p > 0) + model = model.substring(0, p); + } + } + // if we can't figure it out, they're male + if (model == null || model.length() == 0) + model = "male"; - // see if we already know of the model specific sound - String sexedFilename = "#players/" + model + "/" + base.substring(1); - //Com_sprintf (sexedFilename, sizeof(sexedFilename), "#players/%s/%s", model, base+1); - sfx = FindName(sexedFilename, false); + // see if we already know of the model specific sound + String sexedFilename = "#players/" + model + "/" + base.substring(1); + //Com_sprintf (sexedFilename, sizeof(sexedFilename), "#players/%s/%s", model, base+1); + sfx = FindName(sexedFilename, false); - if (sfx != null) return sfx; - - // - // fall back strategies - // - // not found , so see if it exists - if (fileSystem.fileLength(sexedFilename.substring(1)) > 0) { - // yes, register it - return RegisterSound(sexedFilename); - } - // try it with the female sound in the pak0.pak - if (model.equalsIgnoreCase("female")) { - String femaleFilename = "player/female/" + base.substring(1); - if (fileSystem.fileLength("sound/" + femaleFilename) > 0) - return AliasName(sexedFilename, femaleFilename); - } - // no chance, revert to the male sound in the pak0.pak - String maleFilename = "player/male/" + base.substring(1); - return AliasName(sexedFilename, maleFilename); - } - + if (sfx != null) return sfx; + + // + // fall back strategies + // + // not found , so see if it exists + if (fileSystem.fileLength(sexedFilename.substring(1)) > 0) { + // yes, register it + return RegisterSound(sexedFilename); + } + // try it with the female sound in the pak0.pak + if (model.equalsIgnoreCase("female")) { + String femaleFilename = "player/female/" + base.substring(1); + if (fileSystem.fileLength("sound/" + femaleFilename) > 0) + return AliasName(sexedFilename, femaleFilename); + } + // no chance, revert to the male sound in the pak0.pak + String maleFilename = "player/male/" + base.substring(1); + return AliasName(sexedFilename, maleFilename); + } + - static sfx_t[] known_sfx = new sfx_t[MAX_SFX]; - static { - for (int i = 0; i< known_sfx.length; i++) - known_sfx[i] = new sfx_t(); - } - static int num_sfx; + static sfx_t[] known_sfx = new sfx_t[MAX_SFX]; + static { + for (int i = 0; i< known_sfx.length; i++) + known_sfx[i] = new sfx_t(); + } + static int num_sfx; - sfx_t FindName(String name, boolean create) { - int i; - sfx_t sfx = null; + sfx_t FindName(String name, boolean create) { + int i; + sfx_t sfx = null; - if (name == null) - Com.Error(Defines.ERR_FATAL, "S_FindName: NULL\n"); - if (name.length() == 0) - Com.Error(Defines.ERR_FATAL, "S_FindName: empty name\n"); + if (name == null) + Com.Error(Defines.ERR_FATAL, "S_FindName: NULL\n"); + if (name.length() == 0) + Com.Error(Defines.ERR_FATAL, "S_FindName: empty name\n"); - if (name.length() >= Defines.MAX_QPATH) - Com.Error(Defines.ERR_FATAL, "Sound name too long: " + name); + if (name.length() >= Defines.MAX_QPATH) + Com.Error(Defines.ERR_FATAL, "Sound name too long: " + name); - // see if already loaded - for (i = 0; i < num_sfx; i++) - if (name.equals(known_sfx[i].name)) { - return known_sfx[i]; - } + // see if already loaded + for (i = 0; i < num_sfx; i++) + if (name.equals(known_sfx[i].name)) { + return known_sfx[i]; + } - if (!create) - return null; + if (!create) + return null; - // find a free sfx - for (i = 0; i < num_sfx; i++) - if (known_sfx[i].name == null) - // registration_sequence < s_registration_sequence) - break; + // find a free sfx + for (i = 0; i < num_sfx; i++) + if (known_sfx[i].name == null) + // registration_sequence < s_registration_sequence) + break; - if (i == num_sfx) { - if (num_sfx == MAX_SFX) - Com.Error(Defines.ERR_FATAL, "S_FindName: out of sfx_t"); - num_sfx++; - } + if (i == num_sfx) { + if (num_sfx == MAX_SFX) + Com.Error(Defines.ERR_FATAL, "S_FindName: out of sfx_t"); + num_sfx++; + } - sfx = known_sfx[i]; - sfx.clear(); - sfx.name = name; - sfx.registration_sequence = s_registration_sequence; - sfx.bufferId = i; + sfx = known_sfx[i]; + sfx.clear(); + sfx.name = name; + sfx.registration_sequence = s_registration_sequence; + sfx.bufferId = i; - return sfx; - } + return sfx; + } - /* - ================== - S_AliasName + /* + ================== + S_AliasName - ================== - */ - sfx_t AliasName(String aliasname, String truename) - { - sfx_t sfx = null; - String s; - int i; + ================== + */ + sfx_t AliasName(String aliasname, String truename) + { + sfx_t sfx = null; + String s; + int i; - s = new String(truename); + s = new String(truename); - // find a free sfx - for (i=0 ; i < num_sfx ; i++) - if (known_sfx[i].name == null) - break; + // find a free sfx + for (i=0 ; i < num_sfx ; i++) + if (known_sfx[i].name == null) + break; - if (i == num_sfx) - { - if (num_sfx == MAX_SFX) - Com.Error(Defines.ERR_FATAL, "S_FindName: out of sfx_t"); - num_sfx++; - } - - sfx = known_sfx[i]; - sfx.clear(); - sfx.name = new String(aliasname); - sfx.registration_sequence = s_registration_sequence; - sfx.truename = s; - // set the AL bufferId - sfx.bufferId = i; + if (i == num_sfx) + { + if (num_sfx == MAX_SFX) + Com.Error(Defines.ERR_FATAL, "S_FindName: out of sfx_t"); + num_sfx++; + } + + sfx = known_sfx[i]; + sfx.clear(); + sfx.name = new String(aliasname); + sfx.registration_sequence = s_registration_sequence; + sfx.truename = s; + // set the AL bufferId + sfx.bufferId = i; - return sfx; - } + return sfx; + } - /* - ============== - S_LoadSound - ============== - */ - public sfxcache_t LoadSound(sfx_t s) { - if (s.isCached) return s.cache; - sfxcache_t sc = WaveLoader.LoadSound(s); - if (sc != null) { - initBuffer(sc.data, s.bufferId, sc.speed); - s.isCached = true; - // free samples for GC - s.cache.data = null; - } - return sc; - } + /* + ============== + S_LoadSound + ============== + */ + public sfxcache_t LoadSound(sfx_t s) { + if (s.isCached) return s.cache; + sfxcache_t sc = WaveLoader.LoadSound(s); + if (sc != null) { + initBuffer(sc.data, s.bufferId, sc.speed); + s.isCached = true; + // free samples for GC + s.cache.data = null; + } + return sc; + } - /* (non-Javadoc) - * @see jake2.sound.Sound#StartLocalSound(java.lang.String) - */ - public void StartLocalSound(String sound) { - sfx_t sfx; + /* (non-Javadoc) + * @see jake2.sound.Sound#StartLocalSound(java.lang.String) + */ + public void StartLocalSound(String sound) { + sfx_t sfx; - sfx = RegisterSound(sound); - if (sfx == null) { - Com.Printf("S_StartLocalSound: can't cache " + sound + "\n"); - return; - } - StartSound(null, Globals.cl.playernum + 1, 0, sfx, 1, 1, 0); - } + sfx = RegisterSound(sound); + if (sfx == null) { + Com.Printf("S_StartLocalSound: can't cache " + sound + "\n"); + return; + } + StartSound(null, Globals.cl.playernum + 1, 0, sfx, 1, 1, 0); + } private ShortBuffer streamBuffer = sfxDataBuffer.slice().order(ByteOrder.BIG_ENDIAN).asShortBuffer(); /* (non-Javadoc) - * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[]) - */ - public void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) { + * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[]) + */ + public void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) { int format; if (channels == 2) { format = (width == 2) ? AL10.AL_FORMAT_STEREO16 @@ -524,71 +524,71 @@ public final class LWJGLSoundImpl implements Sound { } Channel.updateStream(data, samples * channels * width, format, rate); - } + } public void disableStreaming() { Channel.disableStreaming(); } - /* - =============================================================================== + /* + =============================================================================== - console functions + console functions - =============================================================================== - */ + =============================================================================== + */ - void Play() { - int i; - String name; - sfx_t sfx; + void Play() { + int i; + String name; + sfx_t sfx; - i = 1; - while (i < Cmd.Argc()) { - name = new String(Cmd.Argv(i)); - if (name.indexOf('.') == -1) - name += ".wav"; + i = 1; + while (i < Cmd.Argc()) { + name = new String(Cmd.Argv(i)); + if (name.indexOf('.') == -1) + name += ".wav"; - sfx = RegisterSound(name); - StartSound(null, Globals.cl.playernum + 1, 0, sfx, 1.0f, 1.0f, 0.0f); - i++; - } - } + sfx = RegisterSound(name); + StartSound(null, Globals.cl.playernum + 1, 0, sfx, 1.0f, 1.0f, 0.0f); + i++; + } + } - void SoundList() { - int i; - sfx_t sfx; - sfxcache_t sc; - int size, total; + void SoundList() { + int i; + sfx_t sfx; + sfxcache_t sc; + int size, total; - total = 0; - for (i = 0; i < num_sfx; i++) { - sfx = known_sfx[i]; - if (sfx.registration_sequence == 0) - continue; - sc = sfx.cache; - if (sc != null) { - size = sc.length * sc.width * (sc.stereo + 1); - total += size; - log.info(String.format("%s(%2db) %6d : %s", - (sc.loopstart >= 0 ? 'L' : ' '), - (sc.width * 8), size, sfx.name) - ); - } else { - if (sfx.name.charAt(0) == '*') - log.info(" placeholder : {}", sfx.name); - else - log.info(" not loaded : {}", sfx.name); - } - } - log.info("Total resident: {}", total); - } - - void SoundInfo_f() { - //TODO параметры тут не нужны, сплошная статика - log.info(String.format("%5d stereo", 1)); - log.info(String.format("%5d samples", 22050)); - log.info(String.format("%5d samplebits", 16)); - log.info(String.format("%5d speed", 44100)); - } + total = 0; + for (i = 0; i < num_sfx; i++) { + sfx = known_sfx[i]; + if (sfx.registration_sequence == 0) + continue; + sc = sfx.cache; + if (sc != null) { + size = sc.length * sc.width * (sc.stereo + 1); + total += size; + log.info(String.format("%s(%2db) %6d : %s", + (sc.loopstart >= 0 ? 'L' : ' '), + (sc.width * 8), size, sfx.name) + ); + } else { + if (sfx.name.charAt(0) == '*') + log.info(" placeholder : {}", sfx.name); + else + log.info(" not loaded : {}", sfx.name); + } + } + log.info("Total resident: {}", total); + } + + void SoundInfo_f() { + //TODO параметры тут не нужны, сплошная статика + log.info(String.format("%5d stereo", 1)); + log.info(String.format("%5d samples", 22050)); + log.info(String.format("%5d samplebits", 16)); + log.info(String.format("%5d speed", 44100)); + } } diff --git a/src/main/java/lwjake2/sound/lwjgl/PlaySound.java b/src/main/java/lwjake2/sound/lwjgl/PlaySound.java index d1331c8..9715890 100644 --- a/src/main/java/lwjake2/sound/lwjgl/PlaySound.java +++ b/src/main/java/lwjake2/sound/lwjgl/PlaySound.java @@ -29,28 +29,28 @@ import lwjake2.util.Math3D; */ @Slf4j public class PlaySound { - final static int MAX_PLAYSOUNDS = 128; - - // list with sentinel - private static PlaySound freeList; - private static PlaySound playableList; - - private static PlaySound[] backbuffer = new PlaySound[MAX_PLAYSOUNDS]; - static { - for (int i = 0; i < backbuffer.length; i++) { - backbuffer[i] = new PlaySound(); + final static int MAX_PLAYSOUNDS = 128; + + // list with sentinel + private static PlaySound freeList; + private static PlaySound playableList; + + private static PlaySound[] backbuffer = new PlaySound[MAX_PLAYSOUNDS]; + static { + for (int i = 0; i < backbuffer.length; i++) { + backbuffer[i] = new PlaySound(); } - // init the sentinels - freeList = new PlaySound(); - playableList = new PlaySound(); - // reset the lists - reset(); - } - + // init the sentinels + freeList = new PlaySound(); + playableList = new PlaySound(); + // reset the lists + reset(); + } + // sound attributes int type; - int entnum; - int entchannel; + int entnum; + int entchannel; int bufferId; float volume; float attenuation; @@ -68,7 +68,7 @@ public class PlaySound { } private void clear() { - type = bufferId = entnum = entchannel = -1; + type = bufferId = entnum = entchannel = -1; // volume = attenuation = beginTime = 0; attenuation = beginTime = 0; // Math3D.VectorClear(origin); @@ -81,10 +81,10 @@ public class PlaySound { // concat the the freeList PlaySound ps; - for (int i = 0; i < backbuffer.length; i++) { - ps = backbuffer[i]; - ps.clear(); - ps.prev = freeList; + for (int i = 0; i < backbuffer.length; i++) { + ps = backbuffer[i]; + ps.clear(); + ps.prev = freeList; ps.next = freeList.next; ps.prev.next = ps; ps.next.prev = ps; diff --git a/src/main/java/lwjake2/sound/sfx_t.java b/src/main/java/lwjake2/sound/sfx_t.java index 676c1f2..41b3b43 100644 --- a/src/main/java/lwjake2/sound/sfx_t.java +++ b/src/main/java/lwjake2/sound/sfx_t.java @@ -19,20 +19,20 @@ package lwjake2.sound; public class sfx_t { - public String name; - public int registration_sequence; - public sfxcache_t cache; - public String truename; - - // is used for AL buffers - public int bufferId = -1; - public boolean isCached = false; - - public void clear() { - name = truename = null; - cache = null; - registration_sequence = 0; - bufferId = -1; - isCached = false; - } + public String name; + public int registration_sequence; + public sfxcache_t cache; + public String truename; + + // is used for AL buffers + public int bufferId = -1; + public boolean isCached = false; + + public void clear() { + name = truename = null; + cache = null; + registration_sequence = 0; + bufferId = -1; + isCached = false; + } } diff --git a/src/main/java/lwjake2/sound/sfxcache_t.java b/src/main/java/lwjake2/sound/sfxcache_t.java index 079aba6..ab38adc 100644 --- a/src/main/java/lwjake2/sound/sfxcache_t.java +++ b/src/main/java/lwjake2/sound/sfxcache_t.java @@ -19,14 +19,14 @@ package lwjake2.sound; public class sfxcache_t { - public int length; - public int loopstart; - public int speed; // not needed, because converted on load? - public int width; - public int stereo; - public byte data[]; // variable sized - - public sfxcache_t(int size) { - data = new byte[size]; - } + public int length; + public int loopstart; + public int speed; // not needed, because converted on load? + public int width; + public int stereo; + public byte data[]; // variable sized + + public sfxcache_t(int size) { + data = new byte[size]; + } } diff --git a/src/main/java/lwjake2/sound/soundinfo_t.java b/src/main/java/lwjake2/sound/soundinfo_t.java index d0fabb5..261a53a 100644 --- a/src/main/java/lwjake2/sound/soundinfo_t.java +++ b/src/main/java/lwjake2/sound/soundinfo_t.java @@ -22,10 +22,10 @@ package lwjake2.sound; * soundinfo_t */ public class soundinfo_t { - int channels; - int samples; // mono samples in buffer - int submission_chunk; // don't mix less than this # - int samplepos; // in mono samples - int samplebits; - int speed; + int channels; + int samples; // mono samples in buffer + int submission_chunk; // don't mix less than this # + int samplepos; // in mono samples + int samplebits; + int speed; } diff --git a/src/main/java/lwjake2/sound/wavinfo_t.java b/src/main/java/lwjake2/sound/wavinfo_t.java index 9ce787d..949b307 100644 --- a/src/main/java/lwjake2/sound/wavinfo_t.java +++ b/src/main/java/lwjake2/sound/wavinfo_t.java @@ -22,10 +22,10 @@ package lwjake2.sound; * wavinfo_t */ public class wavinfo_t { - public int rate; - public int width; - public int channels; - public int loopstart; - public int samples; - public int dataofs; // chunk starts this many bytes from file start + public int rate; + public int width; + public int channels; + public int loopstart; + public int samples; + public int dataofs; // chunk starts this many bytes from file start } diff --git a/src/main/java/lwjake2/sys/IN.java b/src/main/java/lwjake2/sys/IN.java index d358cf4..820ee5f 100644 --- a/src/main/java/lwjake2/sys/IN.java +++ b/src/main/java/lwjake2/sys/IN.java @@ -66,12 +66,12 @@ public final class IN extends Globals { } private static void install_grabs() { - Globals.re.getKeyboardHandler().installGrabs(); - ignorefirst = true; + Globals.re.getKeyboardHandler().installGrabs(); + ignorefirst = true; } private static void uninstall_grabs() { - Globals.re.getKeyboardHandler().uninstallGrabs(); + Globals.re.getKeyboardHandler().uninstallGrabs(); } public static void toggleMouse() { @@ -116,20 +116,20 @@ public final class IN extends Globals { } public static void Commands() { - int i; - - if (!IN.mouse_avail) - return; - - KBD kbd=Globals.re.getKeyboardHandler(); - for (i=0 ; i<3 ; i++) { - if ( (IN.mouse_buttonstate & (1< eventQueue = new LinkedList(); + // modifications of eventQueue must be thread safe! + private static LinkedList eventQueue = new LinkedList(); - static void addEvent(LWJake2InputEvent ev) { - synchronized (eventQueue) { - eventQueue.addLast(ev); - } - } + static void addEvent(LWJake2InputEvent ev) { + synchronized (eventQueue) { + eventQueue.addLast(ev); + } + } - static LWJake2InputEvent nextEvent() { - LWJake2InputEvent ev; - synchronized (eventQueue) { - ev = (!eventQueue.isEmpty())?(LWJake2InputEvent)eventQueue.removeFirst():null; - } - return ev; - } + static LWJake2InputEvent nextEvent() { + LWJake2InputEvent ev; + synchronized (eventQueue) { + ev = (!eventQueue.isEmpty())?(LWJake2InputEvent)eventQueue.removeFirst():null; + } + return ev; + } - public void keyPressed(KeyEvent e) { - if (!((e.getModifiersEx() & InputEvent.ALT_GRAPH_DOWN_MASK) != 0)) { - addEvent(new LWJake2InputEvent(LWJake2InputEvent.KeyPress, e)); - } - } + public void keyPressed(KeyEvent e) { + if (!((e.getModifiersEx() & InputEvent.ALT_GRAPH_DOWN_MASK) != 0)) { + addEvent(new LWJake2InputEvent(LWJake2InputEvent.KeyPress, e)); + } + } - public void keyReleased(KeyEvent e) { - addEvent(new LWJake2InputEvent(LWJake2InputEvent.KeyRelease, e)); - } + public void keyReleased(KeyEvent e) { + addEvent(new LWJake2InputEvent(LWJake2InputEvent.KeyRelease, e)); + } - public void keyTyped(KeyEvent e) { - if ((e.getModifiersEx() & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { - addEvent(new LWJake2InputEvent(LWJake2InputEvent.KeyPress, e)); - addEvent(new LWJake2InputEvent(LWJake2InputEvent.KeyRelease, e)); - } - } + public void keyTyped(KeyEvent e) { + if ((e.getModifiersEx() & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { + addEvent(new LWJake2InputEvent(LWJake2InputEvent.KeyPress, e)); + addEvent(new LWJake2InputEvent(LWJake2InputEvent.KeyRelease, e)); + } + } - public void mouseClicked(MouseEvent e) { - } + public void mouseClicked(MouseEvent e) { + } - public void mouseEntered(MouseEvent e) { - } + public void mouseEntered(MouseEvent e) { + } - public void mouseExited(MouseEvent e) { - } + public void mouseExited(MouseEvent e) { + } - public void mousePressed(MouseEvent e) { - addEvent(new LWJake2InputEvent(LWJake2InputEvent.ButtonPress, e)); - } + public void mousePressed(MouseEvent e) { + addEvent(new LWJake2InputEvent(LWJake2InputEvent.ButtonPress, e)); + } - public void mouseReleased(MouseEvent e) { - addEvent(new LWJake2InputEvent(LWJake2InputEvent.ButtonRelease, e)); - } + public void mouseReleased(MouseEvent e) { + addEvent(new LWJake2InputEvent(LWJake2InputEvent.ButtonRelease, e)); + } - public void mouseDragged(MouseEvent e) { - addEvent(new LWJake2InputEvent(LWJake2InputEvent.MotionNotify, e)); - } + public void mouseDragged(MouseEvent e) { + addEvent(new LWJake2InputEvent(LWJake2InputEvent.MotionNotify, e)); + } - public void mouseMoved(MouseEvent e) { - addEvent(new LWJake2InputEvent(LWJake2InputEvent.MotionNotify, e)); - } + public void mouseMoved(MouseEvent e) { + addEvent(new LWJake2InputEvent(LWJake2InputEvent.MotionNotify, e)); + } - public void componentHidden(ComponentEvent e) { - } + public void componentHidden(ComponentEvent e) { + } - public void componentMoved(ComponentEvent e) { - addEvent(new LWJake2InputEvent(LWJake2InputEvent.ConfigureNotify, e)); - } + public void componentMoved(ComponentEvent e) { + addEvent(new LWJake2InputEvent(LWJake2InputEvent.ConfigureNotify, e)); + } - public void componentResized(ComponentEvent e) { - addEvent(new LWJake2InputEvent(LWJake2InputEvent.ConfigureNotify, e)); - } + public void componentResized(ComponentEvent e) { + addEvent(new LWJake2InputEvent(LWJake2InputEvent.ConfigureNotify, e)); + } - public void componentShown(ComponentEvent e) { - JOGLKBD.c = e.getComponent(); - addEvent(new LWJake2InputEvent(LWJake2InputEvent.CreateNotify, e)); - } + public void componentShown(ComponentEvent e) { + JOGLKBD.c = e.getComponent(); + addEvent(new LWJake2InputEvent(LWJake2InputEvent.CreateNotify, e)); + } public void mouseWheelMoved(MouseWheelEvent e) { addEvent(new LWJake2InputEvent(LWJake2InputEvent.WheelMoved, e)); - } + } } diff --git a/src/main/java/lwjake2/sys/JOGLKBD.java b/src/main/java/lwjake2/sys/JOGLKBD.java index 0ffb916..6fa1e7c 100644 --- a/src/main/java/lwjake2/sys/JOGLKBD.java +++ b/src/main/java/lwjake2/sys/JOGLKBD.java @@ -36,225 +36,225 @@ import javax.swing.ImageIcon; final public class JOGLKBD extends KBD { - static Robot robot; - public static InputListener listener = new InputListener(); - static Cursor emptyCursor = null; - static Component c = null; - - static int win_w2 = 0; - static int win_h2 = 0; - - static { - try { - robot = new Robot(); - } catch (AWTException e) { - System.exit(1); - } - } - - public void Init() { - } + static Robot robot; + public static InputListener listener = new InputListener(); + static Cursor emptyCursor = null; + static Component c = null; + + static int win_w2 = 0; + static int win_h2 = 0; + + static { + try { + robot = new Robot(); + } catch (AWTException e) { + System.exit(1); + } + } + + public void Init() { + } - public void Update() { - // get events - HandleEvents(); - } + public void Update() { + // get events + HandleEvents(); + } - public void Close() { - } - - private void HandleEvents() - { - int key; + public void Close() { + } + + private void HandleEvents() + { + int key; - LWJake2InputEvent event; - while ( (event=InputListener.nextEvent()) != null ) { - switch(event.type) { - case LWJake2InputEvent.KeyPress: - case LWJake2InputEvent.KeyRelease: - Do_Key_Event(XLateKey((KeyEvent)event.ev), event.type == LWJake2InputEvent.KeyPress); - break; + LWJake2InputEvent event; + while ( (event=InputListener.nextEvent()) != null ) { + switch(event.type) { + case LWJake2InputEvent.KeyPress: + case LWJake2InputEvent.KeyRelease: + Do_Key_Event(XLateKey((KeyEvent)event.ev), event.type == LWJake2InputEvent.KeyPress); + break; - case LWJake2InputEvent.MotionNotify: -// if (IN.ignorefirst) { -// IN.ignorefirst = false; -// break; -// } - if (IN.mouse_active) { - mx = (((MouseEvent)event.ev).getX() - win_w2) * 2; - my = (((MouseEvent)event.ev).getY() - win_h2) * 2; - } else { - mx = 0; - my = 0; - } - break; - // see java.awt.MouseEvent - case LWJake2InputEvent.ButtonPress: - key = mouseEventToKey((MouseEvent)event.ev); - Do_Key_Event(key, true); - break; + case LWJake2InputEvent.MotionNotify: +// if (IN.ignorefirst) { +// IN.ignorefirst = false; +// break; +// } + if (IN.mouse_active) { + mx = (((MouseEvent)event.ev).getX() - win_w2) * 2; + my = (((MouseEvent)event.ev).getY() - win_h2) * 2; + } else { + mx = 0; + my = 0; + } + break; + // see java.awt.MouseEvent + case LWJake2InputEvent.ButtonPress: + key = mouseEventToKey((MouseEvent)event.ev); + Do_Key_Event(key, true); + break; - case LWJake2InputEvent.ButtonRelease: - key = mouseEventToKey((MouseEvent)event.ev); - Do_Key_Event(key, false); - break; - - case LWJake2InputEvent.WheelMoved: - int dir = ((MouseWheelEvent)event.ev).getWheelRotation(); - if (dir > 0) { - Do_Key_Event(Key.K_MWHEELDOWN, true); - Do_Key_Event(Key.K_MWHEELDOWN, false); - } else { - Do_Key_Event(Key.K_MWHEELUP, true); - Do_Key_Event(Key.K_MWHEELUP, false); - } - break; - - case LWJake2InputEvent.CreateNotify : - case LWJake2InputEvent.ConfigureNotify : - Component c = ((ComponentEvent)event.ev).getComponent(); - win_x = 0; - win_y = 0; - win_w2 = c.getWidth() / 2; - win_h2 = c.getHeight() / 2; - while (c != null) { - if (c instanceof Container) { - Insets insets = ((Container)c).getInsets(); - win_x += insets.left; - win_y += insets.top; - } - win_x += c.getX(); - win_y += c.getY(); - c = c.getParent(); - } - break; - } - } + case LWJake2InputEvent.ButtonRelease: + key = mouseEventToKey((MouseEvent)event.ev); + Do_Key_Event(key, false); + break; + + case LWJake2InputEvent.WheelMoved: + int dir = ((MouseWheelEvent)event.ev).getWheelRotation(); + if (dir > 0) { + Do_Key_Event(Key.K_MWHEELDOWN, true); + Do_Key_Event(Key.K_MWHEELDOWN, false); + } else { + Do_Key_Event(Key.K_MWHEELUP, true); + Do_Key_Event(Key.K_MWHEELUP, false); + } + break; + + case LWJake2InputEvent.CreateNotify : + case LWJake2InputEvent.ConfigureNotify : + Component c = ((ComponentEvent)event.ev).getComponent(); + win_x = 0; + win_y = 0; + win_w2 = c.getWidth() / 2; + win_h2 = c.getHeight() / 2; + while (c != null) { + if (c instanceof Container) { + Insets insets = ((Container)c).getInsets(); + win_x += insets.left; + win_y += insets.top; + } + win_x += c.getX(); + win_y += c.getY(); + c = c.getParent(); + } + break; + } + } - if (mx != 0 || my != 0) { - // move the mouse to the window center again - robot.mouseMove(win_x + win_w2, win_y + win_h2); - } - } + if (mx != 0 || my != 0) { + // move the mouse to the window center again + robot.mouseMove(win_x + win_w2, win_y + win_h2); + } + } - // strange button numbering in java.awt.MouseEvent - // BUTTON1(left) BUTTON2(center) BUTTON3(right) - // K_MOUSE1 K_MOUSE3 K_MOUSE2 - private final int mouseEventToKey(MouseEvent ev) { - switch (ev.getButton()) { - case MouseEvent.BUTTON3: - return Key.K_MOUSE2; - case MouseEvent.BUTTON2: - return Key.K_MOUSE3; - default: - return Key.K_MOUSE1; - } - } + // strange button numbering in java.awt.MouseEvent + // BUTTON1(left) BUTTON2(center) BUTTON3(right) + // K_MOUSE1 K_MOUSE3 K_MOUSE2 + private final int mouseEventToKey(MouseEvent ev) { + switch (ev.getButton()) { + case MouseEvent.BUTTON3: + return Key.K_MOUSE2; + case MouseEvent.BUTTON2: + return Key.K_MOUSE3; + default: + return Key.K_MOUSE1; + } + } - private static int XLateKey(KeyEvent ev) { + private static int XLateKey(KeyEvent ev) { - int key = 0; - int code = ev.getKeyCode(); + int key = 0; + int code = ev.getKeyCode(); - switch(code) { -// 00626 case XK_KP_Page_Up: key = K_KP_PGUP; break; - case KeyEvent.VK_PAGE_UP: key = Key.K_PGUP; break; + switch(code) { +// 00626 case XK_KP_Page_Up: key = K_KP_PGUP; break; + case KeyEvent.VK_PAGE_UP: key = Key.K_PGUP; break; -// 00629 case XK_KP_Page_Down: key = K_KP_PGDN; break; - case KeyEvent.VK_PAGE_DOWN: key = Key.K_PGDN; break; +// 00629 case XK_KP_Page_Down: key = K_KP_PGDN; break; + case KeyEvent.VK_PAGE_DOWN: key = Key.K_PGDN; break; -// 00632 case XK_KP_Home: key = K_KP_HOME; break; - case KeyEvent.VK_HOME: key = Key.K_HOME; break; +// 00632 case XK_KP_Home: key = K_KP_HOME; break; + case KeyEvent.VK_HOME: key = Key.K_HOME; break; -// 00635 case XK_KP_End: key = K_KP_END; break; - case KeyEvent.VK_END: key = Key.K_END; break; +// 00635 case XK_KP_End: key = K_KP_END; break; + case KeyEvent.VK_END: key = Key.K_END; break; - case KeyEvent.VK_KP_LEFT: key = Key.K_KP_LEFTARROW; break; - case KeyEvent.VK_LEFT: key = Key.K_LEFTARROW; break; + case KeyEvent.VK_KP_LEFT: key = Key.K_KP_LEFTARROW; break; + case KeyEvent.VK_LEFT: key = Key.K_LEFTARROW; break; - case KeyEvent.VK_KP_RIGHT: key = Key.K_KP_RIGHTARROW; break; - case KeyEvent.VK_RIGHT: key = Key.K_RIGHTARROW; break; + case KeyEvent.VK_KP_RIGHT: key = Key.K_KP_RIGHTARROW; break; + case KeyEvent.VK_RIGHT: key = Key.K_RIGHTARROW; break; - case KeyEvent.VK_KP_DOWN: key = Key.K_KP_DOWNARROW; break; - case KeyEvent.VK_DOWN: key = Key.K_DOWNARROW; break; + case KeyEvent.VK_KP_DOWN: key = Key.K_KP_DOWNARROW; break; + case KeyEvent.VK_DOWN: key = Key.K_DOWNARROW; break; - case KeyEvent.VK_KP_UP: key = Key.K_KP_UPARROW; break; - case KeyEvent.VK_UP: key = Key.K_UPARROW; break; + case KeyEvent.VK_KP_UP: key = Key.K_KP_UPARROW; break; + case KeyEvent.VK_UP: key = Key.K_UPARROW; break; - case KeyEvent.VK_ESCAPE: key = Key.K_ESCAPE; break; + case KeyEvent.VK_ESCAPE: key = Key.K_ESCAPE; break; - - case KeyEvent.VK_ENTER: key = Key.K_ENTER; break; -// 00652 case XK_KP_Enter: key = K_KP_ENTER; break; + + case KeyEvent.VK_ENTER: key = Key.K_ENTER; break; +// 00652 case XK_KP_Enter: key = K_KP_ENTER; break; - case KeyEvent.VK_TAB: key = Key.K_TAB; break; + case KeyEvent.VK_TAB: key = Key.K_TAB; break; - case KeyEvent.VK_F1: key = Key.K_F1; break; - case KeyEvent.VK_F2: key = Key.K_F2; break; - case KeyEvent.VK_F3: key = Key.K_F3; break; - case KeyEvent.VK_F4: key = Key.K_F4; break; - case KeyEvent.VK_F5: key = Key.K_F5; break; - case KeyEvent.VK_F6: key = Key.K_F6; break; - case KeyEvent.VK_F7: key = Key.K_F7; break; - case KeyEvent.VK_F8: key = Key.K_F8; break; - case KeyEvent.VK_F9: key = Key.K_F9; break; - case KeyEvent.VK_F10: key = Key.K_F10; break; - case KeyEvent.VK_F11: key = Key.K_F11; break; - case KeyEvent.VK_F12: key = Key.K_F12; break; + case KeyEvent.VK_F1: key = Key.K_F1; break; + case KeyEvent.VK_F2: key = Key.K_F2; break; + case KeyEvent.VK_F3: key = Key.K_F3; break; + case KeyEvent.VK_F4: key = Key.K_F4; break; + case KeyEvent.VK_F5: key = Key.K_F5; break; + case KeyEvent.VK_F6: key = Key.K_F6; break; + case KeyEvent.VK_F7: key = Key.K_F7; break; + case KeyEvent.VK_F8: key = Key.K_F8; break; + case KeyEvent.VK_F9: key = Key.K_F9; break; + case KeyEvent.VK_F10: key = Key.K_F10; break; + case KeyEvent.VK_F11: key = Key.K_F11; break; + case KeyEvent.VK_F12: key = Key.K_F12; break; - case KeyEvent.VK_BACK_SPACE: key = Key.K_BACKSPACE; break; + case KeyEvent.VK_BACK_SPACE: key = Key.K_BACKSPACE; break; - case KeyEvent.VK_DELETE: key = Key.K_DEL; break; -// 00683 case XK_KP_Delete: key = K_KP_DEL; break; + case KeyEvent.VK_DELETE: key = Key.K_DEL; break; +// 00683 case XK_KP_Delete: key = K_KP_DEL; break; - case KeyEvent.VK_PAUSE: key = Key.K_PAUSE; break; - - case KeyEvent.VK_SHIFT: key = Key.K_SHIFT; break; - case KeyEvent.VK_CONTROL: key = Key.K_CTRL; break; - - case KeyEvent.VK_ALT: - case KeyEvent.VK_ALT_GRAPH: key = Key.K_ALT; break; + case KeyEvent.VK_PAUSE: key = Key.K_PAUSE; break; + + case KeyEvent.VK_SHIFT: key = Key.K_SHIFT; break; + case KeyEvent.VK_CONTROL: key = Key.K_CTRL; break; + + case KeyEvent.VK_ALT: + case KeyEvent.VK_ALT_GRAPH: key = Key.K_ALT; break; -// 00700 case XK_KP_Begin: key = K_KP_5; break; -// 00701 - case KeyEvent.VK_INSERT: key = Key.K_INS; break; - // toggle console for DE and US keyboards - case KeyEvent.VK_DEAD_ACUTE: - case KeyEvent.VK_CIRCUMFLEX: - case KeyEvent.VK_DEAD_CIRCUMFLEX: key = '`'; break; - - default: - key = ev.getKeyChar(); +// 00700 case XK_KP_Begin: key = K_KP_5; break; +// 00701 + case KeyEvent.VK_INSERT: key = Key.K_INS; break; + // toggle console for DE and US keyboards + case KeyEvent.VK_DEAD_ACUTE: + case KeyEvent.VK_CIRCUMFLEX: + case KeyEvent.VK_DEAD_CIRCUMFLEX: key = '`'; break; + + default: + key = ev.getKeyChar(); - if (key >= 'A' && key <= 'Z') - key = key - 'A' + 'a'; - break; - } - if (key > 255) key = 0; + if (key >= 'A' && key <= 'Z') + key = key - 'A' + 'a'; + break; + } + if (key > 255) key = 0; - return key; - } - - public void Do_Key_Event(int key, boolean down) { - Key.Event(key, down, Timer.Milliseconds()); - } - - public void centerMouse() { - robot.mouseMove(win_x + win_w2, win_y + win_h2); - } - - public void installGrabs() - { - if (emptyCursor == null) { - ImageIcon emptyIcon = new ImageIcon(new byte[0]); - emptyCursor = c.getToolkit().createCustomCursor(emptyIcon.getImage(), new Point(0, 0), "emptyCursor"); - } - c.setCursor(emptyCursor); - centerMouse(); - } - - public void uninstallGrabs() - { - c.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } + return key; + } + + public void Do_Key_Event(int key, boolean down) { + Key.Event(key, down, Timer.Milliseconds()); + } + + public void centerMouse() { + robot.mouseMove(win_x + win_w2, win_y + win_h2); + } + + public void installGrabs() + { + if (emptyCursor == null) { + ImageIcon emptyIcon = new ImageIcon(new byte[0]); + emptyCursor = c.getToolkit().createCustomCursor(emptyIcon.getImage(), new Point(0, 0), "emptyCursor"); + } + c.setCursor(emptyCursor); + centerMouse(); + } + + public void uninstallGrabs() + { + c.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } } diff --git a/src/main/java/lwjake2/sys/KBD.java b/src/main/java/lwjake2/sys/KBD.java index f7dd46e..945de94 100644 --- a/src/main/java/lwjake2/sys/KBD.java +++ b/src/main/java/lwjake2/sys/KBD.java @@ -22,23 +22,23 @@ package lwjake2.sys; * KBD */ abstract public class KBD { - - static int win_x = 0; - static int win_y = 0; - - // motion values - public static int mx = 0; - public static int my = 0; - - abstract public void Init(); + + static int win_x = 0; + static int win_y = 0; + + // motion values + public static int mx = 0; + public static int my = 0; + + abstract public void Init(); - abstract public void Update(); + abstract public void Update(); - abstract public void Close(); - abstract public void Do_Key_Event(int key, boolean down); + abstract public void Close(); + abstract public void Do_Key_Event(int key, boolean down); - abstract public void installGrabs(); - abstract public void uninstallGrabs(); - //abstract public void centerMouse(); + abstract public void installGrabs(); + abstract public void uninstallGrabs(); + //abstract public void centerMouse(); } diff --git a/src/main/java/lwjake2/sys/LWJGLKBD.java b/src/main/java/lwjake2/sys/LWJGLKBD.java index 26043ea..0e2be6d 100644 --- a/src/main/java/lwjake2/sys/LWJGLKBD.java +++ b/src/main/java/lwjake2/sys/LWJGLKBD.java @@ -31,208 +31,208 @@ import org.lwjgl.opengl.Display; * @author dsanders */ public class LWJGLKBD extends KBD { - - private char[] lwjglKeycodeMap = null; - private int pressed[] = null; - - public void Init() - { - try - { - if (!Keyboard.isCreated()) Keyboard.create(); - if (!Mouse.isCreated()) Mouse.create(); - - // Old code from old LWJGL, not sure if it's needed - flibit - - // if (!Keyboard.isBuffered()) Keyboard.enableBuffer(); - // if (!Keyboard.isTranslationEnabled()) Keyboard.enableTranslation(); - // if (!Mouse.isBuffered()) Mouse.enableBuffer(); - - if (lwjglKeycodeMap == null) lwjglKeycodeMap = new char[256]; - if (pressed == null) pressed = new int[256]; - - lastRepeat = Timer.Milliseconds(); - } catch (Exception e) {;} - } + + private char[] lwjglKeycodeMap = null; + private int pressed[] = null; + + public void Init() + { + try + { + if (!Keyboard.isCreated()) Keyboard.create(); + if (!Mouse.isCreated()) Mouse.create(); + + // Old code from old LWJGL, not sure if it's needed - flibit + + // if (!Keyboard.isBuffered()) Keyboard.enableBuffer(); + // if (!Keyboard.isTranslationEnabled()) Keyboard.enableTranslation(); + // if (!Mouse.isBuffered()) Mouse.enableBuffer(); + + if (lwjglKeycodeMap == null) lwjglKeycodeMap = new char[256]; + if (pressed == null) pressed = new int[256]; + + lastRepeat = Timer.Milliseconds(); + } catch (Exception e) {;} + } - public void Update() { - // get events - HandleEvents(); - } + public void Update() { + // get events + HandleEvents(); + } - public void Close() { - Keyboard.destroy(); - Mouse.destroy(); - // free the memory for GC - lwjglKeycodeMap = null; - pressed = null; - } - - private void HandleEvents() - { - Keyboard.poll(); - - if (Display.isCloseRequested()) - { - Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit"); - } + public void Close() { + Keyboard.destroy(); + Mouse.destroy(); + // free the memory for GC + lwjglKeycodeMap = null; + pressed = null; + } + + private void HandleEvents() + { + Keyboard.poll(); + + if (Display.isCloseRequested()) + { + Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit"); + } - while (Keyboard.next()) - { - int key = Keyboard.getEventKey(); - char ch = Keyboard.getEventCharacter(); - boolean down = Keyboard.getEventKeyState(); - - // fill the character translation table - // this is needed because the getEventCharacter() returns \0 if a key is released - // keycode is correct but the charachter value is not - if (down) { - lwjglKeycodeMap[key] = ch; - pressed[key] = Globals.sys_frame_time; - } else { - pressed[key] = 0; - } - - Do_Key_Event(XLateKey(key,ch), down); - } - - generateRepeats(); - - if (IN.mouse_active) - { - mx = Mouse.getDX() << 1; - my = -Mouse.getDY() << 1; - } - else - { - mx=0; - my=0; - } - - while (Mouse.next()) { - int button = Mouse.getEventButton(); - if (button >= 0) { - Do_Key_Event(Key.K_MOUSE1 + button, Mouse.getEventButtonState()); - } else { - button = Mouse.getEventDWheel(); - if (button > 0) { - Do_Key_Event(Key.K_MWHEELUP, true); - Do_Key_Event(Key.K_MWHEELUP, false); - } else if (button < 0) { - Do_Key_Event(Key.K_MWHEELDOWN, true); - Do_Key_Event(Key.K_MWHEELDOWN, false); - } - } - } - } + while (Keyboard.next()) + { + int key = Keyboard.getEventKey(); + char ch = Keyboard.getEventCharacter(); + boolean down = Keyboard.getEventKeyState(); + + // fill the character translation table + // this is needed because the getEventCharacter() returns \0 if a key is released + // keycode is correct but the charachter value is not + if (down) { + lwjglKeycodeMap[key] = ch; + pressed[key] = Globals.sys_frame_time; + } else { + pressed[key] = 0; + } + + Do_Key_Event(XLateKey(key,ch), down); + } + + generateRepeats(); + + if (IN.mouse_active) + { + mx = Mouse.getDX() << 1; + my = -Mouse.getDY() << 1; + } + else + { + mx=0; + my=0; + } + + while (Mouse.next()) { + int button = Mouse.getEventButton(); + if (button >= 0) { + Do_Key_Event(Key.K_MOUSE1 + button, Mouse.getEventButtonState()); + } else { + button = Mouse.getEventDWheel(); + if (button > 0) { + Do_Key_Event(Key.K_MWHEELUP, true); + Do_Key_Event(Key.K_MWHEELUP, false); + } else if (button < 0) { + Do_Key_Event(Key.K_MWHEELDOWN, true); + Do_Key_Event(Key.K_MWHEELDOWN, false); + } + } + } + } - private static int lastRepeat; - private void generateRepeats() { - int time = Globals.sys_frame_time; - if (time - lastRepeat > 50) { - for (int i = 0; i < pressed.length; i++) { - if (pressed[i] > 0 && time - pressed[i] > 500) - Do_Key_Event(XLateKey(i, lwjglKeycodeMap[i]), true); - } - lastRepeat = time; - } - } - - private int XLateKey(int code, int ch) - { - int key = 0; + private static int lastRepeat; + private void generateRepeats() { + int time = Globals.sys_frame_time; + if (time - lastRepeat > 50) { + for (int i = 0; i < pressed.length; i++) { + if (pressed[i] > 0 && time - pressed[i] > 500) + Do_Key_Event(XLateKey(i, lwjglKeycodeMap[i]), true); + } + lastRepeat = time; + } + } + + private int XLateKey(int code, int ch) + { + int key = 0; - switch(code) - { -// 00626 case XK_KP_Page_Up: key = K_KP_PGUP; break; - case Keyboard.KEY_PRIOR: key = Key.K_PGUP; break; + switch(code) + { +// 00626 case XK_KP_Page_Up: key = K_KP_PGUP; break; + case Keyboard.KEY_PRIOR: key = Key.K_PGUP; break; -// 00629 case XK_KP_Page_Down: key = K_KP_PGDN; break; - case Keyboard.KEY_NEXT: key = Key.K_PGDN; break; +// 00629 case XK_KP_Page_Down: key = K_KP_PGDN; break; + case Keyboard.KEY_NEXT: key = Key.K_PGDN; break; -// 00632 case XK_KP_Home: key = K_KP_HOME; break; - case Keyboard.KEY_HOME: key = Key.K_HOME; break; +// 00632 case XK_KP_Home: key = K_KP_HOME; break; + case Keyboard.KEY_HOME: key = Key.K_HOME; break; -// 00635 case XK_KP_End: key = K_KP_END; break; - case Keyboard.KEY_END: key = Key.K_END; break; +// 00635 case XK_KP_End: key = K_KP_END; break; + case Keyboard.KEY_END: key = Key.K_END; break; - // case Keyboard.KEY_LEFT: key = Key.K_KP_LEFTARROW; break; - case Keyboard.KEY_LEFT: key = Key.K_LEFTARROW; break; + // case Keyboard.KEY_LEFT: key = Key.K_KP_LEFTARROW; break; + case Keyboard.KEY_LEFT: key = Key.K_LEFTARROW; break; - // case Keyboard.KEY_RIGHT: key = Key.K_KP_RIGHTARROW; break; - case Keyboard.KEY_RIGHT: key = Key.K_RIGHTARROW; break; + // case Keyboard.KEY_RIGHT: key = Key.K_KP_RIGHTARROW; break; + case Keyboard.KEY_RIGHT: key = Key.K_RIGHTARROW; break; - // case Keyboard.KEY_DOWN: key = Key.K_KP_DOWNARROW; break; - case Keyboard.KEY_DOWN: key = Key.K_DOWNARROW; break; + // case Keyboard.KEY_DOWN: key = Key.K_KP_DOWNARROW; break; + case Keyboard.KEY_DOWN: key = Key.K_DOWNARROW; break; - // case Keyboard.KEY_UP: key = Key.K_KP_UPARROW; break; - case Keyboard.KEY_UP: key = Key.K_UPARROW; break; + // case Keyboard.KEY_UP: key = Key.K_KP_UPARROW; break; + case Keyboard.KEY_UP: key = Key.K_UPARROW; break; - case Keyboard.KEY_ESCAPE: key = Key.K_ESCAPE; break; + case Keyboard.KEY_ESCAPE: key = Key.K_ESCAPE; break; - - case Keyboard.KEY_RETURN: key = Key.K_ENTER; break; -// 00652 case XK_KP_Enter: key = K_KP_ENTER; break; + + case Keyboard.KEY_RETURN: key = Key.K_ENTER; break; +// 00652 case XK_KP_Enter: key = K_KP_ENTER; break; - case Keyboard.KEY_TAB: key = Key.K_TAB; break; + case Keyboard.KEY_TAB: key = Key.K_TAB; break; - case Keyboard.KEY_F1: key = Key.K_F1; break; - case Keyboard.KEY_F2: key = Key.K_F2; break; - case Keyboard.KEY_F3: key = Key.K_F3; break; - case Keyboard.KEY_F4: key = Key.K_F4; break; - case Keyboard.KEY_F5: key = Key.K_F5; break; - case Keyboard.KEY_F6: key = Key.K_F6; break; - case Keyboard.KEY_F7: key = Key.K_F7; break; - case Keyboard.KEY_F8: key = Key.K_F8; break; - case Keyboard.KEY_F9: key = Key.K_F9; break; - case Keyboard.KEY_F10: key = Key.K_F10; break; - case Keyboard.KEY_F11: key = Key.K_F11; break; - case Keyboard.KEY_F12: key = Key.K_F12; break; + case Keyboard.KEY_F1: key = Key.K_F1; break; + case Keyboard.KEY_F2: key = Key.K_F2; break; + case Keyboard.KEY_F3: key = Key.K_F3; break; + case Keyboard.KEY_F4: key = Key.K_F4; break; + case Keyboard.KEY_F5: key = Key.K_F5; break; + case Keyboard.KEY_F6: key = Key.K_F6; break; + case Keyboard.KEY_F7: key = Key.K_F7; break; + case Keyboard.KEY_F8: key = Key.K_F8; break; + case Keyboard.KEY_F9: key = Key.K_F9; break; + case Keyboard.KEY_F10: key = Key.K_F10; break; + case Keyboard.KEY_F11: key = Key.K_F11; break; + case Keyboard.KEY_F12: key = Key.K_F12; break; - case Keyboard.KEY_BACK: key = Key.K_BACKSPACE; break; + case Keyboard.KEY_BACK: key = Key.K_BACKSPACE; break; - case Keyboard.KEY_DELETE: key = Key.K_DEL; break; -// 00683 case XK_KP_Delete: key = K_KP_DEL; break; + case Keyboard.KEY_DELETE: key = Key.K_DEL; break; +// 00683 case XK_KP_Delete: key = K_KP_DEL; break; - case Keyboard.KEY_PAUSE: key = Key.K_PAUSE; break; - - case Keyboard.KEY_RSHIFT: - case Keyboard.KEY_LSHIFT: key = Key.K_SHIFT; break; - - case Keyboard.KEY_RCONTROL: - case Keyboard.KEY_LCONTROL: key = Key.K_CTRL; break; - - case Keyboard.KEY_LMENU: - case Keyboard.KEY_RMENU: key = Key.K_ALT; break; + case Keyboard.KEY_PAUSE: key = Key.K_PAUSE; break; + + case Keyboard.KEY_RSHIFT: + case Keyboard.KEY_LSHIFT: key = Key.K_SHIFT; break; + + case Keyboard.KEY_RCONTROL: + case Keyboard.KEY_LCONTROL: key = Key.K_CTRL; break; + + case Keyboard.KEY_LMENU: + case Keyboard.KEY_RMENU: key = Key.K_ALT; break; -// 00700 case XK_KP_Begin: key = K_KP_5; break; -// 00701 - case Keyboard.KEY_INSERT: key = Key.K_INS; break; - // toggle console for DE and US keyboards - case Keyboard.KEY_GRAVE: - case Keyboard.KEY_CIRCUMFLEX: key = '`'; break; +// 00700 case XK_KP_Begin: key = K_KP_5; break; +// 00701 + case Keyboard.KEY_INSERT: key = Key.K_INS; break; + // toggle console for DE and US keyboards + case Keyboard.KEY_GRAVE: + case Keyboard.KEY_CIRCUMFLEX: key = '`'; break; - default: - key = lwjglKeycodeMap[code]; - if (key >= 'A' && key <= 'Z') - key = key - 'A' + 'a'; - break; - } - if (key > 255) key = 0; - return key; - } - - public void Do_Key_Event(int key, boolean down) { - Key.Event(key, down, Timer.Milliseconds()); - } - - public void installGrabs() - { - Mouse.setGrabbed(true); - } - - public void uninstallGrabs() - { - Mouse.setGrabbed(false); - } + default: + key = lwjglKeycodeMap[code]; + if (key >= 'A' && key <= 'Z') + key = key - 'A' + 'a'; + break; + } + if (key > 255) key = 0; + return key; + } + + public void Do_Key_Event(int key, boolean down) { + Key.Event(key, down, Timer.Milliseconds()); + } + + public void installGrabs() + { + Mouse.setGrabbed(true); + } + + public void uninstallGrabs() + { + Mouse.setGrabbed(false); + } } diff --git a/src/main/java/lwjake2/sys/LWJake2InputEvent.java b/src/main/java/lwjake2/sys/LWJake2InputEvent.java index 110f13e..14cda88 100644 --- a/src/main/java/lwjake2/sys/LWJake2InputEvent.java +++ b/src/main/java/lwjake2/sys/LWJake2InputEvent.java @@ -24,19 +24,19 @@ import java.awt.AWTEvent; * LWJake2InputEvent */ class LWJake2InputEvent { - static final int KeyPress = 0; - static final int KeyRelease = 1; - static final int MotionNotify = 2; - static final int ButtonPress = 3; - static final int ButtonRelease = 4; - static final int CreateNotify = 5; - static final int ConfigureNotify = 6; - static final int WheelMoved = 7; - int type; - AWTEvent ev; - - LWJake2InputEvent(int type, AWTEvent ev) { - this.type = type; - this.ev = ev; - } + static final int KeyPress = 0; + static final int KeyRelease = 1; + static final int MotionNotify = 2; + static final int ButtonPress = 3; + static final int ButtonRelease = 4; + static final int CreateNotify = 5; + static final int ConfigureNotify = 6; + static final int WheelMoved = 7; + int type; + AWTEvent ev; + + LWJake2InputEvent(int type, AWTEvent ev) { + this.type = type; + this.ev = ev; + } } diff --git a/src/main/java/lwjake2/sys/NET.java b/src/main/java/lwjake2/sys/NET.java index aaae6d2..fa0bdd2 100644 --- a/src/main/java/lwjake2/sys/NET.java +++ b/src/main/java/lwjake2/sys/NET.java @@ -381,12 +381,12 @@ public final class NET { * extern qboolean stdin_active; * * if (!ip_sockets[NS_SERVER] || (dedicated && !dedicated.value)) - * return; // we're not a server, just run full speed + * return; // we're not a server, just run full speed * * FD_ZERO(&fdset); * * if (stdin_active) - * FD_SET(0, &fdset); // stdin is processed too + * FD_SET(0, &fdset); // stdin is processed too * * FD_SET(ip_sockets[NS_SERVER], &fdset); // network socket * diff --git a/src/main/java/lwjake2/sys/NanoTimer.java b/src/main/java/lwjake2/sys/NanoTimer.java index e3c6ba5..661ac49 100644 --- a/src/main/java/lwjake2/sys/NanoTimer.java +++ b/src/main/java/lwjake2/sys/NanoTimer.java @@ -20,19 +20,19 @@ package lwjake2.sys; public class NanoTimer extends Timer { - private long base; + private long base; - NanoTimer() { - base = System.nanoTime(); - } - - public long currentTimeMillis() { - long time = System.nanoTime(); - long delta = time - base; - if (delta < 0) { - delta += Long.MAX_VALUE + 1; - } - return (long)(delta * 0.000001); - } + NanoTimer() { + base = System.nanoTime(); + } + + public long currentTimeMillis() { + long time = System.nanoTime(); + long delta = time - base; + if (delta < 0) { + delta += Long.MAX_VALUE + 1; + } + return (long)(delta * 0.000001); + } } diff --git a/src/main/java/lwjake2/sys/StandardTimer.java b/src/main/java/lwjake2/sys/StandardTimer.java index 5eaaca0..f0f63e8 100644 --- a/src/main/java/lwjake2/sys/StandardTimer.java +++ b/src/main/java/lwjake2/sys/StandardTimer.java @@ -20,19 +20,19 @@ package lwjake2.sys; class StandardTimer extends Timer { - private long base; - - StandardTimer() { - base = System.currentTimeMillis(); - } - - public long currentTimeMillis() { - long time = System.currentTimeMillis(); - long delta = time - base; - if (delta < 0) { - delta += Long.MAX_VALUE + 1; - } - return delta; - } + private long base; + + StandardTimer() { + base = System.currentTimeMillis(); + } + + public long currentTimeMillis() { + long time = System.currentTimeMillis(); + long delta = time - base; + if (delta < 0) { + delta += Long.MAX_VALUE + 1; + } + return delta; + } } diff --git a/src/main/java/lwjake2/sys/Sys.java b/src/main/java/lwjake2/sys/Sys.java index 77cb5fd..a8aae4c 100644 --- a/src/main/java/lwjake2/sys/Sys.java +++ b/src/main/java/lwjake2/sys/Sys.java @@ -192,7 +192,7 @@ public final class Sys extends Defines { if (fdir != null) Sys.Error("Sys_BeginFind without close"); - // COM_FilePath (path, findbase); + // COM_FilePath (path, findbase); fdir = FindAll(path, canthave, musthave); fileindex = 0; @@ -216,7 +216,7 @@ public final class Sys extends Defines { } public static void SendKeyEvents() { - Globals.re.getKeyboardHandler().Update(); + Globals.re.getKeyboardHandler().Update(); // grab frame time Globals.sys_frame_time = Timer.Milliseconds(); diff --git a/src/main/java/lwjake2/sys/Timer.java b/src/main/java/lwjake2/sys/Timer.java index 59b3c39..dd15d65 100644 --- a/src/main/java/lwjake2/sys/Timer.java +++ b/src/main/java/lwjake2/sys/Timer.java @@ -23,20 +23,20 @@ import lwjake2.Globals; @Slf4j public abstract class Timer { - abstract public long currentTimeMillis(); - - static Timer t; - - static { - try { - t = new NanoTimer(); - } catch (Throwable e) { - t = new StandardTimer(); - } - log.info("using {}", t.getClass().getName()); - } - - public static int Milliseconds() { - return Globals.curtime = (int)(t.currentTimeMillis()); - } + abstract public long currentTimeMillis(); + + static Timer t; + + static { + try { + t = new NanoTimer(); + } catch (Throwable e) { + t = new StandardTimer(); + } + log.info("using {}", t.getClass().getName()); + } + + public static int Milliseconds() { + return Globals.curtime = (int)(t.currentTimeMillis()); + } } diff --git a/src/main/java/lwjake2/util/Lib.java b/src/main/java/lwjake2/util/Lib.java index 9ec91be..626f72d 100644 --- a/src/main/java/lwjake2/util/Lib.java +++ b/src/main/java/lwjake2/util/Lib.java @@ -35,275 +35,275 @@ import java.nio.IntBuffer; @Slf4j public class Lib { - private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); - /** Converts a vector to a string. */ - public static String vtos(float[] v) { - return (int) v[0] + " " + (int) v[1] + " " + (int) v[2]; - } - - /** Converts a vector to a string. */ - public static String vtofs(float[] v) { - return v[0] + " " + v[1] + " " + v[2]; - } - - /** Converts a vector to a beatiful string. */ - public static String vtofsbeaty(float[] v) { - return Com.sprintf("%8.2f %8.2f %8.2f", new Vargs().add(v[0]).add(v[1]).add(v[2])); - } - - /** Like in libc. */ - public static short rand() { - return (short)Globals.rnd.nextInt(Short.MAX_VALUE+1); - } - - /** Like in libc. */ - public static float crandom() { - return (Globals.rnd.nextFloat() - 0.5f) * 2.0f; - } - - /** Like in libc. */ - public static float random() { - return Globals.rnd.nextFloat(); - } - - /** Like in libc. */ - public static float crand() { - return (Globals.rnd.nextFloat() - 0.5f) * 2.0f; - } - - /** Like in libc. */ - public static int strcmp(String in1, String in2) { - return in1.compareTo(in2); - } + private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); + /** Converts a vector to a string. */ + public static String vtos(float[] v) { + return (int) v[0] + " " + (int) v[1] + " " + (int) v[2]; + } + + /** Converts a vector to a string. */ + public static String vtofs(float[] v) { + return v[0] + " " + v[1] + " " + v[2]; + } + + /** Converts a vector to a beatiful string. */ + public static String vtofsbeaty(float[] v) { + return Com.sprintf("%8.2f %8.2f %8.2f", new Vargs().add(v[0]).add(v[1]).add(v[2])); + } + + /** Like in libc. */ + public static short rand() { + return (short)Globals.rnd.nextInt(Short.MAX_VALUE+1); + } + + /** Like in libc. */ + public static float crandom() { + return (Globals.rnd.nextFloat() - 0.5f) * 2.0f; + } + + /** Like in libc. */ + public static float random() { + return Globals.rnd.nextFloat(); + } + + /** Like in libc. */ + public static float crand() { + return (Globals.rnd.nextFloat() - 0.5f) * 2.0f; + } + + /** Like in libc. */ + public static int strcmp(String in1, String in2) { + return in1.compareTo(in2); + } - /** Like in libc. */ - public static float atof(String in) { - float res = 0; - - try { - res = Float.parseFloat(in); - } - catch (Exception e) { - } - - return res; - } - - /** Like in quake2. */ - public static int Q_stricmp(String in1, String in2) { - return in1.compareToIgnoreCase(in2); - } - - /** Like in libc. */ - public static int atoi(String in) { - try { - return Integer.parseInt(in); - } - catch (Exception e) { - try { - return (int)Double.parseDouble(in); - } catch (Exception e1) { - return 0; - } - } - } - - /** Converts a string to a vector. Needs improvement. */ - public static float[] atov(String v) { - float[] res = { 0, 0, 0 }; - String strres[] = v.split(" "); - for (int n=0; n < 3 && n < strres.length; n++) - { - res[n] = atof(strres[n]); - } - return res; - } + /** Like in libc. */ + public static float atof(String in) { + float res = 0; + + try { + res = Float.parseFloat(in); + } + catch (Exception e) { + } + + return res; + } + + /** Like in quake2. */ + public static int Q_stricmp(String in1, String in2) { + return in1.compareToIgnoreCase(in2); + } + + /** Like in libc. */ + public static int atoi(String in) { + try { + return Integer.parseInt(in); + } + catch (Exception e) { + try { + return (int)Double.parseDouble(in); + } catch (Exception e1) { + return 0; + } + } + } + + /** Converts a string to a vector. Needs improvement. */ + public static float[] atov(String v) { + float[] res = { 0, 0, 0 }; + String strres[] = v.split(" "); + for (int n=0; n < 3 && n < strres.length; n++) + { + res[n] = atof(strres[n]); + } + return res; + } - /** Like in libc. */ - public static int strlen(char in[]) { - for (int i = 0; i < in.length; i++) - if (in[i] == 0) - return i; - return in.length; - } - - /** Like in libc. */ - public static int strlen(byte in[]) { - for (int i = 0; i < in.length; i++) - if (in[i] == 0) - return i; - return in.length; - } + /** Like in libc. */ + public static int strlen(char in[]) { + for (int i = 0; i < in.length; i++) + if (in[i] == 0) + return i; + return in.length; + } + + /** Like in libc. */ + public static int strlen(byte in[]) { + for (int i = 0; i < in.length; i++) + if (in[i] == 0) + return i; + return in.length; + } - /** Converts memory to a memory dump string. */ - public static String hexdumpfile(ByteBuffer bb, int len) throws IOException { - - ByteBuffer bb1 = bb.slice(); - - byte buf[] = new byte[len]; - - bb1.get(buf); - - return hexDump(buf, len, false); - } - - /** Converts memory to a memory dump string. */ - public static String hexDump(byte data1[], int len, boolean showAddress) { - StringBuffer result = new StringBuffer(); - StringBuffer charfield = new StringBuffer(); - int i = 0; - while (i < len) { - if ((i & 0xf) == 0) { - if (showAddress) { - String address = Integer.toHexString(i); - address = ("0000".substring(0, 4 - address.length()) + address).toUpperCase(); - result.append(address + ": "); - } - } - int v = data1[i]; - - result.append(hex2(v)); - result.append(" "); - - charfield.append(readableChar(v)); - i++; - - // nach dem letzten, newline einfuegen - if ((i & 0xf) == 0) { - result.append(charfield); - result.append("\n"); - charfield.setLength(0); - } - // in der Mitte ein Luecke einfuegen ? - else if ((i & 0xf) == 8) { - result.append(" "); - } - } - return result.toString(); - } - - /** Formats an hex byte. */ - public static String hex2(int i) { - String val = Integer.toHexString(i & 0xff); - return ("00".substring(0, 2 - val.length()) + val).toUpperCase(); - } - - /** Returns true if the char is alphanumeric. */ - public static char readableChar(int i) { - if ((i < 0x20) || (i > 0x7f)) - return '.'; - else - return (char) i; - } - - /** Prints a vector to the quake console. */ - public static void printv(String in, float arr[]) { - for (int n = 0; n < arr.length; n++) { - log.info("{}[{}]: {}", in, n, arr[n]); - } - } - - static final byte nullfiller[] = new byte[8192]; - - /** Like in libc. */ - public static void fwriteString(String s, int len, RandomAccessFile f) throws IOException { - if (s == null) - return; - int diff = len - s.length(); - if (diff > 0) { - f.write(stringToBytes(s)); - - f.write(nullfiller, 0, diff); - } - else - f.write(stringToBytes(s), 0, len); - } - - /** Like in libc */ - public static RandomAccessFile fopen(String name, String mode) { - try { - return new RandomAccessFile(name, mode); - } - catch (Exception e) { - Com.DPrintf("Could not open file:" + name); - return null; - } - } - - /** Like in libc */ - public static void fclose(RandomAccessFile f) { - try { - f.close(); - } - catch (Exception e) { - } - } - - /** Like in libc */ - public static String freadString(RandomAccessFile f, int len) { - byte buffer[] = new byte[len]; - fileSystem.read(buffer, len, f); - - return Lib.CtoJava(buffer); - } - - /** Returns the right part of the string from the last occruence of c. */ - public static String rightFrom(String in, char c) { - int pos = in.lastIndexOf(c); - if (pos == -1) - return ""; - else if (pos < in.length()) - return in.substring(pos + 1, in.length()); - return ""; - } - - /** Returns the left part of the string from the last occruence of c. */ - public static String leftFrom(String in, char c) { - int pos = in.lastIndexOf(c); - if (pos == -1) - return ""; - else if (pos < in.length()) - return in.substring(0, pos); - return ""; - } + /** Converts memory to a memory dump string. */ + public static String hexdumpfile(ByteBuffer bb, int len) throws IOException { + + ByteBuffer bb1 = bb.slice(); + + byte buf[] = new byte[len]; + + bb1.get(buf); + + return hexDump(buf, len, false); + } + + /** Converts memory to a memory dump string. */ + public static String hexDump(byte data1[], int len, boolean showAddress) { + StringBuffer result = new StringBuffer(); + StringBuffer charfield = new StringBuffer(); + int i = 0; + while (i < len) { + if ((i & 0xf) == 0) { + if (showAddress) { + String address = Integer.toHexString(i); + address = ("0000".substring(0, 4 - address.length()) + address).toUpperCase(); + result.append(address + ": "); + } + } + int v = data1[i]; + + result.append(hex2(v)); + result.append(" "); + + charfield.append(readableChar(v)); + i++; + + // nach dem letzten, newline einfuegen + if ((i & 0xf) == 0) { + result.append(charfield); + result.append("\n"); + charfield.setLength(0); + } + // in der Mitte ein Luecke einfuegen ? + else if ((i & 0xf) == 8) { + result.append(" "); + } + } + return result.toString(); + } + + /** Formats an hex byte. */ + public static String hex2(int i) { + String val = Integer.toHexString(i & 0xff); + return ("00".substring(0, 2 - val.length()) + val).toUpperCase(); + } + + /** Returns true if the char is alphanumeric. */ + public static char readableChar(int i) { + if ((i < 0x20) || (i > 0x7f)) + return '.'; + else + return (char) i; + } + + /** Prints a vector to the quake console. */ + public static void printv(String in, float arr[]) { + for (int n = 0; n < arr.length; n++) { + log.info("{}[{}]: {}", in, n, arr[n]); + } + } + + static final byte nullfiller[] = new byte[8192]; + + /** Like in libc. */ + public static void fwriteString(String s, int len, RandomAccessFile f) throws IOException { + if (s == null) + return; + int diff = len - s.length(); + if (diff > 0) { + f.write(stringToBytes(s)); + + f.write(nullfiller, 0, diff); + } + else + f.write(stringToBytes(s), 0, len); + } + + /** Like in libc */ + public static RandomAccessFile fopen(String name, String mode) { + try { + return new RandomAccessFile(name, mode); + } + catch (Exception e) { + Com.DPrintf("Could not open file:" + name); + return null; + } + } + + /** Like in libc */ + public static void fclose(RandomAccessFile f) { + try { + f.close(); + } + catch (Exception e) { + } + } + + /** Like in libc */ + public static String freadString(RandomAccessFile f, int len) { + byte buffer[] = new byte[len]; + fileSystem.read(buffer, len, f); + + return Lib.CtoJava(buffer); + } + + /** Returns the right part of the string from the last occruence of c. */ + public static String rightFrom(String in, char c) { + int pos = in.lastIndexOf(c); + if (pos == -1) + return ""; + else if (pos < in.length()) + return in.substring(pos + 1, in.length()); + return ""; + } + + /** Returns the left part of the string from the last occruence of c. */ + public static String leftFrom(String in, char c) { + int pos = in.lastIndexOf(c); + if (pos == -1) + return ""; + else if (pos < in.length()) + return in.substring(0, pos); + return ""; + } - /** Renames a file. */ - public static int rename(String oldn, String newn) { - try { - File f1 = new File(oldn); - File f2 = new File(newn); - f1.renameTo(f2); - return 0; - } - catch (Exception e) { - return 1; - } - } - - /** Converts an int to 4 bytes java representation. */ - public static byte[] getIntBytes(int c) { - byte b[] = new byte[4]; - b[0] = (byte) ((c & 0xff)); - b[1] = (byte) ((c >>> 8) & 0xff); - b[2] = (byte) ((c >>> 16) & 0xff); - b[3] = (byte) ((c >>> 24) & 0xff); - return b; - } - - /** Converts an 4 bytes java int representation to an int. */ - public static int getInt(byte b[]) { - return (b[0] & 0xff) | ((b[1] & 0xff) << 8) | ((b[2] & 0xff) << 16) | ((b[3] & 0xff) << 24); - } - - /** Duplicates a float array. */ - public static float[] clone(float in[]) { - float out[] = new float[in.length]; - - if (in.length != 0) - System.arraycopy(in, 0, out, 0, in.length); - - return out; - } + /** Renames a file. */ + public static int rename(String oldn, String newn) { + try { + File f1 = new File(oldn); + File f2 = new File(newn); + f1.renameTo(f2); + return 0; + } + catch (Exception e) { + return 1; + } + } + + /** Converts an int to 4 bytes java representation. */ + public static byte[] getIntBytes(int c) { + byte b[] = new byte[4]; + b[0] = (byte) ((c & 0xff)); + b[1] = (byte) ((c >>> 8) & 0xff); + b[2] = (byte) ((c >>> 16) & 0xff); + b[3] = (byte) ((c >>> 24) & 0xff); + return b; + } + + /** Converts an 4 bytes java int representation to an int. */ + public static int getInt(byte b[]) { + return (b[0] & 0xff) | ((b[1] & 0xff) << 8) | ((b[2] & 0xff) << 16) | ((b[3] & 0xff) << 24); + } + + /** Duplicates a float array. */ + public static float[] clone(float in[]) { + float out[] = new float[in.length]; + + if (in.length != 0) + System.arraycopy(in, 0, out, 0, in.length); + + return out; + } /** * convert a java string to byte[] with 8bit latin 1 @@ -332,57 +332,57 @@ public class Lib { return null; } } - - /** Helper method that savely handles the null termination of old C String data. */ - public static String CtoJava(String old) { - int index = old.indexOf('\0'); - if (index == 0) return ""; - return (index > 0) ? old.substring(0, index) : old; - } - - /** Helper method that savely handles the null termination of old C String data. */ - public static String CtoJava(byte[] old) { - return CtoJava(old, 0, old.length); - } + + /** Helper method that savely handles the null termination of old C String data. */ + public static String CtoJava(String old) { + int index = old.indexOf('\0'); + if (index == 0) return ""; + return (index > 0) ? old.substring(0, index) : old; + } + + /** Helper method that savely handles the null termination of old C String data. */ + public static String CtoJava(byte[] old) { + return CtoJava(old, 0, old.length); + } - /** Helper method that savely handles the null termination of old C String data. */ - public static String CtoJava(byte[] old, int offset, int maxLenght) { - if (old.length == 0 || old[0] == 0) return ""; - int i; - for (i = offset; (i - offset) < maxLenght && old[i] != 0; i++); - return new String(old, offset, i - offset); - } - - - /* java.nio.* Buffer util functions */ - - public static final int SIZEOF_FLOAT = 4; - public static final int SIZEOF_INT = 4; - - public static FloatBuffer newFloatBuffer(int numElements) { - ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT); - return bb.asFloatBuffer(); - } - public static FloatBuffer newFloatBuffer(int numElements, ByteOrder order) { - ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT, order); - return bb.asFloatBuffer(); - } - public static IntBuffer newIntBuffer(int numElements) { - ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT); - return bb.asIntBuffer(); - } - public static IntBuffer newIntBuffer(int numElements, ByteOrder order) { - ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT, order); - return bb.asIntBuffer(); - } - public static ByteBuffer newByteBuffer(int numElements) { - ByteBuffer bb = ByteBuffer.allocateDirect(numElements); - bb.order(ByteOrder.nativeOrder()); - return bb; - } - public static ByteBuffer newByteBuffer(int numElements, ByteOrder order) { - ByteBuffer bb = ByteBuffer.allocateDirect(numElements); - bb.order(order); - return bb; - } + /** Helper method that savely handles the null termination of old C String data. */ + public static String CtoJava(byte[] old, int offset, int maxLenght) { + if (old.length == 0 || old[0] == 0) return ""; + int i; + for (i = offset; (i - offset) < maxLenght && old[i] != 0; i++); + return new String(old, offset, i - offset); + } + + + /* java.nio.* Buffer util functions */ + + public static final int SIZEOF_FLOAT = 4; + public static final int SIZEOF_INT = 4; + + public static FloatBuffer newFloatBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT); + return bb.asFloatBuffer(); + } + public static FloatBuffer newFloatBuffer(int numElements, ByteOrder order) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT, order); + return bb.asFloatBuffer(); + } + public static IntBuffer newIntBuffer(int numElements) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT); + return bb.asIntBuffer(); + } + public static IntBuffer newIntBuffer(int numElements, ByteOrder order) { + ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT, order); + return bb.asIntBuffer(); + } + public static ByteBuffer newByteBuffer(int numElements) { + ByteBuffer bb = ByteBuffer.allocateDirect(numElements); + bb.order(ByteOrder.nativeOrder()); + return bb; + } + public static ByteBuffer newByteBuffer(int numElements, ByteOrder order) { + ByteBuffer bb = ByteBuffer.allocateDirect(numElements); + bb.order(order); + return bb; + } } diff --git a/src/main/java/lwjake2/util/Math3D.java b/src/main/java/lwjake2/util/Math3D.java index fc82cd1..4e82de7 100644 --- a/src/main/java/lwjake2/util/Math3D.java +++ b/src/main/java/lwjake2/util/Math3D.java @@ -24,468 +24,468 @@ import lwjake2.qcommon.Com; public class Math3D { - static final float shortratio = 360.0f / 65536.0f; - static final float piratio = (float) (Math.PI / 360.0); - public static void set(float v1[], float v2[]) { - v1[0] = v2[0]; - v1[1] = v2[1]; - v1[2] = v2[2]; - } - public static void VectorSubtract(float[] a, float[] b, float[] c) { - c[0] = a[0] - b[0]; - c[1] = a[1] - b[1]; - c[2] = a[2] - b[2]; - } - public static void VectorSubtract(short[] a, short[] b, int[] c) { - c[0] = a[0] - b[0]; - c[1] = a[1] - b[1]; - c[2] = a[2] - b[2]; - } - public static void VectorAdd(float[] a, float[] b, float[] to) { - to[0] = a[0] + b[0]; - to[1] = a[1] + b[1]; - to[2] = a[2] + b[2]; - } - public static void VectorCopy(float[] from, float[] to) { - to[0] = from[0]; - to[1] = from[1]; - to[2] = from[2]; - } - public static void VectorCopy(short[] from, short[] to) { - to[0] = from[0]; - to[1] = from[1]; - to[2] = from[2]; - } - public static void VectorCopy(short[] from, float[] to) { - to[0] = from[0]; - to[1] = from[1]; - to[2] = from[2]; - } - public static void VectorCopy(float[] from, short[] to) { - to[0] = (short) from[0]; - to[1] = (short) from[1]; - to[2] = (short) from[2]; - } - public static void VectorClear(float[] a) { - a[0] = a[1] = a[2] = 0; - } - public static boolean VectorEquals(float[] v1, float[] v2) { - if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) - return false; + static final float shortratio = 360.0f / 65536.0f; + static final float piratio = (float) (Math.PI / 360.0); + public static void set(float v1[], float v2[]) { + v1[0] = v2[0]; + v1[1] = v2[1]; + v1[2] = v2[2]; + } + public static void VectorSubtract(float[] a, float[] b, float[] c) { + c[0] = a[0] - b[0]; + c[1] = a[1] - b[1]; + c[2] = a[2] - b[2]; + } + public static void VectorSubtract(short[] a, short[] b, int[] c) { + c[0] = a[0] - b[0]; + c[1] = a[1] - b[1]; + c[2] = a[2] - b[2]; + } + public static void VectorAdd(float[] a, float[] b, float[] to) { + to[0] = a[0] + b[0]; + to[1] = a[1] + b[1]; + to[2] = a[2] + b[2]; + } + public static void VectorCopy(float[] from, float[] to) { + to[0] = from[0]; + to[1] = from[1]; + to[2] = from[2]; + } + public static void VectorCopy(short[] from, short[] to) { + to[0] = from[0]; + to[1] = from[1]; + to[2] = from[2]; + } + public static void VectorCopy(short[] from, float[] to) { + to[0] = from[0]; + to[1] = from[1]; + to[2] = from[2]; + } + public static void VectorCopy(float[] from, short[] to) { + to[0] = (short) from[0]; + to[1] = (short) from[1]; + to[2] = (short) from[2]; + } + public static void VectorClear(float[] a) { + a[0] = a[1] = a[2] = 0; + } + public static boolean VectorEquals(float[] v1, float[] v2) { + if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) + return false; - return true; - } - public static void VectorNegate(float[] from, float[] to) { - to[0] = -from[0]; - to[1] = -from[1]; - to[2] = -from[2]; - } - public static void VectorSet(float[] v, float x, float y, float z) { - v[0] = (x); - v[1] = (y); - v[2] = (z); - } - public static void VectorMA(float[] veca, float scale, float[] vecb, float[] to) { - to[0] = veca[0] + scale * vecb[0]; - to[1] = veca[1] + scale * vecb[1]; - to[2] = veca[2] + scale * vecb[2]; - } - public static final float VectorNormalize(float[] v) { + return true; + } + public static void VectorNegate(float[] from, float[] to) { + to[0] = -from[0]; + to[1] = -from[1]; + to[2] = -from[2]; + } + public static void VectorSet(float[] v, float x, float y, float z) { + v[0] = (x); + v[1] = (y); + v[2] = (z); + } + public static void VectorMA(float[] veca, float scale, float[] vecb, float[] to) { + to[0] = veca[0] + scale * vecb[0]; + to[1] = veca[1] + scale * vecb[1]; + to[2] = veca[2] + scale * vecb[2]; + } + public static final float VectorNormalize(float[] v) { - float length = VectorLength(v); - if (length != 0.0f) { - float ilength = 1.0f / length; - v[0] *= ilength; - v[1] *= ilength; - v[2] *= ilength; - } - return length; - } - public static final float VectorLength(float v[]) { - return (float) Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); - } - public static void VectorInverse(float[] v) { - v[0] = -v[0]; - v[1] = -v[1]; - v[2] = -v[2]; - } - public static void VectorScale(float[] in, float scale, float[] out) { - out[0] = in[0] * scale; - out[1] = in[1] * scale; - out[2] = in[2] * scale; - } - public static float vectoyaw(float[] vec) { - float yaw; + float length = VectorLength(v); + if (length != 0.0f) { + float ilength = 1.0f / length; + v[0] *= ilength; + v[1] *= ilength; + v[2] *= ilength; + } + return length; + } + public static final float VectorLength(float v[]) { + return (float) Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); + } + public static void VectorInverse(float[] v) { + v[0] = -v[0]; + v[1] = -v[1]; + v[2] = -v[2]; + } + public static void VectorScale(float[] in, float scale, float[] out) { + out[0] = in[0] * scale; + out[1] = in[1] * scale; + out[2] = in[2] * scale; + } + public static float vectoyaw(float[] vec) { + float yaw; - if (/*vec[YAW] == 0 &&*/ - vec[Defines.PITCH] == 0) { - yaw = 0; - if (vec[Defines.YAW] > 0) - yaw = 90; - else if (vec[Defines.YAW] < 0) - yaw = -90; - } - else { + if (/*vec[YAW] == 0 &&*/ + vec[Defines.PITCH] == 0) { + yaw = 0; + if (vec[Defines.YAW] > 0) + yaw = 90; + else if (vec[Defines.YAW] < 0) + yaw = -90; + } + else { - yaw = (int) (Math.atan2(vec[Defines.YAW], vec[Defines.PITCH]) * 180 / Math.PI); - if (yaw < 0) - yaw += 360; - } + yaw = (int) (Math.atan2(vec[Defines.YAW], vec[Defines.PITCH]) * 180 / Math.PI); + if (yaw < 0) + yaw += 360; + } - return yaw; - } - public static void vectoangles(float[] value1, float[] angles) { + return yaw; + } + public static void vectoangles(float[] value1, float[] angles) { - float yaw, pitch; + float yaw, pitch; - if (value1[1] == 0 && value1[0] == 0) { - yaw = 0; - if (value1[2] > 0) - pitch = 90; - else - pitch = 270; - } - else { - if (value1[0] != 0) - yaw = (int) (Math.atan2(value1[1], value1[0]) * 180 / Math.PI); - else if (value1[1] > 0) - yaw = 90; - else - yaw = -90; - if (yaw < 0) - yaw += 360; + if (value1[1] == 0 && value1[0] == 0) { + yaw = 0; + if (value1[2] > 0) + pitch = 90; + else + pitch = 270; + } + else { + if (value1[0] != 0) + yaw = (int) (Math.atan2(value1[1], value1[0]) * 180 / Math.PI); + else if (value1[1] > 0) + yaw = 90; + else + yaw = -90; + if (yaw < 0) + yaw += 360; - float forward = (float) Math.sqrt(value1[0] * value1[0] + value1[1] * value1[1]); - pitch = (int) (Math.atan2(value1[2], forward) * 180 / Math.PI); - if (pitch < 0) - pitch += 360; - } + float forward = (float) Math.sqrt(value1[0] * value1[0] + value1[1] * value1[1]); + pitch = (int) (Math.atan2(value1[2], forward) * 180 / Math.PI); + if (pitch < 0) + pitch += 360; + } - angles[Defines.PITCH] = -pitch; - angles[Defines.YAW] = yaw; - angles[Defines.ROLL] = 0; - } - private static float m[][] = new float[3][3]; - private static float im[][] = new float[3][3]; - private static float tmpmat[][] = new float[3][3]; - private static float zrot[][] = new float[3][3]; - - // to reduce garbage - private static final float[] vr = {0, 0, 0}; - private static final float[] vup = {0, 0, 0}; - private static final float[] vf = {0, 0, 0}; + angles[Defines.PITCH] = -pitch; + angles[Defines.YAW] = yaw; + angles[Defines.ROLL] = 0; + } + private static float m[][] = new float[3][3]; + private static float im[][] = new float[3][3]; + private static float tmpmat[][] = new float[3][3]; + private static float zrot[][] = new float[3][3]; + + // to reduce garbage + private static final float[] vr = {0, 0, 0}; + private static final float[] vup = {0, 0, 0}; + private static final float[] vf = {0, 0, 0}; - public static void RotatePointAroundVector(float[] dst, float[] dir, float[] point, float degrees) { - vf[0] = dir[0]; - vf[1] = dir[1]; - vf[2] = dir[2]; + public static void RotatePointAroundVector(float[] dst, float[] dir, float[] point, float degrees) { + vf[0] = dir[0]; + vf[1] = dir[1]; + vf[2] = dir[2]; - PerpendicularVector(vr, dir); - CrossProduct(vr, vf, vup); + PerpendicularVector(vr, dir); + CrossProduct(vr, vf, vup); - m[0][0] = vr[0]; - m[1][0] = vr[1]; - m[2][0] = vr[2]; + m[0][0] = vr[0]; + m[1][0] = vr[1]; + m[2][0] = vr[2]; - m[0][1] = vup[0]; - m[1][1] = vup[1]; - m[2][1] = vup[2]; + m[0][1] = vup[0]; + m[1][1] = vup[1]; + m[2][1] = vup[2]; - m[0][2] = vf[0]; - m[1][2] = vf[1]; - m[2][2] = vf[2]; + m[0][2] = vf[0]; + m[1][2] = vf[1]; + m[2][2] = vf[2]; - im[0][0] = m[0][0]; - im[0][1] = m[1][0]; - im[0][2] = m[2][0]; - im[1][0] = m[0][1]; - im[1][1] = m[1][1]; - im[1][2] = m[2][1]; - im[2][0] = m[0][2]; - im[2][1] = m[1][2]; - im[2][2] = m[2][2]; + im[0][0] = m[0][0]; + im[0][1] = m[1][0]; + im[0][2] = m[2][0]; + im[1][0] = m[0][1]; + im[1][1] = m[1][1]; + im[1][2] = m[2][1]; + im[2][0] = m[0][2]; + im[2][1] = m[1][2]; + im[2][2] = m[2][2]; - zrot[0][2] = zrot[1][2] = zrot[2][0] = zrot[2][1] = 0.0f; + zrot[0][2] = zrot[1][2] = zrot[2][0] = zrot[2][1] = 0.0f; - zrot[2][2] = 1.0F; + zrot[2][2] = 1.0F; - zrot[0][0] = zrot[1][1] = (float) Math.cos(DEG2RAD(degrees)); - zrot[0][1] = (float) Math.sin(DEG2RAD(degrees)); - zrot[1][0] = -zrot[0][1]; + zrot[0][0] = zrot[1][1] = (float) Math.cos(DEG2RAD(degrees)); + zrot[0][1] = (float) Math.sin(DEG2RAD(degrees)); + zrot[1][0] = -zrot[0][1]; - R_ConcatRotations(m, zrot, tmpmat); - R_ConcatRotations(tmpmat, im, zrot); + R_ConcatRotations(m, zrot, tmpmat); + R_ConcatRotations(tmpmat, im, zrot); - for (int i = 0; i < 3; i++) { - dst[i] = zrot[i][0] * point[0] + zrot[i][1] * point[1] + zrot[i][2] * point[2]; - } - } + for (int i = 0; i < 3; i++) { + dst[i] = zrot[i][0] * point[0] + zrot[i][1] * point[1] + zrot[i][2] * point[2]; + } + } - public static void MakeNormalVectors(float[] forward, float[] right, float[] up) { - // this rotate and negat guarantees a vector - // not colinear with the original - right[1] = -forward[0]; - right[2] = forward[1]; - right[0] = forward[2]; + public static void MakeNormalVectors(float[] forward, float[] right, float[] up) { + // this rotate and negat guarantees a vector + // not colinear with the original + right[1] = -forward[0]; + right[2] = forward[1]; + right[0] = forward[2]; - float d = DotProduct(right, forward); - VectorMA(right, -d, forward, right); - VectorNormalize(right); - CrossProduct(right, forward, up); - } - public static float SHORT2ANGLE(int x) { - return (x * shortratio); - } - /* - ================ - R_ConcatTransforms - ================ - */ - public static void R_ConcatTransforms(float in1[][], float in2[][], float out[][]) { - 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[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] + in1[0][2] * in2[2][3] + in1[0][3]; - 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[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] + in1[1][2] * in2[2][3] + in1[1][3]; - 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]; - out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] + in1[2][2] * in2[2][3] + in1[2][3]; - } - /** - * concatenates 2 matrices each [3][3]. - */ - public static void R_ConcatRotations(float in1[][], float in2[][], float out[][]) { - 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]; - } - public static void ProjectPointOnPlane(float[] dst, float[] p, float[] normal) { + float d = DotProduct(right, forward); + VectorMA(right, -d, forward, right); + VectorNormalize(right); + CrossProduct(right, forward, up); + } + public static float SHORT2ANGLE(int x) { + return (x * shortratio); + } + /* + ================ + R_ConcatTransforms + ================ + */ + public static void R_ConcatTransforms(float in1[][], float in2[][], float out[][]) { + 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[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] + in1[0][2] * in2[2][3] + in1[0][3]; + 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[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] + in1[1][2] * in2[2][3] + in1[1][3]; + 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]; + out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] + in1[2][2] * in2[2][3] + in1[2][3]; + } + /** + * concatenates 2 matrices each [3][3]. + */ + public static void R_ConcatRotations(float in1[][], float in2[][], float out[][]) { + 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]; + } + public static void ProjectPointOnPlane(float[] dst, float[] p, float[] normal) { - float inv_denom = 1.0F / DotProduct(normal, normal); + float inv_denom = 1.0F / DotProduct(normal, normal); - float d = DotProduct(normal, p) * inv_denom; + float d = DotProduct(normal, p) * inv_denom; - dst[0] = normal[0] * inv_denom; - dst[1] = normal[1] * inv_denom; - dst[2] = normal[2] * inv_denom; + dst[0] = normal[0] * inv_denom; + dst[1] = normal[1] * inv_denom; + dst[2] = normal[2] * inv_denom; - dst[0] = p[0] - d * dst[0]; - dst[1] = p[1] - d * dst[1]; - dst[2] = p[2] - d * dst[2]; - } - - private static final float[][] PLANE_XYZ = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; - - /** assumes "src" is normalized */ - public static void PerpendicularVector(float[] dst, float[] src) { - int pos; - int i; - float minelem = 1.0F; + dst[0] = p[0] - d * dst[0]; + dst[1] = p[1] - d * dst[1]; + dst[2] = p[2] - d * dst[2]; + } + + private static final float[][] PLANE_XYZ = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; + + /** assumes "src" is normalized */ + public static void PerpendicularVector(float[] dst, float[] src) { + int pos; + int i; + float minelem = 1.0F; - // find the smallest magnitude axially aligned vector - for (pos = 0, i = 0; i < 3; i++) { - if (Math.abs(src[i]) < minelem) { - pos = i; - minelem = Math.abs(src[i]); - } - } - // project the point onto the plane defined by src - ProjectPointOnPlane(dst, PLANE_XYZ[pos], src); + // find the smallest magnitude axially aligned vector + for (pos = 0, i = 0; i < 3; i++) { + if (Math.abs(src[i]) < minelem) { + pos = i; + minelem = Math.abs(src[i]); + } + } + // project the point onto the plane defined by src + ProjectPointOnPlane(dst, PLANE_XYZ[pos], src); - //normalize the result - VectorNormalize(dst); - } - //===================================================================== - /** - stellt fest, auf welcher Seite sich die Kiste befindet, wenn die Ebene - durch Entfernung und Senkrechten-Normale gegeben ist. - erste Version mit vec3_t... */ - public static final int BoxOnPlaneSide(float emins[], float emaxs[], cplane_t p) { + //normalize the result + VectorNormalize(dst); + } + //===================================================================== + /** + stellt fest, auf welcher Seite sich die Kiste befindet, wenn die Ebene + durch Entfernung und Senkrechten-Normale gegeben ist. + erste Version mit vec3_t... */ + public static final int BoxOnPlaneSide(float emins[], float emaxs[], cplane_t p) { - assert(emins.length == 3 && emaxs.length == 3) : "vec3_t bug"; + assert(emins.length == 3 && emaxs.length == 3) : "vec3_t bug"; - float dist1, dist2; - int sides; + float dist1, dist2; + int sides; - // fast axial cases - if (p.type < 3) { - if (p.dist <= emins[p.type]) - return 1; - if (p.dist >= emaxs[p.type]) - return 2; - return 3; - } + // fast axial cases + if (p.type < 3) { + if (p.dist <= emins[p.type]) + return 1; + if (p.dist >= emaxs[p.type]) + return 2; + return 3; + } - // general case - switch (p.signbits) { - case 0 : - dist1 = p.normal[0] * emaxs[0] + p.normal[1] * emaxs[1] + p.normal[2] * emaxs[2]; - dist2 = p.normal[0] * emins[0] + p.normal[1] * emins[1] + p.normal[2] * emins[2]; - break; - case 1 : - dist1 = p.normal[0] * emins[0] + p.normal[1] * emaxs[1] + p.normal[2] * emaxs[2]; - dist2 = p.normal[0] * emaxs[0] + p.normal[1] * emins[1] + p.normal[2] * emins[2]; - break; - case 2 : - dist1 = p.normal[0] * emaxs[0] + p.normal[1] * emins[1] + p.normal[2] * emaxs[2]; - dist2 = p.normal[0] * emins[0] + p.normal[1] * emaxs[1] + p.normal[2] * emins[2]; - break; - case 3 : - dist1 = p.normal[0] * emins[0] + p.normal[1] * emins[1] + p.normal[2] * emaxs[2]; - dist2 = p.normal[0] * emaxs[0] + p.normal[1] * emaxs[1] + p.normal[2] * emins[2]; - break; - case 4 : - dist1 = p.normal[0] * emaxs[0] + p.normal[1] * emaxs[1] + p.normal[2] * emins[2]; - dist2 = p.normal[0] * emins[0] + p.normal[1] * emins[1] + p.normal[2] * emaxs[2]; - break; - case 5 : - dist1 = p.normal[0] * emins[0] + p.normal[1] * emaxs[1] + p.normal[2] * emins[2]; - dist2 = p.normal[0] * emaxs[0] + p.normal[1] * emins[1] + p.normal[2] * emaxs[2]; - break; - case 6 : - dist1 = p.normal[0] * emaxs[0] + p.normal[1] * emins[1] + p.normal[2] * emins[2]; - dist2 = p.normal[0] * emins[0] + p.normal[1] * emaxs[1] + p.normal[2] * emaxs[2]; - break; - case 7 : - dist1 = p.normal[0] * emins[0] + p.normal[1] * emins[1] + p.normal[2] * emins[2]; - dist2 = p.normal[0] * emaxs[0] + p.normal[1] * emaxs[1] + p.normal[2] * emaxs[2]; - break; - default : - dist1 = dist2 = 0; - assert(false) : "BoxOnPlaneSide bug"; - break; - } + // general case + switch (p.signbits) { + case 0 : + dist1 = p.normal[0] * emaxs[0] + p.normal[1] * emaxs[1] + p.normal[2] * emaxs[2]; + dist2 = p.normal[0] * emins[0] + p.normal[1] * emins[1] + p.normal[2] * emins[2]; + break; + case 1 : + dist1 = p.normal[0] * emins[0] + p.normal[1] * emaxs[1] + p.normal[2] * emaxs[2]; + dist2 = p.normal[0] * emaxs[0] + p.normal[1] * emins[1] + p.normal[2] * emins[2]; + break; + case 2 : + dist1 = p.normal[0] * emaxs[0] + p.normal[1] * emins[1] + p.normal[2] * emaxs[2]; + dist2 = p.normal[0] * emins[0] + p.normal[1] * emaxs[1] + p.normal[2] * emins[2]; + break; + case 3 : + dist1 = p.normal[0] * emins[0] + p.normal[1] * emins[1] + p.normal[2] * emaxs[2]; + dist2 = p.normal[0] * emaxs[0] + p.normal[1] * emaxs[1] + p.normal[2] * emins[2]; + break; + case 4 : + dist1 = p.normal[0] * emaxs[0] + p.normal[1] * emaxs[1] + p.normal[2] * emins[2]; + dist2 = p.normal[0] * emins[0] + p.normal[1] * emins[1] + p.normal[2] * emaxs[2]; + break; + case 5 : + dist1 = p.normal[0] * emins[0] + p.normal[1] * emaxs[1] + p.normal[2] * emins[2]; + dist2 = p.normal[0] * emaxs[0] + p.normal[1] * emins[1] + p.normal[2] * emaxs[2]; + break; + case 6 : + dist1 = p.normal[0] * emaxs[0] + p.normal[1] * emins[1] + p.normal[2] * emins[2]; + dist2 = p.normal[0] * emins[0] + p.normal[1] * emaxs[1] + p.normal[2] * emaxs[2]; + break; + case 7 : + dist1 = p.normal[0] * emins[0] + p.normal[1] * emins[1] + p.normal[2] * emins[2]; + dist2 = p.normal[0] * emaxs[0] + p.normal[1] * emaxs[1] + p.normal[2] * emaxs[2]; + break; + default : + dist1 = dist2 = 0; + assert(false) : "BoxOnPlaneSide bug"; + break; + } - sides = 0; - if (dist1 >= p.dist) - sides = 1; - if (dist2 < p.dist) - sides |= 2; + sides = 0; + if (dist1 >= p.dist) + sides = 1; + if (dist2 < p.dist) + sides |= 2; - assert(sides != 0) : "BoxOnPlaneSide(): sides == 0 bug"; + assert(sides != 0) : "BoxOnPlaneSide(): sides == 0 bug"; - return sides; - } - // this is the slow, general version - private static float corners[][] = new float[2][3]; - public static final int BoxOnPlaneSide2(float[] emins, float[] emaxs, cplane_t p) { + return sides; + } + // this is the slow, general version + private static float corners[][] = new float[2][3]; + public static final int BoxOnPlaneSide2(float[] emins, float[] emaxs, cplane_t p) { - for (int i = 0; i < 3; i++) { - if (p.normal[i] < 0) { - corners[0][i] = emins[i]; - corners[1][i] = emaxs[i]; - } - else { - corners[1][i] = emins[i]; - corners[0][i] = emaxs[i]; - } - } - float dist1 = DotProduct(p.normal, corners[0]) - p.dist; - float dist2 = DotProduct(p.normal, corners[1]) - p.dist; - int sides = 0; - if (dist1 >= 0) - sides = 1; - if (dist2 < 0) - sides |= 2; + for (int i = 0; i < 3; i++) { + if (p.normal[i] < 0) { + corners[0][i] = emins[i]; + corners[1][i] = emaxs[i]; + } + else { + corners[1][i] = emins[i]; + corners[0][i] = emaxs[i]; + } + } + float dist1 = DotProduct(p.normal, corners[0]) - p.dist; + float dist2 = DotProduct(p.normal, corners[1]) - p.dist; + int sides = 0; + if (dist1 >= 0) + sides = 1; + if (dist2 < 0) + sides |= 2; - return sides; - } - public static void AngleVectors(float[] angles, float[] forward, float[] right, float[] up) { + return sides; + } + public static void AngleVectors(float[] angles, float[] forward, float[] right, float[] up) { - float cr = 2.0f * piratio; - float angle = (float) (angles[Defines.YAW] * (cr)); - float sy = (float) Math.sin(angle); - float cy = (float) Math.cos(angle); - angle = (float) (angles[Defines.PITCH] * (cr)); - float sp = (float) Math.sin(angle); - float cp = (float) Math.cos(angle); + float cr = 2.0f * piratio; + float angle = (float) (angles[Defines.YAW] * (cr)); + float sy = (float) Math.sin(angle); + float cy = (float) Math.cos(angle); + angle = (float) (angles[Defines.PITCH] * (cr)); + float sp = (float) Math.sin(angle); + float cp = (float) Math.cos(angle); - if (forward != null) { - forward[0] = cp * cy; - forward[1] = cp * sy; - forward[2] = -sp; - } + if (forward != null) { + forward[0] = cp * cy; + forward[1] = cp * sy; + forward[2] = -sp; + } - if (right != null || up != null) { - angle = (float) (angles[Defines.ROLL] * (cr)); - float sr = (float) Math.sin(angle); - cr = (float) Math.cos(angle); + if (right != null || up != null) { + angle = (float) (angles[Defines.ROLL] * (cr)); + float sr = (float) Math.sin(angle); + cr = (float) Math.cos(angle); - if (right != null) { - right[0] = (-sr * sp * cy + cr * sy); - right[1] = (-sr * sp * sy + -cr * cy); - right[2] = -sr * cp; - } - if (up != null) { - up[0] = (cr * sp * cy + sr * sy); - up[1] = (cr * sp * sy + -sr * cy); - up[2] = cr * cp; - } - } - } - public static void G_ProjectSource( - float[] point, - float[] distance, - float[] forward, - float[] right, - float[] result) { - result[0] = point[0] + forward[0] * distance[0] + right[0] * distance[1]; - result[1] = point[1] + forward[1] * distance[0] + right[1] * distance[1]; - result[2] = point[2] + forward[2] * distance[0] + right[2] * distance[1] + distance[2]; - } - public static final float DotProduct(float[] x, float[] y) { - return x[0] * y[0] + x[1] * y[1] + x[2] * y[2]; - } - public static void CrossProduct(float[] v1, float[] v2, float[] cross) { - cross[0] = v1[1] * v2[2] - v1[2] * v2[1]; - cross[1] = v1[2] * v2[0] - v1[0] * v2[2]; - cross[2] = v1[0] * v2[1] - v1[1] * v2[0]; - } - public static int Q_log2(int val) { - int answer = 0; - while ((val >>= 1) > 0) - answer++; - return answer; - } - public static float DEG2RAD(float in) { - return (in * (float) Math.PI) / 180.0f; - } - public static float anglemod(float a) { - return (float) (shortratio) * ((int) (a / (shortratio)) & 65535); - } - public static int ANGLE2SHORT(float x) { - return ((int) ((x) / shortratio) & 65535); - } - public static float LerpAngle(float a2, float a1, float frac) { - if (a1 - a2 > 180) - a1 -= 360; - if (a1 - a2 < -180) - a1 += 360; - return a2 + frac * (a1 - a2); - } - public static float CalcFov(float fov_x, float width, float height) { - double a = 0.0f; - double x; + if (right != null) { + right[0] = (-sr * sp * cy + cr * sy); + right[1] = (-sr * sp * sy + -cr * cy); + right[2] = -sr * cp; + } + if (up != null) { + up[0] = (cr * sp * cy + sr * sy); + up[1] = (cr * sp * sy + -sr * cy); + up[2] = cr * cp; + } + } + } + public static void G_ProjectSource( + float[] point, + float[] distance, + float[] forward, + float[] right, + float[] result) { + result[0] = point[0] + forward[0] * distance[0] + right[0] * distance[1]; + result[1] = point[1] + forward[1] * distance[0] + right[1] * distance[1]; + result[2] = point[2] + forward[2] * distance[0] + right[2] * distance[1] + distance[2]; + } + public static final float DotProduct(float[] x, float[] y) { + return x[0] * y[0] + x[1] * y[1] + x[2] * y[2]; + } + public static void CrossProduct(float[] v1, float[] v2, float[] cross) { + cross[0] = v1[1] * v2[2] - v1[2] * v2[1]; + cross[1] = v1[2] * v2[0] - v1[0] * v2[2]; + cross[2] = v1[0] * v2[1] - v1[1] * v2[0]; + } + public static int Q_log2(int val) { + int answer = 0; + while ((val >>= 1) > 0) + answer++; + return answer; + } + public static float DEG2RAD(float in) { + return (in * (float) Math.PI) / 180.0f; + } + public static float anglemod(float a) { + return (float) (shortratio) * ((int) (a / (shortratio)) & 65535); + } + public static int ANGLE2SHORT(float x) { + return ((int) ((x) / shortratio) & 65535); + } + public static float LerpAngle(float a2, float a1, float frac) { + if (a1 - a2 > 180) + a1 -= 360; + if (a1 - a2 < -180) + a1 += 360; + return a2 + frac * (a1 - a2); + } + public static float CalcFov(float fov_x, float width, float height) { + double a = 0.0f; + double x; - if (fov_x < 1.0f || fov_x > 179.0f) - Com.Error(Defines.ERR_DROP, "Bad fov: " + fov_x); + if (fov_x < 1.0f || fov_x > 179.0f) + Com.Error(Defines.ERR_DROP, "Bad fov: " + fov_x); - x = width / Math.tan(fov_x * piratio); + x = width / Math.tan(fov_x * piratio); - a = Math.atan(height / x); + a = Math.atan(height / x); - a = a / piratio; + a = a / piratio; - return (float) a; - } + return (float) a; + } } diff --git a/src/main/java/lwjake2/util/PrintfFormat.java b/src/main/java/lwjake2/util/PrintfFormat.java index 416281e..4c7441b 100644 --- a/src/main/java/lwjake2/util/PrintfFormat.java +++ b/src/main/java/lwjake2/util/PrintfFormat.java @@ -437,2778 +437,2778 @@ import java.text.DecimalFormatSymbols; * round up/down when last digits are 50000... */ public class PrintfFormat { - /** - * Constructs an array of control specifications - * possibly preceded, separated, or followed by - * ordinary strings. Control strings begin with - * unpaired percent signs. A pair of successive - * percent signs designates a single percent sign in - * the format. - * @param fmtArg Control string. - * @exception IllegalArgumentException if the control - * string is null, zero length, or otherwise - * malformed. - */ - public PrintfFormat(String fmtArg) throws IllegalArgumentException { - this(Locale.getDefault(), fmtArg); - } - /** - * Constructs an array of control specifications - * possibly preceded, separated, or followed by - * ordinary strings. Control strings begin with - * unpaired percent signs. A pair of successive - * percent signs designates a single percent sign in - * the format. - * @param fmtArg Control string. - * @exception IllegalArgumentException if the control - * string is null, zero length, or otherwise - * malformed. - */ - public PrintfFormat(Locale locale, String fmtArg) throws IllegalArgumentException { - dfs = new DecimalFormatSymbols(locale); - int ePos = 0; - ConversionSpecification sFmt = null; - String unCS = this.nonControl(fmtArg, 0); - if (unCS != null) { - sFmt = new ConversionSpecification(); - sFmt.setLiteral(unCS); - vFmt.addElement(sFmt); - } - while (cPos != -1 && cPos < fmtArg.length()) { - for (ePos = cPos + 1; ePos < fmtArg.length(); ePos++) { - char c = 0; - c = fmtArg.charAt(ePos); - if (c == 'i') - break; - if (c == 'd') - break; - if (c == 'f') - break; - if (c == 'g') - break; - if (c == 'G') - break; - if (c == 'o') - break; - if (c == 'x') - break; - if (c == 'X') - break; - if (c == 'e') - break; - if (c == 'E') - break; - if (c == 'c') - break; - if (c == 's') - break; - if (c == '%') - break; - } - ePos = Math.min(ePos + 1, fmtArg.length()); - sFmt = new ConversionSpecification(fmtArg.substring(cPos, ePos)); - vFmt.addElement(sFmt); - unCS = this.nonControl(fmtArg, ePos); - if (unCS != null) { - sFmt = new ConversionSpecification(); - sFmt.setLiteral(unCS); - vFmt.addElement(sFmt); - } - } - } - /** - * Return a substring starting at - * start and ending at either the end - * of the String s, the next unpaired - * percent sign, or at the end of the String if the - * last character is a percent sign. - * @param s Control string. - * @param start Position in the string - * s to begin looking for the start - * of a control string. - * @return the substring from the start position - * to the beginning of the control string. - */ - private String nonControl(String s, int start) { - // String ret = ""; - cPos = s.indexOf("%", start); - if (cPos == -1) - cPos = s.length(); - return s.substring(start, cPos); - } - /** - * Format an array of objects. Byte, Short, - * Integer, Long, Float, Double, and Character - * arguments are treated as wrappers for primitive - * types. - * @param o The array of objects to format. - * @return The formatted String. - */ - public String sprintf(Object[] o) { - Enumeration e = vFmt.elements(); - ConversionSpecification cs = null; - char c = 0; - int i = 0; - StringBuffer sb = new StringBuffer(); - while (e.hasMoreElements()) { - cs = (ConversionSpecification) e.nextElement(); - c = cs.getConversionCharacter(); - if (c == '\0') - sb.append(cs.getLiteral()); - else if (c == '%') - sb.append("%"); - else { - if (cs.isPositionalSpecification()) { - i = cs.getArgumentPosition() - 1; - if (cs.isPositionalFieldWidth()) { - int ifw = cs.getArgumentPositionForFieldWidth() - 1; - cs.setFieldWidthWithArg(((Integer) o[ifw]).intValue()); - } - if (cs.isPositionalPrecision()) { - int ipr = cs.getArgumentPositionForPrecision() - 1; - cs.setPrecisionWithArg(((Integer) o[ipr]).intValue()); - } - } else { - if (cs.isVariableFieldWidth()) { - cs.setFieldWidthWithArg(((Integer) o[i]).intValue()); - i++; - } - if (cs.isVariablePrecision()) { - cs.setPrecisionWithArg(((Integer) o[i]).intValue()); - i++; - } - } - if (o[i] instanceof Byte) - sb.append(cs.internalsprintf(((Byte) o[i]).byteValue())); - else if (o[i] instanceof Short) - sb.append(cs.internalsprintf(((Short) o[i]).shortValue())); - else if (o[i] instanceof Integer) - sb.append(cs.internalsprintf(((Integer) o[i]).intValue())); - else if (o[i] instanceof Long) - sb.append(cs.internalsprintf(((Long) o[i]).longValue())); - else if (o[i] instanceof Float) - sb.append(cs.internalsprintf(((Float) o[i]).floatValue())); - else if (o[i] instanceof Double) - sb.append(cs.internalsprintf(((Double) o[i]).doubleValue())); - else if (o[i] instanceof Character) - sb.append(cs.internalsprintf(((Character) o[i]).charValue())); - else if (o[i] instanceof String) - sb.append(cs.internalsprintf((String) o[i])); - else - sb.append(cs.internalsprintf(o[i])); - if (!cs.isPositionalSpecification()) - i++; - } - } - return sb.toString(); - } - /** - * Format nothing. Just use the control string. - * @return the formatted String. - */ - public String sprintf() { - Enumeration e = vFmt.elements(); - ConversionSpecification cs = null; - char c = 0; - StringBuffer sb = new StringBuffer(); - while (e.hasMoreElements()) { - cs = (ConversionSpecification) e.nextElement(); - c = cs.getConversionCharacter(); - if (c == '\0') - sb.append(cs.getLiteral()); - else if (c == '%') - sb.append("%"); - } - return sb.toString(); - } - /** - * Format an int. - * @param x The int to format. - * @return The formatted String. - * @exception IllegalArgumentException if the - * conversion character is f, e, E, g, G, s, - * or S. - */ - public String sprintf(int x) throws IllegalArgumentException { - Enumeration e = vFmt.elements(); - ConversionSpecification cs = null; - char c = 0; - StringBuffer sb = new StringBuffer(); - while (e.hasMoreElements()) { - cs = (ConversionSpecification) e.nextElement(); - c = cs.getConversionCharacter(); - if (c == '\0') - sb.append(cs.getLiteral()); - else if (c == '%') - sb.append("%"); - else - sb.append(cs.internalsprintf(x)); - } - return sb.toString(); - } - /** - * Format an long. - * @param x The long to format. - * @return The formatted String. - * @exception IllegalArgumentException if the - * conversion character is f, e, E, g, G, s, - * or S. - */ - public String sprintf(long x) throws IllegalArgumentException { - Enumeration e = vFmt.elements(); - ConversionSpecification cs = null; - char c = 0; - StringBuffer sb = new StringBuffer(); - while (e.hasMoreElements()) { - cs = (ConversionSpecification) e.nextElement(); - c = cs.getConversionCharacter(); - if (c == '\0') - sb.append(cs.getLiteral()); - else if (c == '%') - sb.append("%"); - else - sb.append(cs.internalsprintf(x)); - } - return sb.toString(); - } - /** - * Format a double. - * @param x The double to format. - * @return The formatted String. - * @exception IllegalArgumentException if the - * conversion character is c, C, s, S, - * d, d, x, X, or o. - */ - public String sprintf(double x) throws IllegalArgumentException { - Enumeration e = vFmt.elements(); - ConversionSpecification cs = null; - char c = 0; - StringBuffer sb = new StringBuffer(); - while (e.hasMoreElements()) { - cs = (ConversionSpecification) e.nextElement(); - c = cs.getConversionCharacter(); - if (c == '\0') - sb.append(cs.getLiteral()); - else if (c == '%') - sb.append("%"); - else - sb.append(cs.internalsprintf(x)); - } - return sb.toString(); - } - /** - * Format a String. - * @param x The String to format. - * @return The formatted String. - * @exception IllegalArgumentException if the - * conversion character is neither s nor S. - */ - public String sprintf(String x) throws IllegalArgumentException { - Enumeration e = vFmt.elements(); - ConversionSpecification cs = null; - char c = 0; - StringBuffer sb = new StringBuffer(); - while (e.hasMoreElements()) { - cs = (ConversionSpecification) e.nextElement(); - c = cs.getConversionCharacter(); - if (c == '\0') - sb.append(cs.getLiteral()); - else if (c == '%') - sb.append("%"); - else - sb.append(cs.internalsprintf(x)); - } - return sb.toString(); - } - /** - * Format an Object. Convert wrapper types to - * their primitive equivalents and call the - * appropriate internal formatting method. Convert - * Strings using an internal formatting method for - * Strings. Otherwise use the default formatter - * (use toString). - * @param x the Object to format. - * @return the formatted String. - * @exception IllegalArgumentException if the - * conversion character is inappropriate for - * formatting an unwrapped value. - */ - public String sprintf(Object x) throws IllegalArgumentException { - Enumeration e = vFmt.elements(); - ConversionSpecification cs = null; - char c = 0; - StringBuffer sb = new StringBuffer(); - while (e.hasMoreElements()) { - cs = (ConversionSpecification) e.nextElement(); - c = cs.getConversionCharacter(); - if (c == '\0') - sb.append(cs.getLiteral()); - else if (c == '%') - sb.append("%"); - else { - if (x instanceof Byte) - sb.append(cs.internalsprintf(((Byte) x).byteValue())); - else if (x instanceof Short) - sb.append(cs.internalsprintf(((Short) x).shortValue())); - else if (x instanceof Integer) - sb.append(cs.internalsprintf(((Integer) x).intValue())); - else if (x instanceof Long) - sb.append(cs.internalsprintf(((Long) x).longValue())); - else if (x instanceof Float) - sb.append(cs.internalsprintf(((Float) x).floatValue())); - else if (x instanceof Double) - sb.append(cs.internalsprintf(((Double) x).doubleValue())); - else if (x instanceof Character) - sb.append(cs.internalsprintf(((Character) x).charValue())); - else if (x instanceof String) - sb.append(cs.internalsprintf((String) x)); - else - sb.append(cs.internalsprintf(x)); - } - } - return sb.toString(); - } - /** - *

- * ConversionSpecification allows the formatting of - * a single primitive or object embedded within a - * string. The formatting is controlled by a - * format string. Only one Java primitive or - * object can be formatted at a time. - *

- * A format string is a Java string that contains - * a control string. The control string starts at - * the first percent sign (%) in the string, - * provided that this percent sign - *

    - *
  1. is not escaped protected by a matching % or - * is not an escape % character, - *
  2. is not at the end of the format string, and - *
  3. precedes a sequence of characters that parses - * as a valid control string. - *
- *

- * A control string takes the form: - *

 % ['-+ #0]* [0..9]* { . [0..9]* }+
-	 *                { [hlL] }+ [idfgGoxXeEcs]
-	 *
- *

- * The behavior is like printf. One (hopefully the - * only) exception is that the minimum number of - * exponent digits is 3 instead of 2 for e and E - * formats when the optional L is used before the - * e, E, g, or G conversion character. The - * optional L does not imply conversion to a long - * long double. - */ - private class ConversionSpecification { - /** - * Constructor. Used to prepare an instance - * to hold a literal, not a control string. - */ - ConversionSpecification() { - } - /** - * Constructor for a conversion specification. - * The argument must begin with a % and end - * with the conversion character for the - * conversion specification. - * @param fmtArg String specifying the - * conversion specification. - * @exception IllegalArgumentException if the - * input string is null, zero length, or - * otherwise malformed. - */ - ConversionSpecification(String fmtArg) throws IllegalArgumentException { - if (fmtArg == null) - throw new NullPointerException(); - if (fmtArg.length() == 0) - throw new IllegalArgumentException("Control strings must have positive" + " lengths."); - if (fmtArg.charAt(0) == '%') { - fmt = fmtArg; - pos = 1; - setArgPosition(); - setFlagCharacters(); - setFieldWidth(); - setPrecision(); - setOptionalHL(); - if (setConversionCharacter()) { - if (pos == fmtArg.length()) { - if (leadingZeros && leftJustify) - leadingZeros = false; - if (precisionSet && leadingZeros) { - if (conversionCharacter == 'd' - || conversionCharacter == 'i' - || conversionCharacter == 'o' - || conversionCharacter == 'x') { - leadingZeros = false; - } - } - } else - throw new IllegalArgumentException("Malformed conversion specification=" + fmtArg); - } else - throw new IllegalArgumentException("Malformed conversion specification=" + fmtArg); - } else - throw new IllegalArgumentException("Control strings must begin with %."); - } - /** - * Set the String for this instance. - * @param s the String to store. - */ - void setLiteral(String s) { - fmt = s; - } - /** - * Get the String for this instance. Translate - * any escape sequences. - * - * @return s the stored String. - */ - String getLiteral() { - StringBuffer sb = new StringBuffer(); - int i = 0; - while (i < fmt.length()) { - if (fmt.charAt(i) == '\\') { - i++; - if (i < fmt.length()) { - char c = fmt.charAt(i); - switch (c) { - case 'a' : - sb.append((char) 0x07); - break; - case 'b' : - sb.append('\b'); - break; - case 'f' : - sb.append('\f'); - break; - case 'n' : - sb.append(System.getProperty("line.separator")); - break; - case 'r' : - sb.append('\r'); - break; - case 't' : - sb.append('\t'); - break; - case 'v' : - sb.append((char) 0x0b); - break; - case '\\' : - sb.append('\\'); - break; - } - i++; - } else - sb.append('\\'); - } else - i++; - } - return fmt; - } - /** - * Get the conversion character that tells what - * type of control character this instance has. - * - * @return the conversion character. - */ - char getConversionCharacter() { - return conversionCharacter; - } - /** - * Check whether the specifier has a variable - * field width that is going to be set by an - * argument. - * @return true if the conversion - * uses an * field width; otherwise - * false. - */ - boolean isVariableFieldWidth() { - return variableFieldWidth; - } - /** - * Set the field width with an argument. A - * negative field width is taken as a - flag - * followed by a positive field width. - * @param fw the field width. - */ - void setFieldWidthWithArg(int fw) { - if (fw < 0) - leftJustify = true; - fieldWidthSet = true; - fieldWidth = Math.abs(fw); - } - /** - * Check whether the specifier has a variable - * precision that is going to be set by an - * argument. - * @return true if the conversion - * uses an * precision; otherwise - * false. - */ - boolean isVariablePrecision() { - return variablePrecision; - } - /** - * Set the precision with an argument. A - * negative precision will be changed to zero. - * @param pr the precision. - */ - void setPrecisionWithArg(int pr) { - precisionSet = true; - precision = Math.max(pr, 0); - } - /** - * Format an int argument using this conversion - * specification. - * @param s the int to format. - * @return the formatted String. - * @exception IllegalArgumentException if the - * conversion character is f, e, E, g, or G. - */ - String internalsprintf(int s) throws IllegalArgumentException { - String s2 = ""; - switch (conversionCharacter) { - case 'd' : - case 'i' : - if (optionalh) - s2 = printDFormat((short) s); - else if (optionall) - s2 = printDFormat((long) s); - else - s2 = printDFormat(s); - break; - case 'x' : - case 'X' : - if (optionalh) - s2 = printXFormat((short) s); - else if (optionall) - s2 = printXFormat((long) s); - else - s2 = printXFormat(s); - break; - case 'o' : - if (optionalh) - s2 = printOFormat((short) s); - else if (optionall) - s2 = printOFormat((long) s); - else - s2 = printOFormat(s); - break; - case 'c' : - case 'C' : - s2 = printCFormat((char) s); - break; - default : - throw new IllegalArgumentException( - "Cannot format a int with a format using a " + conversionCharacter + " conversion character."); - } - return s2; - } - /** - * Format a long argument using this conversion - * specification. - * @param s the long to format. - * @return the formatted String. - * @exception IllegalArgumentException if the - * conversion character is f, e, E, g, or G. - */ - String internalsprintf(long s) throws IllegalArgumentException { - String s2 = ""; - switch (conversionCharacter) { - case 'd' : - case 'i' : - if (optionalh) - s2 = printDFormat((short) s); - else if (optionall) - s2 = printDFormat(s); - else - s2 = printDFormat((int) s); - break; - case 'x' : - case 'X' : - if (optionalh) - s2 = printXFormat((short) s); - else if (optionall) - s2 = printXFormat(s); - else - s2 = printXFormat((int) s); - break; - case 'o' : - if (optionalh) - s2 = printOFormat((short) s); - else if (optionall) - s2 = printOFormat(s); - else - s2 = printOFormat((int) s); - break; - case 'c' : - case 'C' : - s2 = printCFormat((char) s); - break; - default : - throw new IllegalArgumentException( - "Cannot format a long with a format using a " + conversionCharacter + " conversion character."); - } - return s2; - } - /** - * Format a double argument using this conversion - * specification. - * @param s the double to format. - * @return the formatted String. - * @exception IllegalArgumentException if the - * conversion character is c, C, s, S, i, d, - * x, X, or o. - */ - String internalsprintf(double s) throws IllegalArgumentException { - String s2 = ""; - switch (conversionCharacter) { - case 'f' : - s2 = printFFormat(s); - break; - case 'E' : - case 'e' : - s2 = printEFormat(s); - break; - case 'G' : - case 'g' : - s2 = printGFormat(s); - break; - default : - throw new IllegalArgumentException( - "Cannot " + "format a double with a format using a " + conversionCharacter + " conversion character."); - } - return s2; - } - /** - * Format a String argument using this conversion - * specification. - * @param s the String to format. - * @return the formatted String. - * @exception IllegalArgumentException if the - * conversion character is neither s nor S. - */ - String internalsprintf(String s) throws IllegalArgumentException { - String s2 = ""; - if (conversionCharacter == 's' || conversionCharacter == 'S') - s2 = printSFormat(s); - else - throw new IllegalArgumentException( - "Cannot " + "format a String with a format using a " + conversionCharacter + " conversion character."); - return s2; - } - /** - * Format an Object argument using this conversion - * specification. - * @param s the Object to format. - * @return the formatted String. - * @exception IllegalArgumentException if the - * conversion character is neither s nor S. - */ - String internalsprintf(Object s) { - String s2 = ""; - if (conversionCharacter == 's' || conversionCharacter == 'S') - s2 = printSFormat(s.toString()); - else - throw new IllegalArgumentException( - "Cannot format a String with a format using" + " a " + conversionCharacter + " conversion character."); - return s2; - } - /** - * For f format, the flag character '-', means that - * the output should be left justified within the - * field. The default is to pad with blanks on the - * left. '+' character means that the conversion - * will always begin with a sign (+ or -). The - * blank flag character means that a non-negative - * input will be preceded with a blank. If both - * a '+' and a ' ' are specified, the blank flag - * is ignored. The '0' flag character implies that - * padding to the field width will be done with - * zeros instead of blanks. - * - * The field width is treated as the minimum number - * of characters to be printed. The default is to - * add no padding. Padding is with blanks by - * default. - * - * The precision, if set, is the number of digits - * to appear after the radix character. Padding is - * with trailing 0s. - */ - private char[] fFormatDigits(double x) { - // int defaultDigits=6; - String sx; // sxOut; - int i, j, k; - int n1In, n2In; - int expon = 0; - boolean minusSign = false; - if (x > 0.0) - sx = Double.toString(x); - else if (x < 0.0) { - sx = Double.toString(-x); - minusSign = true; - } else { - sx = Double.toString(x); - if (sx.charAt(0) == '-') { - minusSign = true; - sx = sx.substring(1); - } - } - int ePos = sx.indexOf('E'); - int rPos = sx.indexOf('.'); - if (rPos != -1) - n1In = rPos; - else if (ePos != -1) - n1In = ePos; - else - n1In = sx.length(); - if (rPos != -1) { - if (ePos != -1) - n2In = ePos - rPos - 1; - else - n2In = sx.length() - rPos - 1; - } else - n2In = 0; - if (ePos != -1) { - int ie = ePos + 1; - expon = 0; - if (sx.charAt(ie) == '-') { - for (++ie; ie < sx.length(); ie++) - if (sx.charAt(ie) != '0') - break; - if (ie < sx.length()) - expon = -Integer.parseInt(sx.substring(ie)); - } else { - if (sx.charAt(ie) == '+') - ++ie; - for (; ie < sx.length(); ie++) - if (sx.charAt(ie) != '0') - break; - if (ie < sx.length()) - expon = Integer.parseInt(sx.substring(ie)); - } - } - int p; - if (precisionSet) - p = precision; - else - p = defaultDigits - 1; - char[] ca1 = sx.toCharArray(); - char[] ca2 = new char[n1In + n2In]; - char[] ca3, ca4, ca5; - for (j = 0; j < n1In; j++) - ca2[j] = ca1[j]; - i = j + 1; - for (k = 0; k < n2In; j++, i++, k++) - ca2[j] = ca1[i]; - if (n1In + expon <= 0) { - ca3 = new char[-expon + n2In]; - for (j = 0, k = 0; k < (-n1In - expon); k++, j++) - ca3[j] = '0'; - for (i = 0; i < (n1In + n2In); i++, j++) - ca3[j] = ca2[i]; - } else - ca3 = ca2; - boolean carry = false; - if (p < -expon + n2In) { - if (expon < 0) - i = p; - else - i = p + n1In; - carry = checkForCarry(ca3, i); - if (carry) - carry = startSymbolicCarry(ca3, i - 1, 0); - } - if (n1In + expon <= 0) { - ca4 = new char[2 + p]; - if (!carry) - ca4[0] = '0'; - else - ca4[0] = '1'; - if (alternateForm || !precisionSet || precision != 0) { - ca4[1] = '.'; - for (i = 0, j = 2; i < Math.min(p, ca3.length); i++, j++) - ca4[j] = ca3[i]; - for (; j < ca4.length; j++) - ca4[j] = '0'; - } - } else { - if (!carry) { - if (alternateForm || !precisionSet || precision != 0) - ca4 = new char[n1In + expon + p + 1]; - else - ca4 = new char[n1In + expon]; - j = 0; - } else { - if (alternateForm || !precisionSet || precision != 0) - ca4 = new char[n1In + expon + p + 2]; - else - ca4 = new char[n1In + expon + 1]; - ca4[0] = '1'; - j = 1; - } - for (i = 0; i < Math.min(n1In + expon, ca3.length); i++, j++) - ca4[j] = ca3[i]; - for (; i < n1In + expon; i++, j++) - ca4[j] = '0'; - if (alternateForm || !precisionSet || precision != 0) { - ca4[j] = '.'; - j++; - for (k = 0; i < ca3.length && k < p; i++, j++, k++) - ca4[j] = ca3[i]; - for (; j < ca4.length; j++) - ca4[j] = '0'; - } - } - int nZeros = 0; - if (!leftJustify && leadingZeros) { - int xThousands = 0; - if (thousands) { - int xlead = 0; - if (ca4[0] == '+' || ca4[0] == '-' || ca4[0] == ' ') - xlead = 1; - int xdp = xlead; - for (; xdp < ca4.length; xdp++) - if (ca4[xdp] == '.') - break; - xThousands = (xdp - xlead) / 3; - } - if (fieldWidthSet) - nZeros = fieldWidth - ca4.length; - if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) - nZeros--; - nZeros -= xThousands; - if (nZeros < 0) - nZeros = 0; - } - j = 0; - if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) { - ca5 = new char[ca4.length + nZeros + 1]; - j++; - } else - ca5 = new char[ca4.length + nZeros]; - if (!minusSign) { - if (leadingSign) - ca5[0] = '+'; - if (leadingSpace) - ca5[0] = ' '; - } else - ca5[0] = '-'; - for (i = 0; i < nZeros; i++, j++) - ca5[j] = '0'; - for (i = 0; i < ca4.length; i++, j++) - ca5[j] = ca4[i]; + /** + * Constructs an array of control specifications + * possibly preceded, separated, or followed by + * ordinary strings. Control strings begin with + * unpaired percent signs. A pair of successive + * percent signs designates a single percent sign in + * the format. + * @param fmtArg Control string. + * @exception IllegalArgumentException if the control + * string is null, zero length, or otherwise + * malformed. + */ + public PrintfFormat(String fmtArg) throws IllegalArgumentException { + this(Locale.getDefault(), fmtArg); + } + /** + * Constructs an array of control specifications + * possibly preceded, separated, or followed by + * ordinary strings. Control strings begin with + * unpaired percent signs. A pair of successive + * percent signs designates a single percent sign in + * the format. + * @param fmtArg Control string. + * @exception IllegalArgumentException if the control + * string is null, zero length, or otherwise + * malformed. + */ + public PrintfFormat(Locale locale, String fmtArg) throws IllegalArgumentException { + dfs = new DecimalFormatSymbols(locale); + int ePos = 0; + ConversionSpecification sFmt = null; + String unCS = this.nonControl(fmtArg, 0); + if (unCS != null) { + sFmt = new ConversionSpecification(); + sFmt.setLiteral(unCS); + vFmt.addElement(sFmt); + } + while (cPos != -1 && cPos < fmtArg.length()) { + for (ePos = cPos + 1; ePos < fmtArg.length(); ePos++) { + char c = 0; + c = fmtArg.charAt(ePos); + if (c == 'i') + break; + if (c == 'd') + break; + if (c == 'f') + break; + if (c == 'g') + break; + if (c == 'G') + break; + if (c == 'o') + break; + if (c == 'x') + break; + if (c == 'X') + break; + if (c == 'e') + break; + if (c == 'E') + break; + if (c == 'c') + break; + if (c == 's') + break; + if (c == '%') + break; + } + ePos = Math.min(ePos + 1, fmtArg.length()); + sFmt = new ConversionSpecification(fmtArg.substring(cPos, ePos)); + vFmt.addElement(sFmt); + unCS = this.nonControl(fmtArg, ePos); + if (unCS != null) { + sFmt = new ConversionSpecification(); + sFmt.setLiteral(unCS); + vFmt.addElement(sFmt); + } + } + } + /** + * Return a substring starting at + * start and ending at either the end + * of the String s, the next unpaired + * percent sign, or at the end of the String if the + * last character is a percent sign. + * @param s Control string. + * @param start Position in the string + * s to begin looking for the start + * of a control string. + * @return the substring from the start position + * to the beginning of the control string. + */ + private String nonControl(String s, int start) { + // String ret = ""; + cPos = s.indexOf("%", start); + if (cPos == -1) + cPos = s.length(); + return s.substring(start, cPos); + } + /** + * Format an array of objects. Byte, Short, + * Integer, Long, Float, Double, and Character + * arguments are treated as wrappers for primitive + * types. + * @param o The array of objects to format. + * @return The formatted String. + */ + public String sprintf(Object[] o) { + Enumeration e = vFmt.elements(); + ConversionSpecification cs = null; + char c = 0; + int i = 0; + StringBuffer sb = new StringBuffer(); + while (e.hasMoreElements()) { + cs = (ConversionSpecification) e.nextElement(); + c = cs.getConversionCharacter(); + if (c == '\0') + sb.append(cs.getLiteral()); + else if (c == '%') + sb.append("%"); + else { + if (cs.isPositionalSpecification()) { + i = cs.getArgumentPosition() - 1; + if (cs.isPositionalFieldWidth()) { + int ifw = cs.getArgumentPositionForFieldWidth() - 1; + cs.setFieldWidthWithArg(((Integer) o[ifw]).intValue()); + } + if (cs.isPositionalPrecision()) { + int ipr = cs.getArgumentPositionForPrecision() - 1; + cs.setPrecisionWithArg(((Integer) o[ipr]).intValue()); + } + } else { + if (cs.isVariableFieldWidth()) { + cs.setFieldWidthWithArg(((Integer) o[i]).intValue()); + i++; + } + if (cs.isVariablePrecision()) { + cs.setPrecisionWithArg(((Integer) o[i]).intValue()); + i++; + } + } + if (o[i] instanceof Byte) + sb.append(cs.internalsprintf(((Byte) o[i]).byteValue())); + else if (o[i] instanceof Short) + sb.append(cs.internalsprintf(((Short) o[i]).shortValue())); + else if (o[i] instanceof Integer) + sb.append(cs.internalsprintf(((Integer) o[i]).intValue())); + else if (o[i] instanceof Long) + sb.append(cs.internalsprintf(((Long) o[i]).longValue())); + else if (o[i] instanceof Float) + sb.append(cs.internalsprintf(((Float) o[i]).floatValue())); + else if (o[i] instanceof Double) + sb.append(cs.internalsprintf(((Double) o[i]).doubleValue())); + else if (o[i] instanceof Character) + sb.append(cs.internalsprintf(((Character) o[i]).charValue())); + else if (o[i] instanceof String) + sb.append(cs.internalsprintf((String) o[i])); + else + sb.append(cs.internalsprintf(o[i])); + if (!cs.isPositionalSpecification()) + i++; + } + } + return sb.toString(); + } + /** + * Format nothing. Just use the control string. + * @return the formatted String. + */ + public String sprintf() { + Enumeration e = vFmt.elements(); + ConversionSpecification cs = null; + char c = 0; + StringBuffer sb = new StringBuffer(); + while (e.hasMoreElements()) { + cs = (ConversionSpecification) e.nextElement(); + c = cs.getConversionCharacter(); + if (c == '\0') + sb.append(cs.getLiteral()); + else if (c == '%') + sb.append("%"); + } + return sb.toString(); + } + /** + * Format an int. + * @param x The int to format. + * @return The formatted String. + * @exception IllegalArgumentException if the + * conversion character is f, e, E, g, G, s, + * or S. + */ + public String sprintf(int x) throws IllegalArgumentException { + Enumeration e = vFmt.elements(); + ConversionSpecification cs = null; + char c = 0; + StringBuffer sb = new StringBuffer(); + while (e.hasMoreElements()) { + cs = (ConversionSpecification) e.nextElement(); + c = cs.getConversionCharacter(); + if (c == '\0') + sb.append(cs.getLiteral()); + else if (c == '%') + sb.append("%"); + else + sb.append(cs.internalsprintf(x)); + } + return sb.toString(); + } + /** + * Format an long. + * @param x The long to format. + * @return The formatted String. + * @exception IllegalArgumentException if the + * conversion character is f, e, E, g, G, s, + * or S. + */ + public String sprintf(long x) throws IllegalArgumentException { + Enumeration e = vFmt.elements(); + ConversionSpecification cs = null; + char c = 0; + StringBuffer sb = new StringBuffer(); + while (e.hasMoreElements()) { + cs = (ConversionSpecification) e.nextElement(); + c = cs.getConversionCharacter(); + if (c == '\0') + sb.append(cs.getLiteral()); + else if (c == '%') + sb.append("%"); + else + sb.append(cs.internalsprintf(x)); + } + return sb.toString(); + } + /** + * Format a double. + * @param x The double to format. + * @return The formatted String. + * @exception IllegalArgumentException if the + * conversion character is c, C, s, S, + * d, d, x, X, or o. + */ + public String sprintf(double x) throws IllegalArgumentException { + Enumeration e = vFmt.elements(); + ConversionSpecification cs = null; + char c = 0; + StringBuffer sb = new StringBuffer(); + while (e.hasMoreElements()) { + cs = (ConversionSpecification) e.nextElement(); + c = cs.getConversionCharacter(); + if (c == '\0') + sb.append(cs.getLiteral()); + else if (c == '%') + sb.append("%"); + else + sb.append(cs.internalsprintf(x)); + } + return sb.toString(); + } + /** + * Format a String. + * @param x The String to format. + * @return The formatted String. + * @exception IllegalArgumentException if the + * conversion character is neither s nor S. + */ + public String sprintf(String x) throws IllegalArgumentException { + Enumeration e = vFmt.elements(); + ConversionSpecification cs = null; + char c = 0; + StringBuffer sb = new StringBuffer(); + while (e.hasMoreElements()) { + cs = (ConversionSpecification) e.nextElement(); + c = cs.getConversionCharacter(); + if (c == '\0') + sb.append(cs.getLiteral()); + else if (c == '%') + sb.append("%"); + else + sb.append(cs.internalsprintf(x)); + } + return sb.toString(); + } + /** + * Format an Object. Convert wrapper types to + * their primitive equivalents and call the + * appropriate internal formatting method. Convert + * Strings using an internal formatting method for + * Strings. Otherwise use the default formatter + * (use toString). + * @param x the Object to format. + * @return the formatted String. + * @exception IllegalArgumentException if the + * conversion character is inappropriate for + * formatting an unwrapped value. + */ + public String sprintf(Object x) throws IllegalArgumentException { + Enumeration e = vFmt.elements(); + ConversionSpecification cs = null; + char c = 0; + StringBuffer sb = new StringBuffer(); + while (e.hasMoreElements()) { + cs = (ConversionSpecification) e.nextElement(); + c = cs.getConversionCharacter(); + if (c == '\0') + sb.append(cs.getLiteral()); + else if (c == '%') + sb.append("%"); + else { + if (x instanceof Byte) + sb.append(cs.internalsprintf(((Byte) x).byteValue())); + else if (x instanceof Short) + sb.append(cs.internalsprintf(((Short) x).shortValue())); + else if (x instanceof Integer) + sb.append(cs.internalsprintf(((Integer) x).intValue())); + else if (x instanceof Long) + sb.append(cs.internalsprintf(((Long) x).longValue())); + else if (x instanceof Float) + sb.append(cs.internalsprintf(((Float) x).floatValue())); + else if (x instanceof Double) + sb.append(cs.internalsprintf(((Double) x).doubleValue())); + else if (x instanceof Character) + sb.append(cs.internalsprintf(((Character) x).charValue())); + else if (x instanceof String) + sb.append(cs.internalsprintf((String) x)); + else + sb.append(cs.internalsprintf(x)); + } + } + return sb.toString(); + } + /** + *

+ * ConversionSpecification allows the formatting of + * a single primitive or object embedded within a + * string. The formatting is controlled by a + * format string. Only one Java primitive or + * object can be formatted at a time. + *

+ * A format string is a Java string that contains + * a control string. The control string starts at + * the first percent sign (%) in the string, + * provided that this percent sign + *

    + *
  1. is not escaped protected by a matching % or + * is not an escape % character, + *
  2. is not at the end of the format string, and + *
  3. precedes a sequence of characters that parses + * as a valid control string. + *
+ *

+ * A control string takes the form: + *

 % ['-+ #0]* [0..9]* { . [0..9]* }+
+     *                { [hlL] }+ [idfgGoxXeEcs]
+     *
+ *

+ * The behavior is like printf. One (hopefully the + * only) exception is that the minimum number of + * exponent digits is 3 instead of 2 for e and E + * formats when the optional L is used before the + * e, E, g, or G conversion character. The + * optional L does not imply conversion to a long + * long double. + */ + private class ConversionSpecification { + /** + * Constructor. Used to prepare an instance + * to hold a literal, not a control string. + */ + ConversionSpecification() { + } + /** + * Constructor for a conversion specification. + * The argument must begin with a % and end + * with the conversion character for the + * conversion specification. + * @param fmtArg String specifying the + * conversion specification. + * @exception IllegalArgumentException if the + * input string is null, zero length, or + * otherwise malformed. + */ + ConversionSpecification(String fmtArg) throws IllegalArgumentException { + if (fmtArg == null) + throw new NullPointerException(); + if (fmtArg.length() == 0) + throw new IllegalArgumentException("Control strings must have positive" + " lengths."); + if (fmtArg.charAt(0) == '%') { + fmt = fmtArg; + pos = 1; + setArgPosition(); + setFlagCharacters(); + setFieldWidth(); + setPrecision(); + setOptionalHL(); + if (setConversionCharacter()) { + if (pos == fmtArg.length()) { + if (leadingZeros && leftJustify) + leadingZeros = false; + if (precisionSet && leadingZeros) { + if (conversionCharacter == 'd' + || conversionCharacter == 'i' + || conversionCharacter == 'o' + || conversionCharacter == 'x') { + leadingZeros = false; + } + } + } else + throw new IllegalArgumentException("Malformed conversion specification=" + fmtArg); + } else + throw new IllegalArgumentException("Malformed conversion specification=" + fmtArg); + } else + throw new IllegalArgumentException("Control strings must begin with %."); + } + /** + * Set the String for this instance. + * @param s the String to store. + */ + void setLiteral(String s) { + fmt = s; + } + /** + * Get the String for this instance. Translate + * any escape sequences. + * + * @return s the stored String. + */ + String getLiteral() { + StringBuffer sb = new StringBuffer(); + int i = 0; + while (i < fmt.length()) { + if (fmt.charAt(i) == '\\') { + i++; + if (i < fmt.length()) { + char c = fmt.charAt(i); + switch (c) { + case 'a' : + sb.append((char) 0x07); + break; + case 'b' : + sb.append('\b'); + break; + case 'f' : + sb.append('\f'); + break; + case 'n' : + sb.append(System.getProperty("line.separator")); + break; + case 'r' : + sb.append('\r'); + break; + case 't' : + sb.append('\t'); + break; + case 'v' : + sb.append((char) 0x0b); + break; + case '\\' : + sb.append('\\'); + break; + } + i++; + } else + sb.append('\\'); + } else + i++; + } + return fmt; + } + /** + * Get the conversion character that tells what + * type of control character this instance has. + * + * @return the conversion character. + */ + char getConversionCharacter() { + return conversionCharacter; + } + /** + * Check whether the specifier has a variable + * field width that is going to be set by an + * argument. + * @return true if the conversion + * uses an * field width; otherwise + * false. + */ + boolean isVariableFieldWidth() { + return variableFieldWidth; + } + /** + * Set the field width with an argument. A + * negative field width is taken as a - flag + * followed by a positive field width. + * @param fw the field width. + */ + void setFieldWidthWithArg(int fw) { + if (fw < 0) + leftJustify = true; + fieldWidthSet = true; + fieldWidth = Math.abs(fw); + } + /** + * Check whether the specifier has a variable + * precision that is going to be set by an + * argument. + * @return true if the conversion + * uses an * precision; otherwise + * false. + */ + boolean isVariablePrecision() { + return variablePrecision; + } + /** + * Set the precision with an argument. A + * negative precision will be changed to zero. + * @param pr the precision. + */ + void setPrecisionWithArg(int pr) { + precisionSet = true; + precision = Math.max(pr, 0); + } + /** + * Format an int argument using this conversion + * specification. + * @param s the int to format. + * @return the formatted String. + * @exception IllegalArgumentException if the + * conversion character is f, e, E, g, or G. + */ + String internalsprintf(int s) throws IllegalArgumentException { + String s2 = ""; + switch (conversionCharacter) { + case 'd' : + case 'i' : + if (optionalh) + s2 = printDFormat((short) s); + else if (optionall) + s2 = printDFormat((long) s); + else + s2 = printDFormat(s); + break; + case 'x' : + case 'X' : + if (optionalh) + s2 = printXFormat((short) s); + else if (optionall) + s2 = printXFormat((long) s); + else + s2 = printXFormat(s); + break; + case 'o' : + if (optionalh) + s2 = printOFormat((short) s); + else if (optionall) + s2 = printOFormat((long) s); + else + s2 = printOFormat(s); + break; + case 'c' : + case 'C' : + s2 = printCFormat((char) s); + break; + default : + throw new IllegalArgumentException( + "Cannot format a int with a format using a " + conversionCharacter + " conversion character."); + } + return s2; + } + /** + * Format a long argument using this conversion + * specification. + * @param s the long to format. + * @return the formatted String. + * @exception IllegalArgumentException if the + * conversion character is f, e, E, g, or G. + */ + String internalsprintf(long s) throws IllegalArgumentException { + String s2 = ""; + switch (conversionCharacter) { + case 'd' : + case 'i' : + if (optionalh) + s2 = printDFormat((short) s); + else if (optionall) + s2 = printDFormat(s); + else + s2 = printDFormat((int) s); + break; + case 'x' : + case 'X' : + if (optionalh) + s2 = printXFormat((short) s); + else if (optionall) + s2 = printXFormat(s); + else + s2 = printXFormat((int) s); + break; + case 'o' : + if (optionalh) + s2 = printOFormat((short) s); + else if (optionall) + s2 = printOFormat(s); + else + s2 = printOFormat((int) s); + break; + case 'c' : + case 'C' : + s2 = printCFormat((char) s); + break; + default : + throw new IllegalArgumentException( + "Cannot format a long with a format using a " + conversionCharacter + " conversion character."); + } + return s2; + } + /** + * Format a double argument using this conversion + * specification. + * @param s the double to format. + * @return the formatted String. + * @exception IllegalArgumentException if the + * conversion character is c, C, s, S, i, d, + * x, X, or o. + */ + String internalsprintf(double s) throws IllegalArgumentException { + String s2 = ""; + switch (conversionCharacter) { + case 'f' : + s2 = printFFormat(s); + break; + case 'E' : + case 'e' : + s2 = printEFormat(s); + break; + case 'G' : + case 'g' : + s2 = printGFormat(s); + break; + default : + throw new IllegalArgumentException( + "Cannot " + "format a double with a format using a " + conversionCharacter + " conversion character."); + } + return s2; + } + /** + * Format a String argument using this conversion + * specification. + * @param s the String to format. + * @return the formatted String. + * @exception IllegalArgumentException if the + * conversion character is neither s nor S. + */ + String internalsprintf(String s) throws IllegalArgumentException { + String s2 = ""; + if (conversionCharacter == 's' || conversionCharacter == 'S') + s2 = printSFormat(s); + else + throw new IllegalArgumentException( + "Cannot " + "format a String with a format using a " + conversionCharacter + " conversion character."); + return s2; + } + /** + * Format an Object argument using this conversion + * specification. + * @param s the Object to format. + * @return the formatted String. + * @exception IllegalArgumentException if the + * conversion character is neither s nor S. + */ + String internalsprintf(Object s) { + String s2 = ""; + if (conversionCharacter == 's' || conversionCharacter == 'S') + s2 = printSFormat(s.toString()); + else + throw new IllegalArgumentException( + "Cannot format a String with a format using" + " a " + conversionCharacter + " conversion character."); + return s2; + } + /** + * For f format, the flag character '-', means that + * the output should be left justified within the + * field. The default is to pad with blanks on the + * left. '+' character means that the conversion + * will always begin with a sign (+ or -). The + * blank flag character means that a non-negative + * input will be preceded with a blank. If both + * a '+' and a ' ' are specified, the blank flag + * is ignored. The '0' flag character implies that + * padding to the field width will be done with + * zeros instead of blanks. + * + * The field width is treated as the minimum number + * of characters to be printed. The default is to + * add no padding. Padding is with blanks by + * default. + * + * The precision, if set, is the number of digits + * to appear after the radix character. Padding is + * with trailing 0s. + */ + private char[] fFormatDigits(double x) { + // int defaultDigits=6; + String sx; // sxOut; + int i, j, k; + int n1In, n2In; + int expon = 0; + boolean minusSign = false; + if (x > 0.0) + sx = Double.toString(x); + else if (x < 0.0) { + sx = Double.toString(-x); + minusSign = true; + } else { + sx = Double.toString(x); + if (sx.charAt(0) == '-') { + minusSign = true; + sx = sx.substring(1); + } + } + int ePos = sx.indexOf('E'); + int rPos = sx.indexOf('.'); + if (rPos != -1) + n1In = rPos; + else if (ePos != -1) + n1In = ePos; + else + n1In = sx.length(); + if (rPos != -1) { + if (ePos != -1) + n2In = ePos - rPos - 1; + else + n2In = sx.length() - rPos - 1; + } else + n2In = 0; + if (ePos != -1) { + int ie = ePos + 1; + expon = 0; + if (sx.charAt(ie) == '-') { + for (++ie; ie < sx.length(); ie++) + if (sx.charAt(ie) != '0') + break; + if (ie < sx.length()) + expon = -Integer.parseInt(sx.substring(ie)); + } else { + if (sx.charAt(ie) == '+') + ++ie; + for (; ie < sx.length(); ie++) + if (sx.charAt(ie) != '0') + break; + if (ie < sx.length()) + expon = Integer.parseInt(sx.substring(ie)); + } + } + int p; + if (precisionSet) + p = precision; + else + p = defaultDigits - 1; + char[] ca1 = sx.toCharArray(); + char[] ca2 = new char[n1In + n2In]; + char[] ca3, ca4, ca5; + for (j = 0; j < n1In; j++) + ca2[j] = ca1[j]; + i = j + 1; + for (k = 0; k < n2In; j++, i++, k++) + ca2[j] = ca1[i]; + if (n1In + expon <= 0) { + ca3 = new char[-expon + n2In]; + for (j = 0, k = 0; k < (-n1In - expon); k++, j++) + ca3[j] = '0'; + for (i = 0; i < (n1In + n2In); i++, j++) + ca3[j] = ca2[i]; + } else + ca3 = ca2; + boolean carry = false; + if (p < -expon + n2In) { + if (expon < 0) + i = p; + else + i = p + n1In; + carry = checkForCarry(ca3, i); + if (carry) + carry = startSymbolicCarry(ca3, i - 1, 0); + } + if (n1In + expon <= 0) { + ca4 = new char[2 + p]; + if (!carry) + ca4[0] = '0'; + else + ca4[0] = '1'; + if (alternateForm || !precisionSet || precision != 0) { + ca4[1] = '.'; + for (i = 0, j = 2; i < Math.min(p, ca3.length); i++, j++) + ca4[j] = ca3[i]; + for (; j < ca4.length; j++) + ca4[j] = '0'; + } + } else { + if (!carry) { + if (alternateForm || !precisionSet || precision != 0) + ca4 = new char[n1In + expon + p + 1]; + else + ca4 = new char[n1In + expon]; + j = 0; + } else { + if (alternateForm || !precisionSet || precision != 0) + ca4 = new char[n1In + expon + p + 2]; + else + ca4 = new char[n1In + expon + 1]; + ca4[0] = '1'; + j = 1; + } + for (i = 0; i < Math.min(n1In + expon, ca3.length); i++, j++) + ca4[j] = ca3[i]; + for (; i < n1In + expon; i++, j++) + ca4[j] = '0'; + if (alternateForm || !precisionSet || precision != 0) { + ca4[j] = '.'; + j++; + for (k = 0; i < ca3.length && k < p; i++, j++, k++) + ca4[j] = ca3[i]; + for (; j < ca4.length; j++) + ca4[j] = '0'; + } + } + int nZeros = 0; + if (!leftJustify && leadingZeros) { + int xThousands = 0; + if (thousands) { + int xlead = 0; + if (ca4[0] == '+' || ca4[0] == '-' || ca4[0] == ' ') + xlead = 1; + int xdp = xlead; + for (; xdp < ca4.length; xdp++) + if (ca4[xdp] == '.') + break; + xThousands = (xdp - xlead) / 3; + } + if (fieldWidthSet) + nZeros = fieldWidth - ca4.length; + if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) + nZeros--; + nZeros -= xThousands; + if (nZeros < 0) + nZeros = 0; + } + j = 0; + if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) { + ca5 = new char[ca4.length + nZeros + 1]; + j++; + } else + ca5 = new char[ca4.length + nZeros]; + if (!minusSign) { + if (leadingSign) + ca5[0] = '+'; + if (leadingSpace) + ca5[0] = ' '; + } else + ca5[0] = '-'; + for (i = 0; i < nZeros; i++, j++) + ca5[j] = '0'; + for (i = 0; i < ca4.length; i++, j++) + ca5[j] = ca4[i]; - int lead = 0; - if (ca5[0] == '+' || ca5[0] == '-' || ca5[0] == ' ') - lead = 1; - int dp = lead; - for (; dp < ca5.length; dp++) - if (ca5[dp] == '.') - break; - int nThousands = (dp - lead) / 3; - // Localize the decimal point. - if (dp < ca5.length) - ca5[dp] = dfs.getDecimalSeparator(); - char[] ca6 = ca5; - if (thousands && nThousands > 0) { - ca6 = new char[ca5.length + nThousands + lead]; - ca6[0] = ca5[0]; - for (i = lead, k = lead; i < dp; i++) { - if (i > 0 && (dp - i) % 3 == 0) { - // ca6[k]=','; - ca6[k] = dfs.getGroupingSeparator(); - ca6[k + 1] = ca5[i]; - k += 2; - } else { - ca6[k] = ca5[i]; - k++; - } - } - for (; i < ca5.length; i++, k++) { - ca6[k] = ca5[i]; - } - } - return ca6; - } - /** - * An intermediate routine on the way to creating - * an f format String. The method decides whether - * the input double value is an infinity, - * not-a-number, or a finite double and formats - * each type of input appropriately. - * @param x the double value to be formatted. - * @return the converted double value. - */ - private String fFormatString(double x) { - // boolean noDigits = false; - char[] ca6, ca7; - if (Double.isInfinite(x)) { - if (x == Double.POSITIVE_INFINITY) { - if (leadingSign) - ca6 = "+Inf".toCharArray(); - else if (leadingSpace) - ca6 = " Inf".toCharArray(); - else - ca6 = "Inf".toCharArray(); - } else - ca6 = "-Inf".toCharArray(); - // noDigits = true; - } else if (Double.isNaN(x)) { - if (leadingSign) - ca6 = "+NaN".toCharArray(); - else if (leadingSpace) - ca6 = " NaN".toCharArray(); - else - ca6 = "NaN".toCharArray(); - // noDigits = true; - } else - ca6 = fFormatDigits(x); - ca7 = applyFloatPadding(ca6, false); - return new String(ca7); - } - /** - * For e format, the flag character '-', means that - * the output should be left justified within the - * field. The default is to pad with blanks on the - * left. '+' character means that the conversion - * will always begin with a sign (+ or -). The - * blank flag character means that a non-negative - * input will be preceded with a blank. If both a - * '+' and a ' ' are specified, the blank flag is - * ignored. The '0' flag character implies that - * padding to the field width will be done with - * zeros instead of blanks. - * - * The field width is treated as the minimum number - * of characters to be printed. The default is to - * add no padding. Padding is with blanks by - * default. - * - * The precision, if set, is the minimum number of - * digits to appear after the radix character. - * Padding is with trailing 0s. - * - * The behavior is like printf. One (hopefully the - * only) exception is that the minimum number of - * exponent digits is 3 instead of 2 for e and E - * formats when the optional L is used before the - * e, E, g, or G conversion character. The optional - * L does not imply conversion to a long long - * double. - */ - private char[] eFormatDigits(double x, char eChar) { - char[] ca1, ca2, ca3; - // int defaultDigits=6; - String sx; //, sxOut; - int i, j, k, p; - // int n1In, n2In; - int expon = 0; - int ePos, rPos, eSize; - boolean minusSign = false; - if (x > 0.0) - sx = Double.toString(x); - else if (x < 0.0) { - sx = Double.toString(-x); - minusSign = true; - } else { - sx = Double.toString(x); - if (sx.charAt(0) == '-') { - minusSign = true; - sx = sx.substring(1); - } - } - ePos = sx.indexOf('E'); - if (ePos == -1) - ePos = sx.indexOf('e'); - rPos = sx.indexOf('.'); - /* Not exactly sure what the point is here - flibit - if (rPos != -1) - n1In = rPos; - else if (ePos != -1) - n1In = ePos; - else - n1In = sx.length(); - if (rPos != -1) { - if (ePos != -1) - n2In = ePos - rPos - 1; - else - n2In = sx.length() - rPos - 1; - } else - n2In = 0; - */ - if (ePos != -1) { - int ie = ePos + 1; - expon = 0; - if (sx.charAt(ie) == '-') { - for (++ie; ie < sx.length(); ie++) - if (sx.charAt(ie) != '0') - break; - if (ie < sx.length()) - expon = -Integer.parseInt(sx.substring(ie)); - } else { - if (sx.charAt(ie) == '+') - ++ie; - for (; ie < sx.length(); ie++) - if (sx.charAt(ie) != '0') - break; - if (ie < sx.length()) - expon = Integer.parseInt(sx.substring(ie)); - } - } - if (rPos != -1) - expon += rPos - 1; - if (precisionSet) - p = precision; - else - p = defaultDigits - 1; - if (rPos != -1 && ePos != -1) - ca1 = (sx.substring(0, rPos) + sx.substring(rPos + 1, ePos)).toCharArray(); - else if (rPos != -1) - ca1 = (sx.substring(0, rPos) + sx.substring(rPos + 1)).toCharArray(); - else if (ePos != -1) - ca1 = sx.substring(0, ePos).toCharArray(); - else - ca1 = sx.toCharArray(); - boolean carry = false; - int i0 = 0; - if (ca1[0] != '0') - i0 = 0; - else - for (i0 = 0; i0 < ca1.length; i0++) - if (ca1[i0] != '0') - break; - if (i0 + p < ca1.length - 1) { - carry = checkForCarry(ca1, i0 + p + 1); - if (carry) - carry = startSymbolicCarry(ca1, i0 + p, i0); - if (carry) { - ca2 = new char[i0 + p + 1]; - ca2[i0] = '1'; - for (j = 0; j < i0; j++) - ca2[j] = '0'; - for (i = i0, j = i0 + 1; j < p + 1; i++, j++) - ca2[j] = ca1[i]; - expon++; - ca1 = ca2; - } - } - if (Math.abs(expon) < 100 && !optionalL) - eSize = 4; - else - eSize = 5; - if (alternateForm || !precisionSet || precision != 0) - ca2 = new char[2 + p + eSize]; - else - ca2 = new char[1 + eSize]; - if (ca1[0] != '0') { - ca2[0] = ca1[0]; - j = 1; - } else { - for (j = 1; j < (ePos == -1 ? ca1.length : ePos); j++) - if (ca1[j] != '0') - break; - if ((ePos != -1 && j < ePos) || (ePos == -1 && j < ca1.length)) { - ca2[0] = ca1[j]; - expon -= j; - j++; - } else { - ca2[0] = '0'; - j = 2; - } - } - if (alternateForm || !precisionSet || precision != 0) { - ca2[1] = '.'; - i = 2; - } else - i = 1; - for (k = 0; k < p && j < ca1.length; j++, i++, k++) - ca2[i] = ca1[j]; - for (; i < ca2.length - eSize; i++) - ca2[i] = '0'; - ca2[i++] = eChar; - if (expon < 0) - ca2[i++] = '-'; - else - ca2[i++] = '+'; - expon = Math.abs(expon); - if (expon >= 100) { - switch (expon / 100) { - case 1 : - ca2[i] = '1'; - break; - case 2 : - ca2[i] = '2'; - break; - case 3 : - ca2[i] = '3'; - break; - case 4 : - ca2[i] = '4'; - break; - case 5 : - ca2[i] = '5'; - break; - case 6 : - ca2[i] = '6'; - break; - case 7 : - ca2[i] = '7'; - break; - case 8 : - ca2[i] = '8'; - break; - case 9 : - ca2[i] = '9'; - break; - } - i++; - } - switch ((expon % 100) / 10) { - case 0 : - ca2[i] = '0'; - break; - case 1 : - ca2[i] = '1'; - break; - case 2 : - ca2[i] = '2'; - break; - case 3 : - ca2[i] = '3'; - break; - case 4 : - ca2[i] = '4'; - break; - case 5 : - ca2[i] = '5'; - break; - case 6 : - ca2[i] = '6'; - break; - case 7 : - ca2[i] = '7'; - break; - case 8 : - ca2[i] = '8'; - break; - case 9 : - ca2[i] = '9'; - break; - } - i++; - switch (expon % 10) { - case 0 : - ca2[i] = '0'; - break; - case 1 : - ca2[i] = '1'; - break; - case 2 : - ca2[i] = '2'; - break; - case 3 : - ca2[i] = '3'; - break; - case 4 : - ca2[i] = '4'; - break; - case 5 : - ca2[i] = '5'; - break; - case 6 : - ca2[i] = '6'; - break; - case 7 : - ca2[i] = '7'; - break; - case 8 : - ca2[i] = '8'; - break; - case 9 : - ca2[i] = '9'; - break; - } - int nZeros = 0; - if (!leftJustify && leadingZeros) { - int xThousands = 0; - if (thousands) { - int xlead = 0; - if (ca2[0] == '+' || ca2[0] == '-' || ca2[0] == ' ') - xlead = 1; - int xdp = xlead; - for (; xdp < ca2.length; xdp++) - if (ca2[xdp] == '.') - break; - xThousands = (xdp - xlead) / 3; - } - if (fieldWidthSet) - nZeros = fieldWidth - ca2.length; - if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) - nZeros--; - nZeros -= xThousands; - if (nZeros < 0) - nZeros = 0; - } - j = 0; - if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) { - ca3 = new char[ca2.length + nZeros + 1]; - j++; - } else - ca3 = new char[ca2.length + nZeros]; - if (!minusSign) { - if (leadingSign) - ca3[0] = '+'; - if (leadingSpace) - ca3[0] = ' '; - } else - ca3[0] = '-'; - for (k = 0; k < nZeros; j++, k++) - ca3[j] = '0'; - for (i = 0; i < ca2.length && j < ca3.length; i++, j++) - ca3[j] = ca2[i]; + int lead = 0; + if (ca5[0] == '+' || ca5[0] == '-' || ca5[0] == ' ') + lead = 1; + int dp = lead; + for (; dp < ca5.length; dp++) + if (ca5[dp] == '.') + break; + int nThousands = (dp - lead) / 3; + // Localize the decimal point. + if (dp < ca5.length) + ca5[dp] = dfs.getDecimalSeparator(); + char[] ca6 = ca5; + if (thousands && nThousands > 0) { + ca6 = new char[ca5.length + nThousands + lead]; + ca6[0] = ca5[0]; + for (i = lead, k = lead; i < dp; i++) { + if (i > 0 && (dp - i) % 3 == 0) { + // ca6[k]=','; + ca6[k] = dfs.getGroupingSeparator(); + ca6[k + 1] = ca5[i]; + k += 2; + } else { + ca6[k] = ca5[i]; + k++; + } + } + for (; i < ca5.length; i++, k++) { + ca6[k] = ca5[i]; + } + } + return ca6; + } + /** + * An intermediate routine on the way to creating + * an f format String. The method decides whether + * the input double value is an infinity, + * not-a-number, or a finite double and formats + * each type of input appropriately. + * @param x the double value to be formatted. + * @return the converted double value. + */ + private String fFormatString(double x) { + // boolean noDigits = false; + char[] ca6, ca7; + if (Double.isInfinite(x)) { + if (x == Double.POSITIVE_INFINITY) { + if (leadingSign) + ca6 = "+Inf".toCharArray(); + else if (leadingSpace) + ca6 = " Inf".toCharArray(); + else + ca6 = "Inf".toCharArray(); + } else + ca6 = "-Inf".toCharArray(); + // noDigits = true; + } else if (Double.isNaN(x)) { + if (leadingSign) + ca6 = "+NaN".toCharArray(); + else if (leadingSpace) + ca6 = " NaN".toCharArray(); + else + ca6 = "NaN".toCharArray(); + // noDigits = true; + } else + ca6 = fFormatDigits(x); + ca7 = applyFloatPadding(ca6, false); + return new String(ca7); + } + /** + * For e format, the flag character '-', means that + * the output should be left justified within the + * field. The default is to pad with blanks on the + * left. '+' character means that the conversion + * will always begin with a sign (+ or -). The + * blank flag character means that a non-negative + * input will be preceded with a blank. If both a + * '+' and a ' ' are specified, the blank flag is + * ignored. The '0' flag character implies that + * padding to the field width will be done with + * zeros instead of blanks. + * + * The field width is treated as the minimum number + * of characters to be printed. The default is to + * add no padding. Padding is with blanks by + * default. + * + * The precision, if set, is the minimum number of + * digits to appear after the radix character. + * Padding is with trailing 0s. + * + * The behavior is like printf. One (hopefully the + * only) exception is that the minimum number of + * exponent digits is 3 instead of 2 for e and E + * formats when the optional L is used before the + * e, E, g, or G conversion character. The optional + * L does not imply conversion to a long long + * double. + */ + private char[] eFormatDigits(double x, char eChar) { + char[] ca1, ca2, ca3; + // int defaultDigits=6; + String sx; //, sxOut; + int i, j, k, p; + // int n1In, n2In; + int expon = 0; + int ePos, rPos, eSize; + boolean minusSign = false; + if (x > 0.0) + sx = Double.toString(x); + else if (x < 0.0) { + sx = Double.toString(-x); + minusSign = true; + } else { + sx = Double.toString(x); + if (sx.charAt(0) == '-') { + minusSign = true; + sx = sx.substring(1); + } + } + ePos = sx.indexOf('E'); + if (ePos == -1) + ePos = sx.indexOf('e'); + rPos = sx.indexOf('.'); + /* Not exactly sure what the point is here - flibit + if (rPos != -1) + n1In = rPos; + else if (ePos != -1) + n1In = ePos; + else + n1In = sx.length(); + if (rPos != -1) { + if (ePos != -1) + n2In = ePos - rPos - 1; + else + n2In = sx.length() - rPos - 1; + } else + n2In = 0; + */ + if (ePos != -1) { + int ie = ePos + 1; + expon = 0; + if (sx.charAt(ie) == '-') { + for (++ie; ie < sx.length(); ie++) + if (sx.charAt(ie) != '0') + break; + if (ie < sx.length()) + expon = -Integer.parseInt(sx.substring(ie)); + } else { + if (sx.charAt(ie) == '+') + ++ie; + for (; ie < sx.length(); ie++) + if (sx.charAt(ie) != '0') + break; + if (ie < sx.length()) + expon = Integer.parseInt(sx.substring(ie)); + } + } + if (rPos != -1) + expon += rPos - 1; + if (precisionSet) + p = precision; + else + p = defaultDigits - 1; + if (rPos != -1 && ePos != -1) + ca1 = (sx.substring(0, rPos) + sx.substring(rPos + 1, ePos)).toCharArray(); + else if (rPos != -1) + ca1 = (sx.substring(0, rPos) + sx.substring(rPos + 1)).toCharArray(); + else if (ePos != -1) + ca1 = sx.substring(0, ePos).toCharArray(); + else + ca1 = sx.toCharArray(); + boolean carry = false; + int i0 = 0; + if (ca1[0] != '0') + i0 = 0; + else + for (i0 = 0; i0 < ca1.length; i0++) + if (ca1[i0] != '0') + break; + if (i0 + p < ca1.length - 1) { + carry = checkForCarry(ca1, i0 + p + 1); + if (carry) + carry = startSymbolicCarry(ca1, i0 + p, i0); + if (carry) { + ca2 = new char[i0 + p + 1]; + ca2[i0] = '1'; + for (j = 0; j < i0; j++) + ca2[j] = '0'; + for (i = i0, j = i0 + 1; j < p + 1; i++, j++) + ca2[j] = ca1[i]; + expon++; + ca1 = ca2; + } + } + if (Math.abs(expon) < 100 && !optionalL) + eSize = 4; + else + eSize = 5; + if (alternateForm || !precisionSet || precision != 0) + ca2 = new char[2 + p + eSize]; + else + ca2 = new char[1 + eSize]; + if (ca1[0] != '0') { + ca2[0] = ca1[0]; + j = 1; + } else { + for (j = 1; j < (ePos == -1 ? ca1.length : ePos); j++) + if (ca1[j] != '0') + break; + if ((ePos != -1 && j < ePos) || (ePos == -1 && j < ca1.length)) { + ca2[0] = ca1[j]; + expon -= j; + j++; + } else { + ca2[0] = '0'; + j = 2; + } + } + if (alternateForm || !precisionSet || precision != 0) { + ca2[1] = '.'; + i = 2; + } else + i = 1; + for (k = 0; k < p && j < ca1.length; j++, i++, k++) + ca2[i] = ca1[j]; + for (; i < ca2.length - eSize; i++) + ca2[i] = '0'; + ca2[i++] = eChar; + if (expon < 0) + ca2[i++] = '-'; + else + ca2[i++] = '+'; + expon = Math.abs(expon); + if (expon >= 100) { + switch (expon / 100) { + case 1 : + ca2[i] = '1'; + break; + case 2 : + ca2[i] = '2'; + break; + case 3 : + ca2[i] = '3'; + break; + case 4 : + ca2[i] = '4'; + break; + case 5 : + ca2[i] = '5'; + break; + case 6 : + ca2[i] = '6'; + break; + case 7 : + ca2[i] = '7'; + break; + case 8 : + ca2[i] = '8'; + break; + case 9 : + ca2[i] = '9'; + break; + } + i++; + } + switch ((expon % 100) / 10) { + case 0 : + ca2[i] = '0'; + break; + case 1 : + ca2[i] = '1'; + break; + case 2 : + ca2[i] = '2'; + break; + case 3 : + ca2[i] = '3'; + break; + case 4 : + ca2[i] = '4'; + break; + case 5 : + ca2[i] = '5'; + break; + case 6 : + ca2[i] = '6'; + break; + case 7 : + ca2[i] = '7'; + break; + case 8 : + ca2[i] = '8'; + break; + case 9 : + ca2[i] = '9'; + break; + } + i++; + switch (expon % 10) { + case 0 : + ca2[i] = '0'; + break; + case 1 : + ca2[i] = '1'; + break; + case 2 : + ca2[i] = '2'; + break; + case 3 : + ca2[i] = '3'; + break; + case 4 : + ca2[i] = '4'; + break; + case 5 : + ca2[i] = '5'; + break; + case 6 : + ca2[i] = '6'; + break; + case 7 : + ca2[i] = '7'; + break; + case 8 : + ca2[i] = '8'; + break; + case 9 : + ca2[i] = '9'; + break; + } + int nZeros = 0; + if (!leftJustify && leadingZeros) { + int xThousands = 0; + if (thousands) { + int xlead = 0; + if (ca2[0] == '+' || ca2[0] == '-' || ca2[0] == ' ') + xlead = 1; + int xdp = xlead; + for (; xdp < ca2.length; xdp++) + if (ca2[xdp] == '.') + break; + xThousands = (xdp - xlead) / 3; + } + if (fieldWidthSet) + nZeros = fieldWidth - ca2.length; + if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) + nZeros--; + nZeros -= xThousands; + if (nZeros < 0) + nZeros = 0; + } + j = 0; + if ((!minusSign && (leadingSign || leadingSpace)) || minusSign) { + ca3 = new char[ca2.length + nZeros + 1]; + j++; + } else + ca3 = new char[ca2.length + nZeros]; + if (!minusSign) { + if (leadingSign) + ca3[0] = '+'; + if (leadingSpace) + ca3[0] = ' '; + } else + ca3[0] = '-'; + for (k = 0; k < nZeros; j++, k++) + ca3[j] = '0'; + for (i = 0; i < ca2.length && j < ca3.length; i++, j++) + ca3[j] = ca2[i]; - int lead = 0; - if (ca3[0] == '+' || ca3[0] == '-' || ca3[0] == ' ') - lead = 1; - int dp = lead; - for (; dp < ca3.length; dp++) - if (ca3[dp] == '.') - break; - int nThousands = dp / 3; - // Localize the decimal point. - if (dp < ca3.length) - ca3[dp] = dfs.getDecimalSeparator(); - char[] ca4 = ca3; - if (thousands && nThousands > 0) { - ca4 = new char[ca3.length + nThousands + lead]; - ca4[0] = ca3[0]; - for (i = lead, k = lead; i < dp; i++) { - if (i > 0 && (dp - i) % 3 == 0) { - // ca4[k]=','; - ca4[k] = dfs.getGroupingSeparator(); - ca4[k + 1] = ca3[i]; - k += 2; - } else { - ca4[k] = ca3[i]; - k++; - } - } - for (; i < ca3.length; i++, k++) - ca4[k] = ca3[i]; - } - return ca4; - } - /** - * Check to see if the digits that are going to - * be truncated because of the precision should - * force a round in the preceding digits. - * @param ca1 the array of digits - * @param icarry the index of the first digit that - * is to be truncated from the print - * @return true if the truncation forces - * a round that will change the print - */ - private boolean checkForCarry(char[] ca1, int icarry) { - boolean carry = false; - if (icarry < ca1.length) { - if (ca1[icarry] == '6' || ca1[icarry] == '7' || ca1[icarry] == '8' || ca1[icarry] == '9') - carry = true; - else if (ca1[icarry] == '5') { - int ii = icarry + 1; - for (; ii < ca1.length; ii++) - if (ca1[ii] != '0') - break; - carry = ii < ca1.length; - if (!carry && icarry > 0) { - carry = - (ca1[icarry - 1] == '1' - || ca1[icarry - 1] == '3' - || ca1[icarry - 1] == '5' - || ca1[icarry - 1] == '7' - || ca1[icarry - 1] == '9'); - } - } - } - return carry; - } - /** - * Start the symbolic carry process. The process - * is not quite finished because the symbolic - * carry may change the length of the string and - * change the exponent (in e format). - * @param cLast index of the last digit changed - * by the round - * @param cFirst index of the first digit allowed - * to be changed by this phase of the round - * @return true if the carry forces - * a round that will change the print still - * more - */ - private boolean startSymbolicCarry(char[] ca, int cLast, int cFirst) { - boolean carry = true; - for (int i = cLast; carry && i >= cFirst; i--) { - carry = false; - switch (ca[i]) { - case '0' : - ca[i] = '1'; - break; - case '1' : - ca[i] = '2'; - break; - case '2' : - ca[i] = '3'; - break; - case '3' : - ca[i] = '4'; - break; - case '4' : - ca[i] = '5'; - break; - case '5' : - ca[i] = '6'; - break; - case '6' : - ca[i] = '7'; - break; - case '7' : - ca[i] = '8'; - break; - case '8' : - ca[i] = '9'; - break; - case '9' : - ca[i] = '0'; - carry = true; - break; - } - } - return carry; - } - /** - * An intermediate routine on the way to creating - * an e format String. The method decides whether - * the input double value is an infinity, - * not-a-number, or a finite double and formats - * each type of input appropriately. - * @param x the double value to be formatted. - * @param eChar an 'e' or 'E' to use in the - * converted double value. - * @return the converted double value. - */ - private String eFormatString(double x, char eChar) { - // boolean noDigits = false; - char[] ca4, ca5; - if (Double.isInfinite(x)) { - if (x == Double.POSITIVE_INFINITY) { - if (leadingSign) - ca4 = "+Inf".toCharArray(); - else if (leadingSpace) - ca4 = " Inf".toCharArray(); - else - ca4 = "Inf".toCharArray(); - } else - ca4 = "-Inf".toCharArray(); - // noDigits = true; - } else if (Double.isNaN(x)) { - if (leadingSign) - ca4 = "+NaN".toCharArray(); - else if (leadingSpace) - ca4 = " NaN".toCharArray(); - else - ca4 = "NaN".toCharArray(); - // noDigits = true; - } else - ca4 = eFormatDigits(x, eChar); - ca5 = applyFloatPadding(ca4, false); - return new String(ca5); - } - /** - * Apply zero or blank, left or right padding. - * @param ca4 array of characters before padding is - * finished - * @param noDigits NaN or signed Inf - * @return a padded array of characters - */ - private char[] applyFloatPadding(char[] ca4, boolean noDigits) { - char[] ca5 = ca4; - if (fieldWidthSet) { - int i, j, nBlanks; - if (leftJustify) { - nBlanks = fieldWidth - ca4.length; - if (nBlanks > 0) { - ca5 = new char[ca4.length + nBlanks]; - for (i = 0; i < ca4.length; i++) - ca5[i] = ca4[i]; - for (j = 0; j < nBlanks; j++, i++) - ca5[i] = ' '; - } - } else if (!leadingZeros || noDigits) { - nBlanks = fieldWidth - ca4.length; - if (nBlanks > 0) { - ca5 = new char[ca4.length + nBlanks]; - for (i = 0; i < nBlanks; i++) - ca5[i] = ' '; - for (j = 0; j < ca4.length; i++, j++) - ca5[i] = ca4[j]; - } - } else if (leadingZeros) { - nBlanks = fieldWidth - ca4.length; - if (nBlanks > 0) { - ca5 = new char[ca4.length + nBlanks]; - i = 0; - j = 0; - if (ca4[0] == '-') { - ca5[0] = '-'; - i++; - j++; - } - for (int k = 0; k < nBlanks; i++, k++) - ca5[i] = '0'; - for (; j < ca4.length; i++, j++) - ca5[i] = ca4[j]; - } - } - } - return ca5; - } - /** - * Format method for the f conversion character. - * @param x the double to format. - * @return the formatted String. - */ - private String printFFormat(double x) { - return fFormatString(x); - } - /** - * Format method for the e or E conversion - * character. - * @param x the double to format. - * @return the formatted String. - */ - private String printEFormat(double x) { - if (conversionCharacter == 'e') - return eFormatString(x, 'e'); - else - return eFormatString(x, 'E'); - } - /** - * Format method for the g conversion character. - * - * For g format, the flag character '-', means that - * the output should be left justified within the - * field. The default is to pad with blanks on the - * left. '+' character means that the conversion - * will always begin with a sign (+ or -). The - * blank flag character means that a non-negative - * input will be preceded with a blank. If both a - * '+' and a ' ' are specified, the blank flag is - * ignored. The '0' flag character implies that - * padding to the field width will be done with - * zeros instead of blanks. - * - * The field width is treated as the minimum number - * of characters to be printed. The default is to - * add no padding. Padding is with blanks by - * default. - * - * The precision, if set, is the minimum number of - * digits to appear after the radix character. - * Padding is with trailing 0s. - * @param x the double to format. - * @return the formatted String. - */ - private String printGFormat(double x) { - String sx, sy, sz, ret; - int savePrecision = precision; - int i; - char[] ca4, ca5; - // boolean noDigits = false; - if (Double.isInfinite(x)) { - if (x == Double.POSITIVE_INFINITY) { - if (leadingSign) - ca4 = "+Inf".toCharArray(); - else if (leadingSpace) - ca4 = " Inf".toCharArray(); - else - ca4 = "Inf".toCharArray(); - } else - ca4 = "-Inf".toCharArray(); - // noDigits = true; - } else if (Double.isNaN(x)) { - if (leadingSign) - ca4 = "+NaN".toCharArray(); - else if (leadingSpace) - ca4 = " NaN".toCharArray(); - else - ca4 = "NaN".toCharArray(); - // noDigits = true; - } else { - if (!precisionSet) - precision = defaultDigits; - if (precision == 0) - precision = 1; - int ePos = -1; - if (conversionCharacter == 'g') { - sx = eFormatString(x, 'e').trim(); - ePos = sx.indexOf('e'); - } else { - sx = eFormatString(x, 'E').trim(); - ePos = sx.indexOf('E'); - } - i = ePos + 1; - int expon = 0; - if (sx.charAt(i) == '-') { - for (++i; i < sx.length(); i++) - if (sx.charAt(i) != '0') - break; - if (i < sx.length()) - expon = -Integer.parseInt(sx.substring(i)); - } else { - if (sx.charAt(i) == '+') - ++i; - for (; i < sx.length(); i++) - if (sx.charAt(i) != '0') - break; - if (i < sx.length()) - expon = Integer.parseInt(sx.substring(i)); - } - // Trim trailing zeros. - // If the radix character is not followed by - // a digit, trim it, too. - if (!alternateForm) { - if (expon >= -4 && expon < precision) - sy = fFormatString(x).trim(); - else - sy = sx.substring(0, ePos); - i = sy.length() - 1; - for (; i >= 0; i--) - if (sy.charAt(i) != '0') - break; - if (i >= 0 && sy.charAt(i) == '.') - i--; - if (i == -1) - sz = "0"; - else if (!Character.isDigit(sy.charAt(i))) - sz = sy.substring(0, i + 1) + "0"; - else - sz = sy.substring(0, i + 1); - if (expon >= -4 && expon < precision) - ret = sz; - else - ret = sz + sx.substring(ePos); - } else { - if (expon >= -4 && expon < precision) - ret = fFormatString(x).trim(); - else - ret = sx; - } - // leading space was trimmed off during - // construction - if (leadingSpace) - if (x >= 0) - ret = " " + ret; - ca4 = ret.toCharArray(); - } - // Pad with blanks or zeros. - ca5 = applyFloatPadding(ca4, false); - precision = savePrecision; - return new String(ca5); - } - /** - * Format method for the d conversion specifer and - * short argument. - * - * For d format, the flag character '-', means that - * the output should be left justified within the - * field. The default is to pad with blanks on the - * left. A '+' character means that the conversion - * will always begin with a sign (+ or -). The - * blank flag character means that a non-negative - * input will be preceded with a blank. If both a - * '+' and a ' ' are specified, the blank flag is - * ignored. The '0' flag character implies that - * padding to the field width will be done with - * zeros instead of blanks. - * - * The field width is treated as the minimum number - * of characters to be printed. The default is to - * add no padding. Padding is with blanks by - * default. - * - * The precision, if set, is the minimum number of - * digits to appear. Padding is with leading 0s. - * @param x the short to format. - * @return the formatted String. - */ - private String printDFormat(short x) { - return printDFormat(Short.toString(x)); - } - /** - * Format method for the d conversion character and - * long argument. - * - * For d format, the flag character '-', means that - * the output should be left justified within the - * field. The default is to pad with blanks on the - * left. A '+' character means that the conversion - * will always begin with a sign (+ or -). The - * blank flag character means that a non-negative - * input will be preceded with a blank. If both a - * '+' and a ' ' are specified, the blank flag is - * ignored. The '0' flag character implies that - * padding to the field width will be done with - * zeros instead of blanks. - * - * The field width is treated as the minimum number - * of characters to be printed. The default is to - * add no padding. Padding is with blanks by - * default. - * - * The precision, if set, is the minimum number of - * digits to appear. Padding is with leading 0s. - * @param x the long to format. - * @return the formatted String. - */ - private String printDFormat(long x) { - return printDFormat(Long.toString(x)); - } - /** - * Format method for the d conversion character and - * int argument. - * - * For d format, the flag character '-', means that - * the output should be left justified within the - * field. The default is to pad with blanks on the - * left. A '+' character means that the conversion - * will always begin with a sign (+ or -). The - * blank flag character means that a non-negative - * input will be preceded with a blank. If both a - * '+' and a ' ' are specified, the blank flag is - * ignored. The '0' flag character implies that - * padding to the field width will be done with - * zeros instead of blanks. - * - * The field width is treated as the minimum number - * of characters to be printed. The default is to - * add no padding. Padding is with blanks by - * default. - * - * The precision, if set, is the minimum number of - * digits to appear. Padding is with leading 0s. - * @param x the int to format. - * @return the formatted String. - */ - private String printDFormat(int x) { - return printDFormat(Integer.toString(x)); - } - /** - * Utility method for formatting using the d - * conversion character. - * @param sx the String to format, the result of - * converting a short, int, or long to a - * String. - * @return the formatted String. - */ - private String printDFormat(String sx) { - int nLeadingZeros = 0; - int nBlanks = 0, n = 0; - int i = 0, jFirst = 0; - boolean neg = sx.charAt(0) == '-'; - if (sx.equals("0") && precisionSet && precision == 0) - sx = ""; - if (!neg) { - if (precisionSet && sx.length() < precision) - nLeadingZeros = precision - sx.length(); - } else { - if (precisionSet && (sx.length() - 1) < precision) - nLeadingZeros = precision - sx.length() + 1; - } - if (nLeadingZeros < 0) - nLeadingZeros = 0; - if (fieldWidthSet) { - nBlanks = fieldWidth - nLeadingZeros - sx.length(); - if (!neg && (leadingSign || leadingSpace)) - nBlanks--; - } - if (nBlanks < 0) - nBlanks = 0; - if (leadingSign) - n++; - else if (leadingSpace) - n++; - n += nBlanks; - n += nLeadingZeros; - n += sx.length(); - char[] ca = new char[n]; - if (leftJustify) { - if (neg) - ca[i++] = '-'; - else if (leadingSign) - ca[i++] = '+'; - else if (leadingSpace) - ca[i++] = ' '; - char[] csx = sx.toCharArray(); - jFirst = neg ? 1 : 0; - for (int j = 0; j < nLeadingZeros; i++, j++) - ca[i] = '0'; - for (int j = jFirst; j < csx.length; j++, i++) - ca[i] = csx[j]; - for (int j = 0; j < nBlanks; i++, j++) - ca[i] = ' '; - } else { - if (!leadingZeros) { - for (i = 0; i < nBlanks; i++) - ca[i] = ' '; - if (neg) - ca[i++] = '-'; - else if (leadingSign) - ca[i++] = '+'; - else if (leadingSpace) - ca[i++] = ' '; - } else { - if (neg) - ca[i++] = '-'; - else if (leadingSign) - ca[i++] = '+'; - else if (leadingSpace) - ca[i++] = ' '; - for (int j = 0; j < nBlanks; j++, i++) - ca[i] = '0'; - } - for (int j = 0; j < nLeadingZeros; j++, i++) - ca[i] = '0'; - char[] csx = sx.toCharArray(); - jFirst = neg ? 1 : 0; - for (int j = jFirst; j < csx.length; j++, i++) - ca[i] = csx[j]; - } - return new String(ca); - } - /** - * Format method for the x conversion character and - * short argument. - * - * For x format, the flag character '-', means that - * the output should be left justified within the - * field. The default is to pad with blanks on the - * left. The '#' flag character means to lead with - * '0x'. - * - * The field width is treated as the minimum number - * of characters to be printed. The default is to - * add no padding. Padding is with blanks by - * default. - * - * The precision, if set, is the minimum number of - * digits to appear. Padding is with leading 0s. - * @param x the short to format. - * @return the formatted String. - */ - private String printXFormat(short x) { - String sx = null; - if (x == Short.MIN_VALUE) - sx = "8000"; - else if (x < 0) { - String t; - if (x == Short.MIN_VALUE) - t = "0"; - else { - t = Integer.toString((~(-x - 1)) ^ Short.MIN_VALUE, 16); - if (t.charAt(0) == 'F' || t.charAt(0) == 'f') - t = t.substring(16, 32); - } - switch (t.length()) { - case 1 : - sx = "800" + t; - break; - case 2 : - sx = "80" + t; - break; - case 3 : - sx = "8" + t; - break; - case 4 : - switch (t.charAt(0)) { - case '1' : - sx = "9" + t.substring(1, 4); - break; - case '2' : - sx = "a" + t.substring(1, 4); - break; - case '3' : - sx = "b" + t.substring(1, 4); - break; - case '4' : - sx = "c" + t.substring(1, 4); - break; - case '5' : - sx = "d" + t.substring(1, 4); - break; - case '6' : - sx = "e" + t.substring(1, 4); - break; - case '7' : - sx = "f" + t.substring(1, 4); - break; - } - break; - } - } else - sx = Integer.toString((int) x, 16); - return printXFormat(sx); - } - /** - * Format method for the x conversion character and - * long argument. - * - * For x format, the flag character '-', means that - * the output should be left justified within the - * field. The default is to pad with blanks on the - * left. The '#' flag character means to lead with - * '0x'. - * - * The field width is treated as the minimum number - * of characters to be printed. The default is to - * add no padding. Padding is with blanks by - * default. - * - * The precision, if set, is the minimum number of - * digits to appear. Padding is with leading 0s. - * @param x the long to format. - * @return the formatted String. - */ - private String printXFormat(long x) { - String sx = null; - if (x == Long.MIN_VALUE) - sx = "8000000000000000"; - else if (x < 0) { - String t = Long.toString((~(-x - 1)) ^ Long.MIN_VALUE, 16); - switch (t.length()) { - case 1 : - sx = "800000000000000" + t; - break; - case 2 : - sx = "80000000000000" + t; - break; - case 3 : - sx = "8000000000000" + t; - break; - case 4 : - sx = "800000000000" + t; - break; - case 5 : - sx = "80000000000" + t; - break; - case 6 : - sx = "8000000000" + t; - break; - case 7 : - sx = "800000000" + t; - break; - case 8 : - sx = "80000000" + t; - break; - case 9 : - sx = "8000000" + t; - break; - case 10 : - sx = "800000" + t; - break; - case 11 : - sx = "80000" + t; - break; - case 12 : - sx = "8000" + t; - break; - case 13 : - sx = "800" + t; - break; - case 14 : - sx = "80" + t; - break; - case 15 : - sx = "8" + t; - break; - case 16 : - switch (t.charAt(0)) { - case '1' : - sx = "9" + t.substring(1, 16); - break; - case '2' : - sx = "a" + t.substring(1, 16); - break; - case '3' : - sx = "b" + t.substring(1, 16); - break; - case '4' : - sx = "c" + t.substring(1, 16); - break; - case '5' : - sx = "d" + t.substring(1, 16); - break; - case '6' : - sx = "e" + t.substring(1, 16); - break; - case '7' : - sx = "f" + t.substring(1, 16); - break; - } - break; - } - } else - sx = Long.toString(x, 16); - return printXFormat(sx); - } - /** - * Format method for the x conversion character and - * int argument. - * - * For x format, the flag character '-', means that - * the output should be left justified within the - * field. The default is to pad with blanks on the - * left. The '#' flag character means to lead with - * '0x'. - * - * The field width is treated as the minimum number - * of characters to be printed. The default is to - * add no padding. Padding is with blanks by - * default. - * - * The precision, if set, is the minimum number of - * digits to appear. Padding is with leading 0s. - * @param x the int to format. - * @return the formatted String. - */ - private String printXFormat(int x) { - String sx = null; - if (x == Integer.MIN_VALUE) - sx = "80000000"; - else if (x < 0) { - String t = Integer.toString((~(-x - 1)) ^ Integer.MIN_VALUE, 16); - switch (t.length()) { - case 1 : - sx = "8000000" + t; - break; - case 2 : - sx = "800000" + t; - break; - case 3 : - sx = "80000" + t; - break; - case 4 : - sx = "8000" + t; - break; - case 5 : - sx = "800" + t; - break; - case 6 : - sx = "80" + t; - break; - case 7 : - sx = "8" + t; - break; - case 8 : - switch (t.charAt(0)) { - case '1' : - sx = "9" + t.substring(1, 8); - break; - case '2' : - sx = "a" + t.substring(1, 8); - break; - case '3' : - sx = "b" + t.substring(1, 8); - break; - case '4' : - sx = "c" + t.substring(1, 8); - break; - case '5' : - sx = "d" + t.substring(1, 8); - break; - case '6' : - sx = "e" + t.substring(1, 8); - break; - case '7' : - sx = "f" + t.substring(1, 8); - break; - } - break; - } - } else - sx = Integer.toString(x, 16); - return printXFormat(sx); - } - /** - * Utility method for formatting using the x - * conversion character. - * @param sx the String to format, the result of - * converting a short, int, or long to a - * String. - * @return the formatted String. - */ - private String printXFormat(String sx) { - int nLeadingZeros = 0; - int nBlanks = 0; - if (sx == null || sx.equals("0") && precisionSet && precision == 0) - sx = ""; - if (precisionSet) - nLeadingZeros = precision - sx.length(); - if (nLeadingZeros < 0) - nLeadingZeros = 0; - if (fieldWidthSet) { - nBlanks = fieldWidth - nLeadingZeros - sx.length(); - if (alternateForm) - nBlanks = nBlanks - 2; - } - if (nBlanks < 0) - nBlanks = 0; - int n = 0; - if (alternateForm) - n += 2; - n += nLeadingZeros; - n += sx.length(); - n += nBlanks; - char[] ca = new char[n]; - int i = 0; - if (leftJustify) { - if (alternateForm) { - ca[i++] = '0'; - ca[i++] = 'x'; - } - for (int j = 0; j < nLeadingZeros; j++, i++) - ca[i] = '0'; - char[] csx = sx.toCharArray(); - for (int j = 0; j < csx.length; j++, i++) - ca[i] = csx[j]; - for (int j = 0; j < nBlanks; j++, i++) - ca[i] = ' '; - } else { - if (!leadingZeros) - for (int j = 0; j < nBlanks; j++, i++) - ca[i] = ' '; - if (alternateForm) { - ca[i++] = '0'; - ca[i++] = 'x'; - } - if (leadingZeros) - for (int j = 0; j < nBlanks; j++, i++) - ca[i] = '0'; - for (int j = 0; j < nLeadingZeros; j++, i++) - ca[i] = '0'; - char[] csx = sx.toCharArray(); - for (int j = 0; j < csx.length; j++, i++) - ca[i] = csx[j]; - } - String caReturn = new String(ca); - if (conversionCharacter == 'X') - caReturn = caReturn.toUpperCase(); - return caReturn; - } - /** - * Format method for the o conversion character and - * short argument. - * - * For o format, the flag character '-', means that - * the output should be left justified within the - * field. The default is to pad with blanks on the - * left. The '#' flag character means that the - * output begins with a leading 0 and the precision - * is increased by 1. - * - * The field width is treated as the minimum number - * of characters to be printed. The default is to - * add no padding. Padding is with blanks by - * default. - * - * The precision, if set, is the minimum number of - * digits to appear. Padding is with leading 0s. - * @param x the short to format. - * @return the formatted String. - */ - private String printOFormat(short x) { - String sx = null; - if (x == Short.MIN_VALUE) - sx = "100000"; - else if (x < 0) { - String t = Integer.toString((~(-x - 1)) ^ Short.MIN_VALUE, 8); - switch (t.length()) { - case 1 : - sx = "10000" + t; - break; - case 2 : - sx = "1000" + t; - break; - case 3 : - sx = "100" + t; - break; - case 4 : - sx = "10" + t; - break; - case 5 : - sx = "1" + t; - break; - } - } else - sx = Integer.toString((int) x, 8); - return printOFormat(sx); - } - /** - * Format method for the o conversion character and - * long argument. - * - * For o format, the flag character '-', means that - * the output should be left justified within the - * field. The default is to pad with blanks on the - * left. The '#' flag character means that the - * output begins with a leading 0 and the precision - * is increased by 1. - * - * The field width is treated as the minimum number - * of characters to be printed. The default is to - * add no padding. Padding is with blanks by - * default. - * - * The precision, if set, is the minimum number of - * digits to appear. Padding is with leading 0s. - * @param x the long to format. - * @return the formatted String. - */ - private String printOFormat(long x) { - String sx = null; - if (x == Long.MIN_VALUE) - sx = "1000000000000000000000"; - else if (x < 0) { - String t = Long.toString((~(-x - 1)) ^ Long.MIN_VALUE, 8); - switch (t.length()) { - case 1 : - sx = "100000000000000000000" + t; - break; - case 2 : - sx = "10000000000000000000" + t; - break; - case 3 : - sx = "1000000000000000000" + t; - break; - case 4 : - sx = "100000000000000000" + t; - break; - case 5 : - sx = "10000000000000000" + t; - break; - case 6 : - sx = "1000000000000000" + t; - break; - case 7 : - sx = "100000000000000" + t; - break; - case 8 : - sx = "10000000000000" + t; - break; - case 9 : - sx = "1000000000000" + t; - break; - case 10 : - sx = "100000000000" + t; - break; - case 11 : - sx = "10000000000" + t; - break; - case 12 : - sx = "1000000000" + t; - break; - case 13 : - sx = "100000000" + t; - break; - case 14 : - sx = "10000000" + t; - break; - case 15 : - sx = "1000000" + t; - break; - case 16 : - sx = "100000" + t; - break; - case 17 : - sx = "10000" + t; - break; - case 18 : - sx = "1000" + t; - break; - case 19 : - sx = "100" + t; - break; - case 20 : - sx = "10" + t; - break; - case 21 : - sx = "1" + t; - break; - } - } else - sx = Long.toString(x, 8); - return printOFormat(sx); - } - /** - * Format method for the o conversion character and - * int argument. - * - * For o format, the flag character '-', means that - * the output should be left justified within the - * field. The default is to pad with blanks on the - * left. The '#' flag character means that the - * output begins with a leading 0 and the precision - * is increased by 1. - * - * The field width is treated as the minimum number - * of characters to be printed. The default is to - * add no padding. Padding is with blanks by - * default. - * - * The precision, if set, is the minimum number of - * digits to appear. Padding is with leading 0s. - * @param x the int to format. - * @return the formatted String. - */ - private String printOFormat(int x) { - String sx = null; - if (x == Integer.MIN_VALUE) - sx = "20000000000"; - else if (x < 0) { - String t = Integer.toString((~(-x - 1)) ^ Integer.MIN_VALUE, 8); - switch (t.length()) { - case 1 : - sx = "2000000000" + t; - break; - case 2 : - sx = "200000000" + t; - break; - case 3 : - sx = "20000000" + t; - break; - case 4 : - sx = "2000000" + t; - break; - case 5 : - sx = "200000" + t; - break; - case 6 : - sx = "20000" + t; - break; - case 7 : - sx = "2000" + t; - break; - case 8 : - sx = "200" + t; - break; - case 9 : - sx = "20" + t; - break; - case 10 : - sx = "2" + t; - break; - case 11 : - sx = "3" + t.substring(1); - break; - } - } else - sx = Integer.toString(x, 8); - return printOFormat(sx); - } - /** - * Utility method for formatting using the o - * conversion character. - * @param sx the String to format, the result of - * converting a short, int, or long to a - * String. - * @return the formatted String. - */ - private String printOFormat(String sx) { - int nLeadingZeros = 0; - int nBlanks = 0; - if (sx == null || sx.equals("0") && precisionSet && precision == 0) - sx = ""; - if (precisionSet) - nLeadingZeros = precision - sx.length(); - if (alternateForm) - nLeadingZeros++; - if (nLeadingZeros < 0) - nLeadingZeros = 0; - if (fieldWidthSet) - nBlanks = fieldWidth - nLeadingZeros - sx.length(); - if (nBlanks < 0) - nBlanks = 0; - int n = nLeadingZeros + sx.length() + nBlanks; - char[] ca = new char[n]; - int i; - if (leftJustify) { - for (i = 0; i < nLeadingZeros; i++) - ca[i] = '0'; - char[] csx = sx.toCharArray(); - for (int j = 0; j < csx.length; j++, i++) - ca[i] = csx[j]; - for (int j = 0; j < nBlanks; j++, i++) - ca[i] = ' '; - } else { - if (leadingZeros) - for (i = 0; i < nBlanks; i++) - ca[i] = '0'; - else - for (i = 0; i < nBlanks; i++) - ca[i] = ' '; - for (int j = 0; j < nLeadingZeros; j++, i++) - ca[i] = '0'; - char[] csx = sx.toCharArray(); - for (int j = 0; j < csx.length; j++, i++) - ca[i] = csx[j]; - } - return new String(ca); - } - /** - * Format method for the c conversion character and - * char argument. - * - * The only flag character that affects c format is - * the '-', meaning that the output should be left - * justified within the field. The default is to - * pad with blanks on the left. - * - * The field width is treated as the minimum number - * of characters to be printed. Padding is with - * blanks by default. The default width is 1. - * - * The precision, if set, is ignored. - * @param x the char to format. - * @return the formatted String. - */ - private String printCFormat(char x) { - int nPrint = 1; - int width = fieldWidth; - if (!fieldWidthSet) - width = nPrint; - char[] ca = new char[width]; - int i = 0; - if (leftJustify) { - ca[0] = x; - for (i = 1; i <= width - nPrint; i++) - ca[i] = ' '; - } else { - for (i = 0; i < width - nPrint; i++) - ca[i] = ' '; - ca[i] = x; - } - return new String(ca); - } - /** - * Format method for the s conversion character and - * String argument. - * - * The only flag character that affects s format is - * the '-', meaning that the output should be left - * justified within the field. The default is to - * pad with blanks on the left. - * - * The field width is treated as the minimum number - * of characters to be printed. The default is the - * smaller of the number of characters in the the - * input and the precision. Padding is with blanks - * by default. - * - * The precision, if set, specifies the maximum - * number of characters to be printed from the - * string. A null digit string is treated - * as a 0. The default is not to set a maximum - * number of characters to be printed. - * @param x the String to format. - * @return the formatted String. - */ - private String printSFormat(String x) { - int nPrint = x.length(); - int width = fieldWidth; - if (precisionSet && nPrint > precision) - nPrint = precision; - if (!fieldWidthSet) - width = nPrint; - int n = 0; - if (width > nPrint) - n += width - nPrint; - if (nPrint >= x.length()) - n += x.length(); - else - n += nPrint; - char[] ca = new char[n]; - int i = 0; - if (leftJustify) { - if (nPrint >= x.length()) { - char[] csx = x.toCharArray(); - for (i = 0; i < x.length(); i++) - ca[i] = csx[i]; - } else { - char[] csx = x.substring(0, nPrint).toCharArray(); - for (i = 0; i < nPrint; i++) - ca[i] = csx[i]; - } - for (int j = 0; j < width - nPrint; j++, i++) - ca[i] = ' '; - } else { - for (i = 0; i < width - nPrint; i++) - ca[i] = ' '; - if (nPrint >= x.length()) { - char[] csx = x.toCharArray(); - for (int j = 0; j < x.length(); i++, j++) - ca[i] = csx[j]; - } else { - char[] csx = x.substring(0, nPrint).toCharArray(); - for (int j = 0; j < nPrint; i++, j++) - ca[i] = csx[j]; - } - } - return new String(ca); - } - /** - * Check for a conversion character. If it is - * there, store it. - * @param x the String to format. - * @return true if the conversion - * character is there, and - * false otherwise. - */ - private boolean setConversionCharacter() { - /* idfgGoxXeEcs */ - boolean ret = false; - conversionCharacter = '\0'; - if (pos < fmt.length()) { - char c = fmt.charAt(pos); - if (c == 'i' - || c == 'd' - || c == 'f' - || c == 'g' - || c == 'G' - || c == 'o' - || c == 'x' - || c == 'X' - || c == 'e' - || c == 'E' - || c == 'c' - || c == 's' - || c == '%') { - conversionCharacter = c; - pos++; - ret = true; - } - } - return ret; - } - /** - * Check for an h, l, or L in a format. An L is - * used to control the minimum number of digits - * in an exponent when using floating point - * formats. An l or h is used to control - * conversion of the input to a long or short, - * respectively, before formatting. If any of - * these is present, store them. - */ - private void setOptionalHL() { - optionalh = false; - optionall = false; - optionalL = false; - if (pos < fmt.length()) { - char c = fmt.charAt(pos); - if (c == 'h') { - optionalh = true; - pos++; - } else if (c == 'l') { - optionall = true; - pos++; - } else if (c == 'L') { - optionalL = true; - pos++; - } - } - } - /** - * Set the precision. - */ - private void setPrecision() { - int firstPos = pos; - precisionSet = false; - if (pos < fmt.length() && fmt.charAt(pos) == '.') { - pos++; - if ((pos < fmt.length()) && (fmt.charAt(pos) == '*')) { - pos++; - if (!setPrecisionArgPosition()) { - variablePrecision = true; - precisionSet = true; - } - return; - } else { - while (pos < fmt.length()) { - char c = fmt.charAt(pos); - if (Character.isDigit(c)) - pos++; - else - break; - } - if (pos > firstPos + 1) { - String sz = fmt.substring(firstPos + 1, pos); - precision = Integer.parseInt(sz); - precisionSet = true; - } - } - } - } - /** - * Set the field width. - */ - private void setFieldWidth() { - int firstPos = pos; - fieldWidth = 0; - fieldWidthSet = false; - if ((pos < fmt.length()) && (fmt.charAt(pos) == '*')) { - pos++; - if (!setFieldWidthArgPosition()) { - variableFieldWidth = true; - fieldWidthSet = true; - } - } else { - while (pos < fmt.length()) { - char c = fmt.charAt(pos); - if (Character.isDigit(c)) - pos++; - else - break; - } - if (firstPos < pos && firstPos < fmt.length()) { - String sz = fmt.substring(firstPos, pos); - fieldWidth = Integer.parseInt(sz); - fieldWidthSet = true; - } - } - } - /** - * Store the digits n in %n$ forms. - */ - private void setArgPosition() { - int xPos; - for (xPos = pos; xPos < fmt.length(); xPos++) { - if (!Character.isDigit(fmt.charAt(xPos))) - break; - } - if (xPos > pos && xPos < fmt.length()) { - if (fmt.charAt(xPos) == '$') { - positionalSpecification = true; - argumentPosition = Integer.parseInt(fmt.substring(pos, xPos)); - pos = xPos + 1; - } - } - } - /** - * Store the digits n in *n$ forms. - */ - private boolean setFieldWidthArgPosition() { - boolean ret = false; - int xPos; - for (xPos = pos; xPos < fmt.length(); xPos++) { - if (!Character.isDigit(fmt.charAt(xPos))) - break; - } - if (xPos > pos && xPos < fmt.length()) { - if (fmt.charAt(xPos) == '$') { - positionalFieldWidth = true; - argumentPositionForFieldWidth = Integer.parseInt(fmt.substring(pos, xPos)); - pos = xPos + 1; - ret = true; - } - } - return ret; - } - /** - * Store the digits n in *n$ forms. - */ - private boolean setPrecisionArgPosition() { - boolean ret = false; - int xPos; - for (xPos = pos; xPos < fmt.length(); xPos++) { - if (!Character.isDigit(fmt.charAt(xPos))) - break; - } - if (xPos > pos && xPos < fmt.length()) { - if (fmt.charAt(xPos) == '$') { - positionalPrecision = true; - argumentPositionForPrecision = Integer.parseInt(fmt.substring(pos, xPos)); - pos = xPos + 1; - ret = true; - } - } - return ret; - } - boolean isPositionalSpecification() { - return positionalSpecification; - } - int getArgumentPosition() { - return argumentPosition; - } - boolean isPositionalFieldWidth() { - return positionalFieldWidth; - } - int getArgumentPositionForFieldWidth() { - return argumentPositionForFieldWidth; - } - boolean isPositionalPrecision() { - return positionalPrecision; - } - int getArgumentPositionForPrecision() { - return argumentPositionForPrecision; - } - /** - * Set flag characters, one of '-+#0 or a space. - */ - private void setFlagCharacters() { - /* '-+ #0 */ - thousands = false; - leftJustify = false; - leadingSign = false; - leadingSpace = false; - alternateForm = false; - leadingZeros = false; - for (; pos < fmt.length(); pos++) { - char c = fmt.charAt(pos); - if (c == '\'') - thousands = true; - else if (c == '-') { - leftJustify = true; - leadingZeros = false; - } else if (c == '+') { - leadingSign = true; - leadingSpace = false; - } else if (c == ' ') { - if (!leadingSign) - leadingSpace = true; - } else if (c == '#') - alternateForm = true; - else if (c == '0') { - if (!leftJustify) - leadingZeros = true; - } else - break; - } - } - /** - * The integer portion of the result of a decimal - * conversion (i, d, u, f, g, or G) will be - * formatted with thousands' grouping characters. - * For other conversions the flag is ignored. - */ - private boolean thousands = false; - /** - * The result of the conversion will be - * left-justified within the field. - */ - private boolean leftJustify = false; - /** - * The result of a signed conversion will always - * begin with a sign (+ or -). - */ - private boolean leadingSign = false; - /** - * Flag indicating that left padding with spaces is - * specified. - */ - private boolean leadingSpace = false; - /** - * For an o conversion, increase the precision to - * force the first digit of the result to be a - * zero. For x (or X) conversions, a non-zero - * result will have 0x (or 0X) prepended to it. - * For e, E, f, g, or G conversions, the result - * will always contain a radix character, even if - * no digits follow the point. For g and G - * conversions, trailing zeros will not be removed - * from the result. - */ - private boolean alternateForm = false; - /** - * Flag indicating that left padding with zeroes is - * specified. - */ - private boolean leadingZeros = false; - /** - * Flag indicating that the field width is *. - */ - private boolean variableFieldWidth = false; - /** - * If the converted value has fewer bytes than the - * field width, it will be padded with spaces or - * zeroes. - */ - private int fieldWidth = 0; - /** - * Flag indicating whether or not the field width - * has been set. - */ - private boolean fieldWidthSet = false; - /** - * The minimum number of digits to appear for the - * d, i, o, u, x, or X conversions. The number of - * digits to appear after the radix character for - * the e, E, and f conversions. The maximum number - * of significant digits for the g and G - * conversions. The maximum number of bytes to be - * printed from a string in s and S conversions. - */ - private int precision = 0; - /** Default precision. */ - private final static int defaultDigits = 6; - /** - * Flag indicating that the precision is *. - */ - private boolean variablePrecision = false; - /** - * Flag indicating whether or not the precision has - * been set. - */ - private boolean precisionSet = false; - /* - */ - private boolean positionalSpecification = false; - private int argumentPosition = 0; - private boolean positionalFieldWidth = false; - private int argumentPositionForFieldWidth = 0; - private boolean positionalPrecision = false; - private int argumentPositionForPrecision = 0; - /** - * Flag specifying that a following d, i, o, u, x, - * or X conversion character applies to a type - * short int. - */ - private boolean optionalh = false; - /** - * Flag specifying that a following d, i, o, u, x, - * or X conversion character applies to a type lont - * int argument. - */ - private boolean optionall = false; - /** - * Flag specifying that a following e, E, f, g, or - * G conversion character applies to a type double - * argument. This is a noop in Java. - */ - private boolean optionalL = false; - /** Control string type. */ - private char conversionCharacter = '\0'; - /** - * Position within the control string. Used by - * the constructor. - */ - private int pos = 0; - /** Literal or control format string. */ - private String fmt; - } - /** Vector of control strings and format literals. */ - private Vector vFmt = new Vector(); - /** Character position. Used by the constructor. */ - private int cPos = 0; - /** Character position. Used by the constructor. */ - private DecimalFormatSymbols dfs = null; + int lead = 0; + if (ca3[0] == '+' || ca3[0] == '-' || ca3[0] == ' ') + lead = 1; + int dp = lead; + for (; dp < ca3.length; dp++) + if (ca3[dp] == '.') + break; + int nThousands = dp / 3; + // Localize the decimal point. + if (dp < ca3.length) + ca3[dp] = dfs.getDecimalSeparator(); + char[] ca4 = ca3; + if (thousands && nThousands > 0) { + ca4 = new char[ca3.length + nThousands + lead]; + ca4[0] = ca3[0]; + for (i = lead, k = lead; i < dp; i++) { + if (i > 0 && (dp - i) % 3 == 0) { + // ca4[k]=','; + ca4[k] = dfs.getGroupingSeparator(); + ca4[k + 1] = ca3[i]; + k += 2; + } else { + ca4[k] = ca3[i]; + k++; + } + } + for (; i < ca3.length; i++, k++) + ca4[k] = ca3[i]; + } + return ca4; + } + /** + * Check to see if the digits that are going to + * be truncated because of the precision should + * force a round in the preceding digits. + * @param ca1 the array of digits + * @param icarry the index of the first digit that + * is to be truncated from the print + * @return true if the truncation forces + * a round that will change the print + */ + private boolean checkForCarry(char[] ca1, int icarry) { + boolean carry = false; + if (icarry < ca1.length) { + if (ca1[icarry] == '6' || ca1[icarry] == '7' || ca1[icarry] == '8' || ca1[icarry] == '9') + carry = true; + else if (ca1[icarry] == '5') { + int ii = icarry + 1; + for (; ii < ca1.length; ii++) + if (ca1[ii] != '0') + break; + carry = ii < ca1.length; + if (!carry && icarry > 0) { + carry = + (ca1[icarry - 1] == '1' + || ca1[icarry - 1] == '3' + || ca1[icarry - 1] == '5' + || ca1[icarry - 1] == '7' + || ca1[icarry - 1] == '9'); + } + } + } + return carry; + } + /** + * Start the symbolic carry process. The process + * is not quite finished because the symbolic + * carry may change the length of the string and + * change the exponent (in e format). + * @param cLast index of the last digit changed + * by the round + * @param cFirst index of the first digit allowed + * to be changed by this phase of the round + * @return true if the carry forces + * a round that will change the print still + * more + */ + private boolean startSymbolicCarry(char[] ca, int cLast, int cFirst) { + boolean carry = true; + for (int i = cLast; carry && i >= cFirst; i--) { + carry = false; + switch (ca[i]) { + case '0' : + ca[i] = '1'; + break; + case '1' : + ca[i] = '2'; + break; + case '2' : + ca[i] = '3'; + break; + case '3' : + ca[i] = '4'; + break; + case '4' : + ca[i] = '5'; + break; + case '5' : + ca[i] = '6'; + break; + case '6' : + ca[i] = '7'; + break; + case '7' : + ca[i] = '8'; + break; + case '8' : + ca[i] = '9'; + break; + case '9' : + ca[i] = '0'; + carry = true; + break; + } + } + return carry; + } + /** + * An intermediate routine on the way to creating + * an e format String. The method decides whether + * the input double value is an infinity, + * not-a-number, or a finite double and formats + * each type of input appropriately. + * @param x the double value to be formatted. + * @param eChar an 'e' or 'E' to use in the + * converted double value. + * @return the converted double value. + */ + private String eFormatString(double x, char eChar) { + // boolean noDigits = false; + char[] ca4, ca5; + if (Double.isInfinite(x)) { + if (x == Double.POSITIVE_INFINITY) { + if (leadingSign) + ca4 = "+Inf".toCharArray(); + else if (leadingSpace) + ca4 = " Inf".toCharArray(); + else + ca4 = "Inf".toCharArray(); + } else + ca4 = "-Inf".toCharArray(); + // noDigits = true; + } else if (Double.isNaN(x)) { + if (leadingSign) + ca4 = "+NaN".toCharArray(); + else if (leadingSpace) + ca4 = " NaN".toCharArray(); + else + ca4 = "NaN".toCharArray(); + // noDigits = true; + } else + ca4 = eFormatDigits(x, eChar); + ca5 = applyFloatPadding(ca4, false); + return new String(ca5); + } + /** + * Apply zero or blank, left or right padding. + * @param ca4 array of characters before padding is + * finished + * @param noDigits NaN or signed Inf + * @return a padded array of characters + */ + private char[] applyFloatPadding(char[] ca4, boolean noDigits) { + char[] ca5 = ca4; + if (fieldWidthSet) { + int i, j, nBlanks; + if (leftJustify) { + nBlanks = fieldWidth - ca4.length; + if (nBlanks > 0) { + ca5 = new char[ca4.length + nBlanks]; + for (i = 0; i < ca4.length; i++) + ca5[i] = ca4[i]; + for (j = 0; j < nBlanks; j++, i++) + ca5[i] = ' '; + } + } else if (!leadingZeros || noDigits) { + nBlanks = fieldWidth - ca4.length; + if (nBlanks > 0) { + ca5 = new char[ca4.length + nBlanks]; + for (i = 0; i < nBlanks; i++) + ca5[i] = ' '; + for (j = 0; j < ca4.length; i++, j++) + ca5[i] = ca4[j]; + } + } else if (leadingZeros) { + nBlanks = fieldWidth - ca4.length; + if (nBlanks > 0) { + ca5 = new char[ca4.length + nBlanks]; + i = 0; + j = 0; + if (ca4[0] == '-') { + ca5[0] = '-'; + i++; + j++; + } + for (int k = 0; k < nBlanks; i++, k++) + ca5[i] = '0'; + for (; j < ca4.length; i++, j++) + ca5[i] = ca4[j]; + } + } + } + return ca5; + } + /** + * Format method for the f conversion character. + * @param x the double to format. + * @return the formatted String. + */ + private String printFFormat(double x) { + return fFormatString(x); + } + /** + * Format method for the e or E conversion + * character. + * @param x the double to format. + * @return the formatted String. + */ + private String printEFormat(double x) { + if (conversionCharacter == 'e') + return eFormatString(x, 'e'); + else + return eFormatString(x, 'E'); + } + /** + * Format method for the g conversion character. + * + * For g format, the flag character '-', means that + * the output should be left justified within the + * field. The default is to pad with blanks on the + * left. '+' character means that the conversion + * will always begin with a sign (+ or -). The + * blank flag character means that a non-negative + * input will be preceded with a blank. If both a + * '+' and a ' ' are specified, the blank flag is + * ignored. The '0' flag character implies that + * padding to the field width will be done with + * zeros instead of blanks. + * + * The field width is treated as the minimum number + * of characters to be printed. The default is to + * add no padding. Padding is with blanks by + * default. + * + * The precision, if set, is the minimum number of + * digits to appear after the radix character. + * Padding is with trailing 0s. + * @param x the double to format. + * @return the formatted String. + */ + private String printGFormat(double x) { + String sx, sy, sz, ret; + int savePrecision = precision; + int i; + char[] ca4, ca5; + // boolean noDigits = false; + if (Double.isInfinite(x)) { + if (x == Double.POSITIVE_INFINITY) { + if (leadingSign) + ca4 = "+Inf".toCharArray(); + else if (leadingSpace) + ca4 = " Inf".toCharArray(); + else + ca4 = "Inf".toCharArray(); + } else + ca4 = "-Inf".toCharArray(); + // noDigits = true; + } else if (Double.isNaN(x)) { + if (leadingSign) + ca4 = "+NaN".toCharArray(); + else if (leadingSpace) + ca4 = " NaN".toCharArray(); + else + ca4 = "NaN".toCharArray(); + // noDigits = true; + } else { + if (!precisionSet) + precision = defaultDigits; + if (precision == 0) + precision = 1; + int ePos = -1; + if (conversionCharacter == 'g') { + sx = eFormatString(x, 'e').trim(); + ePos = sx.indexOf('e'); + } else { + sx = eFormatString(x, 'E').trim(); + ePos = sx.indexOf('E'); + } + i = ePos + 1; + int expon = 0; + if (sx.charAt(i) == '-') { + for (++i; i < sx.length(); i++) + if (sx.charAt(i) != '0') + break; + if (i < sx.length()) + expon = -Integer.parseInt(sx.substring(i)); + } else { + if (sx.charAt(i) == '+') + ++i; + for (; i < sx.length(); i++) + if (sx.charAt(i) != '0') + break; + if (i < sx.length()) + expon = Integer.parseInt(sx.substring(i)); + } + // Trim trailing zeros. + // If the radix character is not followed by + // a digit, trim it, too. + if (!alternateForm) { + if (expon >= -4 && expon < precision) + sy = fFormatString(x).trim(); + else + sy = sx.substring(0, ePos); + i = sy.length() - 1; + for (; i >= 0; i--) + if (sy.charAt(i) != '0') + break; + if (i >= 0 && sy.charAt(i) == '.') + i--; + if (i == -1) + sz = "0"; + else if (!Character.isDigit(sy.charAt(i))) + sz = sy.substring(0, i + 1) + "0"; + else + sz = sy.substring(0, i + 1); + if (expon >= -4 && expon < precision) + ret = sz; + else + ret = sz + sx.substring(ePos); + } else { + if (expon >= -4 && expon < precision) + ret = fFormatString(x).trim(); + else + ret = sx; + } + // leading space was trimmed off during + // construction + if (leadingSpace) + if (x >= 0) + ret = " " + ret; + ca4 = ret.toCharArray(); + } + // Pad with blanks or zeros. + ca5 = applyFloatPadding(ca4, false); + precision = savePrecision; + return new String(ca5); + } + /** + * Format method for the d conversion specifer and + * short argument. + * + * For d format, the flag character '-', means that + * the output should be left justified within the + * field. The default is to pad with blanks on the + * left. A '+' character means that the conversion + * will always begin with a sign (+ or -). The + * blank flag character means that a non-negative + * input will be preceded with a blank. If both a + * '+' and a ' ' are specified, the blank flag is + * ignored. The '0' flag character implies that + * padding to the field width will be done with + * zeros instead of blanks. + * + * The field width is treated as the minimum number + * of characters to be printed. The default is to + * add no padding. Padding is with blanks by + * default. + * + * The precision, if set, is the minimum number of + * digits to appear. Padding is with leading 0s. + * @param x the short to format. + * @return the formatted String. + */ + private String printDFormat(short x) { + return printDFormat(Short.toString(x)); + } + /** + * Format method for the d conversion character and + * long argument. + * + * For d format, the flag character '-', means that + * the output should be left justified within the + * field. The default is to pad with blanks on the + * left. A '+' character means that the conversion + * will always begin with a sign (+ or -). The + * blank flag character means that a non-negative + * input will be preceded with a blank. If both a + * '+' and a ' ' are specified, the blank flag is + * ignored. The '0' flag character implies that + * padding to the field width will be done with + * zeros instead of blanks. + * + * The field width is treated as the minimum number + * of characters to be printed. The default is to + * add no padding. Padding is with blanks by + * default. + * + * The precision, if set, is the minimum number of + * digits to appear. Padding is with leading 0s. + * @param x the long to format. + * @return the formatted String. + */ + private String printDFormat(long x) { + return printDFormat(Long.toString(x)); + } + /** + * Format method for the d conversion character and + * int argument. + * + * For d format, the flag character '-', means that + * the output should be left justified within the + * field. The default is to pad with blanks on the + * left. A '+' character means that the conversion + * will always begin with a sign (+ or -). The + * blank flag character means that a non-negative + * input will be preceded with a blank. If both a + * '+' and a ' ' are specified, the blank flag is + * ignored. The '0' flag character implies that + * padding to the field width will be done with + * zeros instead of blanks. + * + * The field width is treated as the minimum number + * of characters to be printed. The default is to + * add no padding. Padding is with blanks by + * default. + * + * The precision, if set, is the minimum number of + * digits to appear. Padding is with leading 0s. + * @param x the int to format. + * @return the formatted String. + */ + private String printDFormat(int x) { + return printDFormat(Integer.toString(x)); + } + /** + * Utility method for formatting using the d + * conversion character. + * @param sx the String to format, the result of + * converting a short, int, or long to a + * String. + * @return the formatted String. + */ + private String printDFormat(String sx) { + int nLeadingZeros = 0; + int nBlanks = 0, n = 0; + int i = 0, jFirst = 0; + boolean neg = sx.charAt(0) == '-'; + if (sx.equals("0") && precisionSet && precision == 0) + sx = ""; + if (!neg) { + if (precisionSet && sx.length() < precision) + nLeadingZeros = precision - sx.length(); + } else { + if (precisionSet && (sx.length() - 1) < precision) + nLeadingZeros = precision - sx.length() + 1; + } + if (nLeadingZeros < 0) + nLeadingZeros = 0; + if (fieldWidthSet) { + nBlanks = fieldWidth - nLeadingZeros - sx.length(); + if (!neg && (leadingSign || leadingSpace)) + nBlanks--; + } + if (nBlanks < 0) + nBlanks = 0; + if (leadingSign) + n++; + else if (leadingSpace) + n++; + n += nBlanks; + n += nLeadingZeros; + n += sx.length(); + char[] ca = new char[n]; + if (leftJustify) { + if (neg) + ca[i++] = '-'; + else if (leadingSign) + ca[i++] = '+'; + else if (leadingSpace) + ca[i++] = ' '; + char[] csx = sx.toCharArray(); + jFirst = neg ? 1 : 0; + for (int j = 0; j < nLeadingZeros; i++, j++) + ca[i] = '0'; + for (int j = jFirst; j < csx.length; j++, i++) + ca[i] = csx[j]; + for (int j = 0; j < nBlanks; i++, j++) + ca[i] = ' '; + } else { + if (!leadingZeros) { + for (i = 0; i < nBlanks; i++) + ca[i] = ' '; + if (neg) + ca[i++] = '-'; + else if (leadingSign) + ca[i++] = '+'; + else if (leadingSpace) + ca[i++] = ' '; + } else { + if (neg) + ca[i++] = '-'; + else if (leadingSign) + ca[i++] = '+'; + else if (leadingSpace) + ca[i++] = ' '; + for (int j = 0; j < nBlanks; j++, i++) + ca[i] = '0'; + } + for (int j = 0; j < nLeadingZeros; j++, i++) + ca[i] = '0'; + char[] csx = sx.toCharArray(); + jFirst = neg ? 1 : 0; + for (int j = jFirst; j < csx.length; j++, i++) + ca[i] = csx[j]; + } + return new String(ca); + } + /** + * Format method for the x conversion character and + * short argument. + * + * For x format, the flag character '-', means that + * the output should be left justified within the + * field. The default is to pad with blanks on the + * left. The '#' flag character means to lead with + * '0x'. + * + * The field width is treated as the minimum number + * of characters to be printed. The default is to + * add no padding. Padding is with blanks by + * default. + * + * The precision, if set, is the minimum number of + * digits to appear. Padding is with leading 0s. + * @param x the short to format. + * @return the formatted String. + */ + private String printXFormat(short x) { + String sx = null; + if (x == Short.MIN_VALUE) + sx = "8000"; + else if (x < 0) { + String t; + if (x == Short.MIN_VALUE) + t = "0"; + else { + t = Integer.toString((~(-x - 1)) ^ Short.MIN_VALUE, 16); + if (t.charAt(0) == 'F' || t.charAt(0) == 'f') + t = t.substring(16, 32); + } + switch (t.length()) { + case 1 : + sx = "800" + t; + break; + case 2 : + sx = "80" + t; + break; + case 3 : + sx = "8" + t; + break; + case 4 : + switch (t.charAt(0)) { + case '1' : + sx = "9" + t.substring(1, 4); + break; + case '2' : + sx = "a" + t.substring(1, 4); + break; + case '3' : + sx = "b" + t.substring(1, 4); + break; + case '4' : + sx = "c" + t.substring(1, 4); + break; + case '5' : + sx = "d" + t.substring(1, 4); + break; + case '6' : + sx = "e" + t.substring(1, 4); + break; + case '7' : + sx = "f" + t.substring(1, 4); + break; + } + break; + } + } else + sx = Integer.toString((int) x, 16); + return printXFormat(sx); + } + /** + * Format method for the x conversion character and + * long argument. + * + * For x format, the flag character '-', means that + * the output should be left justified within the + * field. The default is to pad with blanks on the + * left. The '#' flag character means to lead with + * '0x'. + * + * The field width is treated as the minimum number + * of characters to be printed. The default is to + * add no padding. Padding is with blanks by + * default. + * + * The precision, if set, is the minimum number of + * digits to appear. Padding is with leading 0s. + * @param x the long to format. + * @return the formatted String. + */ + private String printXFormat(long x) { + String sx = null; + if (x == Long.MIN_VALUE) + sx = "8000000000000000"; + else if (x < 0) { + String t = Long.toString((~(-x - 1)) ^ Long.MIN_VALUE, 16); + switch (t.length()) { + case 1 : + sx = "800000000000000" + t; + break; + case 2 : + sx = "80000000000000" + t; + break; + case 3 : + sx = "8000000000000" + t; + break; + case 4 : + sx = "800000000000" + t; + break; + case 5 : + sx = "80000000000" + t; + break; + case 6 : + sx = "8000000000" + t; + break; + case 7 : + sx = "800000000" + t; + break; + case 8 : + sx = "80000000" + t; + break; + case 9 : + sx = "8000000" + t; + break; + case 10 : + sx = "800000" + t; + break; + case 11 : + sx = "80000" + t; + break; + case 12 : + sx = "8000" + t; + break; + case 13 : + sx = "800" + t; + break; + case 14 : + sx = "80" + t; + break; + case 15 : + sx = "8" + t; + break; + case 16 : + switch (t.charAt(0)) { + case '1' : + sx = "9" + t.substring(1, 16); + break; + case '2' : + sx = "a" + t.substring(1, 16); + break; + case '3' : + sx = "b" + t.substring(1, 16); + break; + case '4' : + sx = "c" + t.substring(1, 16); + break; + case '5' : + sx = "d" + t.substring(1, 16); + break; + case '6' : + sx = "e" + t.substring(1, 16); + break; + case '7' : + sx = "f" + t.substring(1, 16); + break; + } + break; + } + } else + sx = Long.toString(x, 16); + return printXFormat(sx); + } + /** + * Format method for the x conversion character and + * int argument. + * + * For x format, the flag character '-', means that + * the output should be left justified within the + * field. The default is to pad with blanks on the + * left. The '#' flag character means to lead with + * '0x'. + * + * The field width is treated as the minimum number + * of characters to be printed. The default is to + * add no padding. Padding is with blanks by + * default. + * + * The precision, if set, is the minimum number of + * digits to appear. Padding is with leading 0s. + * @param x the int to format. + * @return the formatted String. + */ + private String printXFormat(int x) { + String sx = null; + if (x == Integer.MIN_VALUE) + sx = "80000000"; + else if (x < 0) { + String t = Integer.toString((~(-x - 1)) ^ Integer.MIN_VALUE, 16); + switch (t.length()) { + case 1 : + sx = "8000000" + t; + break; + case 2 : + sx = "800000" + t; + break; + case 3 : + sx = "80000" + t; + break; + case 4 : + sx = "8000" + t; + break; + case 5 : + sx = "800" + t; + break; + case 6 : + sx = "80" + t; + break; + case 7 : + sx = "8" + t; + break; + case 8 : + switch (t.charAt(0)) { + case '1' : + sx = "9" + t.substring(1, 8); + break; + case '2' : + sx = "a" + t.substring(1, 8); + break; + case '3' : + sx = "b" + t.substring(1, 8); + break; + case '4' : + sx = "c" + t.substring(1, 8); + break; + case '5' : + sx = "d" + t.substring(1, 8); + break; + case '6' : + sx = "e" + t.substring(1, 8); + break; + case '7' : + sx = "f" + t.substring(1, 8); + break; + } + break; + } + } else + sx = Integer.toString(x, 16); + return printXFormat(sx); + } + /** + * Utility method for formatting using the x + * conversion character. + * @param sx the String to format, the result of + * converting a short, int, or long to a + * String. + * @return the formatted String. + */ + private String printXFormat(String sx) { + int nLeadingZeros = 0; + int nBlanks = 0; + if (sx == null || sx.equals("0") && precisionSet && precision == 0) + sx = ""; + if (precisionSet) + nLeadingZeros = precision - sx.length(); + if (nLeadingZeros < 0) + nLeadingZeros = 0; + if (fieldWidthSet) { + nBlanks = fieldWidth - nLeadingZeros - sx.length(); + if (alternateForm) + nBlanks = nBlanks - 2; + } + if (nBlanks < 0) + nBlanks = 0; + int n = 0; + if (alternateForm) + n += 2; + n += nLeadingZeros; + n += sx.length(); + n += nBlanks; + char[] ca = new char[n]; + int i = 0; + if (leftJustify) { + if (alternateForm) { + ca[i++] = '0'; + ca[i++] = 'x'; + } + for (int j = 0; j < nLeadingZeros; j++, i++) + ca[i] = '0'; + char[] csx = sx.toCharArray(); + for (int j = 0; j < csx.length; j++, i++) + ca[i] = csx[j]; + for (int j = 0; j < nBlanks; j++, i++) + ca[i] = ' '; + } else { + if (!leadingZeros) + for (int j = 0; j < nBlanks; j++, i++) + ca[i] = ' '; + if (alternateForm) { + ca[i++] = '0'; + ca[i++] = 'x'; + } + if (leadingZeros) + for (int j = 0; j < nBlanks; j++, i++) + ca[i] = '0'; + for (int j = 0; j < nLeadingZeros; j++, i++) + ca[i] = '0'; + char[] csx = sx.toCharArray(); + for (int j = 0; j < csx.length; j++, i++) + ca[i] = csx[j]; + } + String caReturn = new String(ca); + if (conversionCharacter == 'X') + caReturn = caReturn.toUpperCase(); + return caReturn; + } + /** + * Format method for the o conversion character and + * short argument. + * + * For o format, the flag character '-', means that + * the output should be left justified within the + * field. The default is to pad with blanks on the + * left. The '#' flag character means that the + * output begins with a leading 0 and the precision + * is increased by 1. + * + * The field width is treated as the minimum number + * of characters to be printed. The default is to + * add no padding. Padding is with blanks by + * default. + * + * The precision, if set, is the minimum number of + * digits to appear. Padding is with leading 0s. + * @param x the short to format. + * @return the formatted String. + */ + private String printOFormat(short x) { + String sx = null; + if (x == Short.MIN_VALUE) + sx = "100000"; + else if (x < 0) { + String t = Integer.toString((~(-x - 1)) ^ Short.MIN_VALUE, 8); + switch (t.length()) { + case 1 : + sx = "10000" + t; + break; + case 2 : + sx = "1000" + t; + break; + case 3 : + sx = "100" + t; + break; + case 4 : + sx = "10" + t; + break; + case 5 : + sx = "1" + t; + break; + } + } else + sx = Integer.toString((int) x, 8); + return printOFormat(sx); + } + /** + * Format method for the o conversion character and + * long argument. + * + * For o format, the flag character '-', means that + * the output should be left justified within the + * field. The default is to pad with blanks on the + * left. The '#' flag character means that the + * output begins with a leading 0 and the precision + * is increased by 1. + * + * The field width is treated as the minimum number + * of characters to be printed. The default is to + * add no padding. Padding is with blanks by + * default. + * + * The precision, if set, is the minimum number of + * digits to appear. Padding is with leading 0s. + * @param x the long to format. + * @return the formatted String. + */ + private String printOFormat(long x) { + String sx = null; + if (x == Long.MIN_VALUE) + sx = "1000000000000000000000"; + else if (x < 0) { + String t = Long.toString((~(-x - 1)) ^ Long.MIN_VALUE, 8); + switch (t.length()) { + case 1 : + sx = "100000000000000000000" + t; + break; + case 2 : + sx = "10000000000000000000" + t; + break; + case 3 : + sx = "1000000000000000000" + t; + break; + case 4 : + sx = "100000000000000000" + t; + break; + case 5 : + sx = "10000000000000000" + t; + break; + case 6 : + sx = "1000000000000000" + t; + break; + case 7 : + sx = "100000000000000" + t; + break; + case 8 : + sx = "10000000000000" + t; + break; + case 9 : + sx = "1000000000000" + t; + break; + case 10 : + sx = "100000000000" + t; + break; + case 11 : + sx = "10000000000" + t; + break; + case 12 : + sx = "1000000000" + t; + break; + case 13 : + sx = "100000000" + t; + break; + case 14 : + sx = "10000000" + t; + break; + case 15 : + sx = "1000000" + t; + break; + case 16 : + sx = "100000" + t; + break; + case 17 : + sx = "10000" + t; + break; + case 18 : + sx = "1000" + t; + break; + case 19 : + sx = "100" + t; + break; + case 20 : + sx = "10" + t; + break; + case 21 : + sx = "1" + t; + break; + } + } else + sx = Long.toString(x, 8); + return printOFormat(sx); + } + /** + * Format method for the o conversion character and + * int argument. + * + * For o format, the flag character '-', means that + * the output should be left justified within the + * field. The default is to pad with blanks on the + * left. The '#' flag character means that the + * output begins with a leading 0 and the precision + * is increased by 1. + * + * The field width is treated as the minimum number + * of characters to be printed. The default is to + * add no padding. Padding is with blanks by + * default. + * + * The precision, if set, is the minimum number of + * digits to appear. Padding is with leading 0s. + * @param x the int to format. + * @return the formatted String. + */ + private String printOFormat(int x) { + String sx = null; + if (x == Integer.MIN_VALUE) + sx = "20000000000"; + else if (x < 0) { + String t = Integer.toString((~(-x - 1)) ^ Integer.MIN_VALUE, 8); + switch (t.length()) { + case 1 : + sx = "2000000000" + t; + break; + case 2 : + sx = "200000000" + t; + break; + case 3 : + sx = "20000000" + t; + break; + case 4 : + sx = "2000000" + t; + break; + case 5 : + sx = "200000" + t; + break; + case 6 : + sx = "20000" + t; + break; + case 7 : + sx = "2000" + t; + break; + case 8 : + sx = "200" + t; + break; + case 9 : + sx = "20" + t; + break; + case 10 : + sx = "2" + t; + break; + case 11 : + sx = "3" + t.substring(1); + break; + } + } else + sx = Integer.toString(x, 8); + return printOFormat(sx); + } + /** + * Utility method for formatting using the o + * conversion character. + * @param sx the String to format, the result of + * converting a short, int, or long to a + * String. + * @return the formatted String. + */ + private String printOFormat(String sx) { + int nLeadingZeros = 0; + int nBlanks = 0; + if (sx == null || sx.equals("0") && precisionSet && precision == 0) + sx = ""; + if (precisionSet) + nLeadingZeros = precision - sx.length(); + if (alternateForm) + nLeadingZeros++; + if (nLeadingZeros < 0) + nLeadingZeros = 0; + if (fieldWidthSet) + nBlanks = fieldWidth - nLeadingZeros - sx.length(); + if (nBlanks < 0) + nBlanks = 0; + int n = nLeadingZeros + sx.length() + nBlanks; + char[] ca = new char[n]; + int i; + if (leftJustify) { + for (i = 0; i < nLeadingZeros; i++) + ca[i] = '0'; + char[] csx = sx.toCharArray(); + for (int j = 0; j < csx.length; j++, i++) + ca[i] = csx[j]; + for (int j = 0; j < nBlanks; j++, i++) + ca[i] = ' '; + } else { + if (leadingZeros) + for (i = 0; i < nBlanks; i++) + ca[i] = '0'; + else + for (i = 0; i < nBlanks; i++) + ca[i] = ' '; + for (int j = 0; j < nLeadingZeros; j++, i++) + ca[i] = '0'; + char[] csx = sx.toCharArray(); + for (int j = 0; j < csx.length; j++, i++) + ca[i] = csx[j]; + } + return new String(ca); + } + /** + * Format method for the c conversion character and + * char argument. + * + * The only flag character that affects c format is + * the '-', meaning that the output should be left + * justified within the field. The default is to + * pad with blanks on the left. + * + * The field width is treated as the minimum number + * of characters to be printed. Padding is with + * blanks by default. The default width is 1. + * + * The precision, if set, is ignored. + * @param x the char to format. + * @return the formatted String. + */ + private String printCFormat(char x) { + int nPrint = 1; + int width = fieldWidth; + if (!fieldWidthSet) + width = nPrint; + char[] ca = new char[width]; + int i = 0; + if (leftJustify) { + ca[0] = x; + for (i = 1; i <= width - nPrint; i++) + ca[i] = ' '; + } else { + for (i = 0; i < width - nPrint; i++) + ca[i] = ' '; + ca[i] = x; + } + return new String(ca); + } + /** + * Format method for the s conversion character and + * String argument. + * + * The only flag character that affects s format is + * the '-', meaning that the output should be left + * justified within the field. The default is to + * pad with blanks on the left. + * + * The field width is treated as the minimum number + * of characters to be printed. The default is the + * smaller of the number of characters in the the + * input and the precision. Padding is with blanks + * by default. + * + * The precision, if set, specifies the maximum + * number of characters to be printed from the + * string. A null digit string is treated + * as a 0. The default is not to set a maximum + * number of characters to be printed. + * @param x the String to format. + * @return the formatted String. + */ + private String printSFormat(String x) { + int nPrint = x.length(); + int width = fieldWidth; + if (precisionSet && nPrint > precision) + nPrint = precision; + if (!fieldWidthSet) + width = nPrint; + int n = 0; + if (width > nPrint) + n += width - nPrint; + if (nPrint >= x.length()) + n += x.length(); + else + n += nPrint; + char[] ca = new char[n]; + int i = 0; + if (leftJustify) { + if (nPrint >= x.length()) { + char[] csx = x.toCharArray(); + for (i = 0; i < x.length(); i++) + ca[i] = csx[i]; + } else { + char[] csx = x.substring(0, nPrint).toCharArray(); + for (i = 0; i < nPrint; i++) + ca[i] = csx[i]; + } + for (int j = 0; j < width - nPrint; j++, i++) + ca[i] = ' '; + } else { + for (i = 0; i < width - nPrint; i++) + ca[i] = ' '; + if (nPrint >= x.length()) { + char[] csx = x.toCharArray(); + for (int j = 0; j < x.length(); i++, j++) + ca[i] = csx[j]; + } else { + char[] csx = x.substring(0, nPrint).toCharArray(); + for (int j = 0; j < nPrint; i++, j++) + ca[i] = csx[j]; + } + } + return new String(ca); + } + /** + * Check for a conversion character. If it is + * there, store it. + * @param x the String to format. + * @return true if the conversion + * character is there, and + * false otherwise. + */ + private boolean setConversionCharacter() { + /* idfgGoxXeEcs */ + boolean ret = false; + conversionCharacter = '\0'; + if (pos < fmt.length()) { + char c = fmt.charAt(pos); + if (c == 'i' + || c == 'd' + || c == 'f' + || c == 'g' + || c == 'G' + || c == 'o' + || c == 'x' + || c == 'X' + || c == 'e' + || c == 'E' + || c == 'c' + || c == 's' + || c == '%') { + conversionCharacter = c; + pos++; + ret = true; + } + } + return ret; + } + /** + * Check for an h, l, or L in a format. An L is + * used to control the minimum number of digits + * in an exponent when using floating point + * formats. An l or h is used to control + * conversion of the input to a long or short, + * respectively, before formatting. If any of + * these is present, store them. + */ + private void setOptionalHL() { + optionalh = false; + optionall = false; + optionalL = false; + if (pos < fmt.length()) { + char c = fmt.charAt(pos); + if (c == 'h') { + optionalh = true; + pos++; + } else if (c == 'l') { + optionall = true; + pos++; + } else if (c == 'L') { + optionalL = true; + pos++; + } + } + } + /** + * Set the precision. + */ + private void setPrecision() { + int firstPos = pos; + precisionSet = false; + if (pos < fmt.length() && fmt.charAt(pos) == '.') { + pos++; + if ((pos < fmt.length()) && (fmt.charAt(pos) == '*')) { + pos++; + if (!setPrecisionArgPosition()) { + variablePrecision = true; + precisionSet = true; + } + return; + } else { + while (pos < fmt.length()) { + char c = fmt.charAt(pos); + if (Character.isDigit(c)) + pos++; + else + break; + } + if (pos > firstPos + 1) { + String sz = fmt.substring(firstPos + 1, pos); + precision = Integer.parseInt(sz); + precisionSet = true; + } + } + } + } + /** + * Set the field width. + */ + private void setFieldWidth() { + int firstPos = pos; + fieldWidth = 0; + fieldWidthSet = false; + if ((pos < fmt.length()) && (fmt.charAt(pos) == '*')) { + pos++; + if (!setFieldWidthArgPosition()) { + variableFieldWidth = true; + fieldWidthSet = true; + } + } else { + while (pos < fmt.length()) { + char c = fmt.charAt(pos); + if (Character.isDigit(c)) + pos++; + else + break; + } + if (firstPos < pos && firstPos < fmt.length()) { + String sz = fmt.substring(firstPos, pos); + fieldWidth = Integer.parseInt(sz); + fieldWidthSet = true; + } + } + } + /** + * Store the digits n in %n$ forms. + */ + private void setArgPosition() { + int xPos; + for (xPos = pos; xPos < fmt.length(); xPos++) { + if (!Character.isDigit(fmt.charAt(xPos))) + break; + } + if (xPos > pos && xPos < fmt.length()) { + if (fmt.charAt(xPos) == '$') { + positionalSpecification = true; + argumentPosition = Integer.parseInt(fmt.substring(pos, xPos)); + pos = xPos + 1; + } + } + } + /** + * Store the digits n in *n$ forms. + */ + private boolean setFieldWidthArgPosition() { + boolean ret = false; + int xPos; + for (xPos = pos; xPos < fmt.length(); xPos++) { + if (!Character.isDigit(fmt.charAt(xPos))) + break; + } + if (xPos > pos && xPos < fmt.length()) { + if (fmt.charAt(xPos) == '$') { + positionalFieldWidth = true; + argumentPositionForFieldWidth = Integer.parseInt(fmt.substring(pos, xPos)); + pos = xPos + 1; + ret = true; + } + } + return ret; + } + /** + * Store the digits n in *n$ forms. + */ + private boolean setPrecisionArgPosition() { + boolean ret = false; + int xPos; + for (xPos = pos; xPos < fmt.length(); xPos++) { + if (!Character.isDigit(fmt.charAt(xPos))) + break; + } + if (xPos > pos && xPos < fmt.length()) { + if (fmt.charAt(xPos) == '$') { + positionalPrecision = true; + argumentPositionForPrecision = Integer.parseInt(fmt.substring(pos, xPos)); + pos = xPos + 1; + ret = true; + } + } + return ret; + } + boolean isPositionalSpecification() { + return positionalSpecification; + } + int getArgumentPosition() { + return argumentPosition; + } + boolean isPositionalFieldWidth() { + return positionalFieldWidth; + } + int getArgumentPositionForFieldWidth() { + return argumentPositionForFieldWidth; + } + boolean isPositionalPrecision() { + return positionalPrecision; + } + int getArgumentPositionForPrecision() { + return argumentPositionForPrecision; + } + /** + * Set flag characters, one of '-+#0 or a space. + */ + private void setFlagCharacters() { + /* '-+ #0 */ + thousands = false; + leftJustify = false; + leadingSign = false; + leadingSpace = false; + alternateForm = false; + leadingZeros = false; + for (; pos < fmt.length(); pos++) { + char c = fmt.charAt(pos); + if (c == '\'') + thousands = true; + else if (c == '-') { + leftJustify = true; + leadingZeros = false; + } else if (c == '+') { + leadingSign = true; + leadingSpace = false; + } else if (c == ' ') { + if (!leadingSign) + leadingSpace = true; + } else if (c == '#') + alternateForm = true; + else if (c == '0') { + if (!leftJustify) + leadingZeros = true; + } else + break; + } + } + /** + * The integer portion of the result of a decimal + * conversion (i, d, u, f, g, or G) will be + * formatted with thousands' grouping characters. + * For other conversions the flag is ignored. + */ + private boolean thousands = false; + /** + * The result of the conversion will be + * left-justified within the field. + */ + private boolean leftJustify = false; + /** + * The result of a signed conversion will always + * begin with a sign (+ or -). + */ + private boolean leadingSign = false; + /** + * Flag indicating that left padding with spaces is + * specified. + */ + private boolean leadingSpace = false; + /** + * For an o conversion, increase the precision to + * force the first digit of the result to be a + * zero. For x (or X) conversions, a non-zero + * result will have 0x (or 0X) prepended to it. + * For e, E, f, g, or G conversions, the result + * will always contain a radix character, even if + * no digits follow the point. For g and G + * conversions, trailing zeros will not be removed + * from the result. + */ + private boolean alternateForm = false; + /** + * Flag indicating that left padding with zeroes is + * specified. + */ + private boolean leadingZeros = false; + /** + * Flag indicating that the field width is *. + */ + private boolean variableFieldWidth = false; + /** + * If the converted value has fewer bytes than the + * field width, it will be padded with spaces or + * zeroes. + */ + private int fieldWidth = 0; + /** + * Flag indicating whether or not the field width + * has been set. + */ + private boolean fieldWidthSet = false; + /** + * The minimum number of digits to appear for the + * d, i, o, u, x, or X conversions. The number of + * digits to appear after the radix character for + * the e, E, and f conversions. The maximum number + * of significant digits for the g and G + * conversions. The maximum number of bytes to be + * printed from a string in s and S conversions. + */ + private int precision = 0; + /** Default precision. */ + private final static int defaultDigits = 6; + /** + * Flag indicating that the precision is *. + */ + private boolean variablePrecision = false; + /** + * Flag indicating whether or not the precision has + * been set. + */ + private boolean precisionSet = false; + /* + */ + private boolean positionalSpecification = false; + private int argumentPosition = 0; + private boolean positionalFieldWidth = false; + private int argumentPositionForFieldWidth = 0; + private boolean positionalPrecision = false; + private int argumentPositionForPrecision = 0; + /** + * Flag specifying that a following d, i, o, u, x, + * or X conversion character applies to a type + * short int. + */ + private boolean optionalh = false; + /** + * Flag specifying that a following d, i, o, u, x, + * or X conversion character applies to a type lont + * int argument. + */ + private boolean optionall = false; + /** + * Flag specifying that a following e, E, f, g, or + * G conversion character applies to a type double + * argument. This is a noop in Java. + */ + private boolean optionalL = false; + /** Control string type. */ + private char conversionCharacter = '\0'; + /** + * Position within the control string. Used by + * the constructor. + */ + private int pos = 0; + /** Literal or control format string. */ + private String fmt; + } + /** Vector of control strings and format literals. */ + private Vector vFmt = new Vector(); + /** Character position. Used by the constructor. */ + private int cPos = 0; + /** Character position. Used by the constructor. */ + private DecimalFormatSymbols dfs = null; } diff --git a/src/main/java/lwjake2/util/Vargs.java b/src/main/java/lwjake2/util/Vargs.java index 97d2bfa..f2ae395 100644 --- a/src/main/java/lwjake2/util/Vargs.java +++ b/src/main/java/lwjake2/util/Vargs.java @@ -27,90 +27,90 @@ import java.util.Vector; */ public class Vargs { - // initial capacity - static final int SIZE = 5; + // initial capacity + static final int SIZE = 5; - Vector v = null; + Vector v = null; - public Vargs() { - this(SIZE); - } + public Vargs() { + this(SIZE); + } - public Vargs(int initialSize) { - if (v != null) - v.clear(); // clear previous list for GC - v = new Vector<>(initialSize); - } + public Vargs(int initialSize) { + if (v != null) + v.clear(); // clear previous list for GC + v = new Vector<>(initialSize); + } - public Vargs add(boolean value) { - v.add(value); - return this; - } + public Vargs add(boolean value) { + v.add(value); + return this; + } - public Vargs add(byte value) { - v.add(value); - return this; - } + public Vargs add(byte value) { + v.add(value); + return this; + } - public Vargs add(char value) { - v.add(value); - return this; - } + public Vargs add(char value) { + v.add(value); + return this; + } - public Vargs add(short value) { - v.add(value); - return this; - } + public Vargs add(short value) { + v.add(value); + return this; + } - public Vargs add(int value) { - v.add(value); - return this; - } + public Vargs add(int value) { + v.add(value); + return this; + } - public Vargs add(long value) { - v.add(value); - return this; - } + public Vargs add(long value) { + v.add(value); + return this; + } - public Vargs add(float value) { - v.add(value); - return this; - } + public Vargs add(float value) { + v.add(value); + return this; + } - public Vargs add(double value) { - v.add(value); - return this; - } + public Vargs add(double value) { + v.add(value); + return this; + } - public Vargs add(String value) { - v.add(value); - return this; - } + public Vargs add(String value) { + v.add(value); + return this; + } - public Vargs add(Object value) { - v.add(value); - return this; - } + public Vargs add(Object value) { + v.add(value); + return this; + } - public Vargs clear() { - v.clear(); - return this; - } + public Vargs clear() { + v.clear(); + return this; + } - /* This apparently isn't even used? - flibit - public Vector toVector() { - // Vector tmp = v; - // v = null; - // return tmp; - return (Vector) v.clone(); - } - */ + /* This apparently isn't even used? - flibit + public Vector toVector() { + // Vector tmp = v; + // v = null; + // return tmp; + return (Vector) v.clone(); + } + */ - public Object[] toArray() { - return v.toArray(); - } + public Object[] toArray() { + return v.toArray(); + } - public int size() { - return v.size(); - } + public int size() { + return v.size(); + } }