From 5257417f0e8e57ed5023c404bbe31680218dfc2b Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Thu, 24 Mar 2016 12:17:13 +0100 Subject: [PATCH 01/17] Added 0.0.5 release video --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index adebf33f..786d75b8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ #djoom3 - a Doom 3 Java port. + +####23-03-16 +Version 0.0.5 + +[http://www.youtube.com/watch?v=JstU-T1mHPo](http://www.youtube.com/watch?v=JstU-T1mHPo) +[![Screenshot](http://img.youtube.com/vi/JstU-T1mHPo/0.jpg)](http://www.youtube.com/watch?v=JstU-T1mHPo"djoom3 0.0.5") + + ####05-03-16 Version 0.0.4 From d082667a9d9428894f032c5fcffd8b20d1454fee Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Wed, 20 Apr 2016 16:02:05 +0200 Subject: [PATCH 02/17] -refactored some of the mouse input event handling -small qsort fix --- pom.xml | 2 +- src/main/java/neo/Game/Physics/Clip.java | 65 ++++++----- .../neo/Game/Physics/Physics_RigidBody.java | 7 +- .../java/neo/Renderer/RenderSystem_init.java | 4 +- src/main/java/neo/Renderer/tr_main.java | 6 +- src/main/java/neo/framework/UsercmdGen.java | 110 ++++++++++-------- src/main/java/neo/sys/win_input.java | 1 + src/main/java/neo/sys/win_main.java | 11 +- 8 files changed, 104 insertions(+), 102 deletions(-) diff --git a/pom.xml b/pom.xml index 521aa717..de7297ec 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.djoom3 djoom3 - 0.5-SNAPSHOT + 0.6-SNAPSHOT jar diff --git a/src/main/java/neo/Game/Physics/Clip.java b/src/main/java/neo/Game/Physics/Clip.java index 495e7daf..dac05354 100644 --- a/src/main/java/neo/Game/Physics/Clip.java +++ b/src/main/java/neo/Game/Physics/Clip.java @@ -10,6 +10,8 @@ import neo.Game.Entity.idEntity; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; + +import static neo.CM.CollisionModel_local.collisionModelManager; import static neo.Game.Game_local.ENTITYNUM_NONE; import static neo.Game.Game_local.ENTITYNUM_WORLD; import static neo.Game.Game_local.MAX_GENTITIES; @@ -187,12 +189,12 @@ public final boolean LoadModel(final String name) { FreeTraceModel(traceModelIndex); traceModelIndex = -1; } - collisionModelHandle = CollisionModel_local.collisionModelManager.LoadModel(name, false); + collisionModelHandle = collisionModelManager.LoadModel(name, false); if (collisionModelHandle != 0) { - CollisionModel_local.collisionModelManager.GetModelBounds(collisionModelHandle, bounds); + collisionModelManager.GetModelBounds(collisionModelHandle, bounds); { int[] contents = {0}; - CollisionModel_local.collisionModelManager.GetModelContents(collisionModelHandle, contents); + collisionModelManager.GetModelContents(collisionModelHandle, contents); this.contents = contents[0]; } return true; @@ -239,7 +241,7 @@ public void Save(idSaveGame savefile) { savefile.WriteMaterial(material); savefile.WriteInt(contents); if (collisionModelHandle >= 0) { - savefile.WriteString(CollisionModel_local.collisionModelManager.GetModelName(collisionModelHandle)); + savefile.WriteString(collisionModelManager.GetModelName(collisionModelHandle)); } else { savefile.WriteString(""); } @@ -265,7 +267,7 @@ public void Restore(idRestoreGame savefile) { contents = savefile.ReadInt(); savefile.ReadString(collisionModelName); if (collisionModelName.Length() != 0) { - collisionModelHandle = CollisionModel_local.collisionModelManager.LoadModel(collisionModelName.toString(), false); + collisionModelHandle = collisionModelManager.LoadModel(collisionModelName.toString(), false); } else { collisionModelHandle = -1; } @@ -465,7 +467,7 @@ public boolean IsEqual(final idTraceModel trm) { if (collisionModelHandle != 0) { return collisionModelHandle; } else if (traceModelIndex != -1) { - return CollisionModel_local.collisionModelManager.SetupTrmModel(GetCachedTraceModel(traceModelIndex), material); + return collisionModelManager.SetupTrmModel(GetCachedTraceModel(traceModelIndex), material); } else { // this happens in multiplayer on the combat models gameLocal.Warning("idClipModel::Handle: clip model %d on '%s' (%x) is not a collision or trace model", id, entity.name, entity.entityNumber); @@ -492,7 +494,7 @@ public void GetMassProperties(final float density, float[] mass, idVec3 centerOf } public static int/*cmHandle_t*/ CheckModel(final String name) { - return CollisionModel_local.collisionModelManager.LoadModel(name, false); + return collisionModelManager.LoadModel(name, false); } public static int/*cmHandle_t*/ CheckModel(final idStr name) { @@ -682,8 +684,8 @@ public void Init() { numClipSectors = 0; touchCount = -1; // get world map bounds - h = CollisionModel_local.collisionModelManager.LoadModel("worldMap", false); - CollisionModel_local.collisionModelManager.GetModelBounds(h, worldBounds); + h = collisionModelManager.LoadModel("worldMap", false); + collisionModelManager.GetModelBounds(h, worldBounds); // create world sectors CreateClipSectors_r(0, worldBounds, maxSector); @@ -737,7 +739,7 @@ public boolean Translation(trace_s[] results, final idVec3 start, final idVec3 e if (null == passEntity || passEntity.entityNumber != ENTITYNUM_WORLD) { // test world this.numTranslations++; - CollisionModel_local.collisionModelManager.Translation(results, start, end, trm, trmAxis, contentMask, 0, getVec3_origin(), getMat3_default()); + collisionModelManager.Translation(results, start, end, trm, trmAxis, contentMask, 0, getVec3_origin(), getMat3_default()); results[0].c.entityNum = results[0].fraction != 1.0f ? ENTITYNUM_WORLD : ENTITYNUM_NONE; if (results[0].fraction == 0.0f) { return true; // blocked immediately by the world @@ -772,7 +774,7 @@ public boolean Translation(trace_s[] results, final idVec3 start, final idVec3 e TraceRenderModel(trace[0], start, end, radius, trmAxis, touch); } else { this.numTranslations++; - CollisionModel_local.collisionModelManager.Translation(trace, start, end, trm, trmAxis, contentMask, touch.Handle(), touch.origin, touch.axis); + collisionModelManager.Translation(trace, start, end, trm, trmAxis, contentMask, touch.Handle(), touch.origin, touch.axis); } if (trace[0].fraction < results[0].fraction) { @@ -802,7 +804,7 @@ public boolean Rotation(trace_s[] results, final idVec3 start, final idRotation if (null == passEntity || passEntity.entityNumber != ENTITYNUM_WORLD) { // test world this.numRotations++; - CollisionModel_local.collisionModelManager.Rotation(results, start, rotation, trm, trmAxis, contentMask, 0, getVec3_origin(), getMat3_default()); + collisionModelManager.Rotation(results, start, rotation, trm, trmAxis, contentMask, 0, getVec3_origin(), getMat3_default()); results[0].c.entityNum = results[0].fraction != 1.0f ? ENTITYNUM_WORLD : ENTITYNUM_NONE; if (results[0].fraction == 0.0f) { return true; // blocked immediately by the world @@ -836,7 +838,7 @@ public boolean Rotation(trace_s[] results, final idVec3 start, final idRotation } this.numRotations++; - CollisionModel_local.collisionModelManager.Rotation(trace, start, rotation, trm, trmAxis, contentMask, touch.Handle(), touch.origin, touch.axis); + collisionModelManager.Rotation(trace, start, rotation, trm, trmAxis, contentMask, touch.Handle(), touch.origin, touch.axis); if (trace[0].fraction < results[0].fraction) { results[0] = trace[0]; @@ -894,7 +896,7 @@ public boolean Motion(trace_s[] results, final idVec3 start, final idVec3 end, f if (null == passEntity || passEntity.entityNumber != ENTITYNUM_WORLD) { // translational collision with world this.numTranslations++; - CollisionModel_local.collisionModelManager.Translation(translationalTrace, start, end, trm, trmAxis, contentMask, 0, getVec3_origin(), getMat3_default()); + collisionModelManager.Translation(translationalTrace, start, end, trm, trmAxis, contentMask, 0, getVec3_origin(), getMat3_default()); translationalTrace[0].c.entityNum = translationalTrace[0].fraction != 1.0f ? ENTITYNUM_WORLD : ENTITYNUM_NONE; } else { // memset( &translationalTrace, 0, sizeof( translationalTrace ) ); @@ -930,7 +932,7 @@ public boolean Motion(trace_s[] results, final idVec3 start, final idVec3 end, f TraceRenderModel(trace[0], start, end, radius, trmAxis, touch); } else { this.numTranslations++; - CollisionModel_local.collisionModelManager.Translation(trace, start, end, trm, trmAxis, contentMask, touch.Handle(), touch.origin, touch.axis); + collisionModelManager.Translation(trace, start, end, trm, trmAxis, contentMask, touch.Handle(), touch.origin, touch.axis); } if (trace[0].fraction < translationalTrace[0].fraction) { @@ -953,7 +955,7 @@ public boolean Motion(trace_s[] results, final idVec3 start, final idVec3 end, f if (null == passEntity || passEntity.entityNumber != ENTITYNUM_WORLD) { // rotational collision with world this.numRotations++; - CollisionModel_local.collisionModelManager.Rotation(rotationalTrace, endPosition, endRotation, trm, trmAxis, contentMask, 0, getVec3_origin(), getMat3_default()); + collisionModelManager.Rotation(rotationalTrace, endPosition, endRotation, trm, trmAxis, contentMask, 0, getVec3_origin(), getMat3_default()); rotationalTrace[0].c.entityNum = rotationalTrace[0].fraction != 1.0f ? ENTITYNUM_WORLD : ENTITYNUM_NONE; } else { // memset( &rotationalTrace, 0, sizeof( rotationalTrace ) ); @@ -983,7 +985,7 @@ public boolean Motion(trace_s[] results, final idVec3 start, final idVec3 end, f } this.numRotations++; - CollisionModel_local.collisionModelManager.Rotation(trace, endPosition, endRotation, trm, trmAxis, contentMask, touch.Handle(), touch.origin, touch.axis); + collisionModelManager.Rotation(trace, endPosition, endRotation, trm, trmAxis, contentMask, touch.Handle(), touch.origin, touch.axis); if (trace[0].fraction < rotationalTrace[0].fraction) { rotationalTrace[0] = trace[0]; @@ -1021,7 +1023,7 @@ public int Contacts(contactInfo_t[] contacts, final int maxContacts, final idVec if (null == passEntity || passEntity.entityNumber != ENTITYNUM_WORLD) { // test world this.numContacts++; - numContacts = CollisionModel_local.collisionModelManager.Contacts(contacts, maxContacts, start, dir, depth, trm, trmAxis, contentMask, 0, getVec3_origin(), getMat3_default()); + numContacts = collisionModelManager.Contacts(contacts, maxContacts, start, dir, depth, trm, trmAxis, contentMask, 0, getVec3_origin(), getMat3_default()); } else { numContacts = 0; } @@ -1057,7 +1059,7 @@ public int Contacts(contactInfo_t[] contacts, final int maxContacts, final idVec } this.numContacts++; - n = CollisionModel_local.collisionModelManager.Contacts( + n = collisionModelManager.Contacts( Arrays.copyOfRange(contacts, numContacts, contacts.length), maxContacts - numContacts, start, dir, depth, trm, trmAxis, contentMask, @@ -1077,8 +1079,7 @@ public int Contacts(contactInfo_t[] contacts, final int maxContacts, final idVec return numContacts; } - public int Contents(final idVec3 start, - final idClipModel mdl, final idMat3 trmAxis, int contentMask, final idEntity passEntity) { + public int Contents(final idVec3 start, final idClipModel mdl, final idMat3 trmAxis, int contentMask, final idEntity passEntity) { int i, num, contents; idClipModel touch; idClipModel[] clipModelList = new idClipModel[MAX_GENTITIES]; @@ -1090,7 +1091,7 @@ public int Contents(final idVec3 start, if (null == passEntity || passEntity.entityNumber != ENTITYNUM_WORLD) { // test world this.numContents++; - contents = CollisionModel_local.collisionModelManager.Contents(start, trm, trmAxis, contentMask, 0, getVec3_origin(), getMat3_default()); + contents = collisionModelManager.Contents(start, trm, trmAxis, contentMask, 0, getVec3_origin(), getMat3_default()); } else { contents = 0; } @@ -1130,7 +1131,7 @@ public int Contents(final idVec3 start, } this.numContents++; - if (CollisionModel_local.collisionModelManager.Contents(start, trm, trmAxis, contentMask, touch.Handle(), touch.origin, touch.axis) != 0) { + if (collisionModelManager.Contents(start, trm, trmAxis, contentMask, touch.Handle(), touch.origin, touch.axis) != 0) { contents |= (touch.contents & contentMask); } } @@ -1155,28 +1156,28 @@ public void TranslationModel(trace_s[] results, final idVec3 start, final idVec3 final idClipModel mdl, final idMat3 trmAxis, int contentMask, int/*cmHandle_t*/ model, final idVec3 modelOrigin, final idMat3 modelAxis) { final idTraceModel trm = TraceModelForClipModel(mdl); this.numTranslations++; - CollisionModel_local.collisionModelManager.Translation(results, start, end, trm, trmAxis, contentMask, model, modelOrigin, modelAxis); + collisionModelManager.Translation(results, start, end, trm, trmAxis, contentMask, model, modelOrigin, modelAxis); } public void RotationModel(trace_s[] results, final idVec3 start, final idRotation rotation, final idClipModel mdl, final idMat3 trmAxis, int contentMask, int/*cmHandle_t*/ model, final idVec3 modelOrigin, final idMat3 modelAxis) { final idTraceModel trm = TraceModelForClipModel(mdl); this.numRotations++; - CollisionModel_local.collisionModelManager.Rotation(results, start, rotation, trm, trmAxis, contentMask, model, modelOrigin, modelAxis); + collisionModelManager.Rotation(results, start, rotation, trm, trmAxis, contentMask, model, modelOrigin, modelAxis); } public int ContactsModel(contactInfo_t[] contacts, final int maxContacts, final idVec3 start, final idVec6 dir, final float depth, final idClipModel mdl, final idMat3 trmAxis, int contentMask, int/*cmHandle_t*/ model, final idVec3 modelOrigin, final idMat3 modelAxis) { final idTraceModel trm = TraceModelForClipModel(mdl); this.numContacts++; - return CollisionModel_local.collisionModelManager.Contacts(contacts, maxContacts, start, dir, depth, trm, trmAxis, contentMask, model, modelOrigin, modelAxis); + return collisionModelManager.Contacts(contacts, maxContacts, start, dir, depth, trm, trmAxis, contentMask, model, modelOrigin, modelAxis); } public int ContentsModel(final idVec3 start, final idClipModel mdl, final idMat3 trmAxis, int contentMask, int/*cmHandle_t*/ model, final idVec3 modelOrigin, final idMat3 modelAxis) { final idTraceModel trm = TraceModelForClipModel(mdl); this.numContents++; - return CollisionModel_local.collisionModelManager.Contents(start, trm, trmAxis, contentMask, model, modelOrigin, modelAxis); + return collisionModelManager.Contents(start, trm, trmAxis, contentMask, model, modelOrigin, modelAxis); } // clip versus all entities but not the world @@ -1222,7 +1223,7 @@ public void TranslationEntities(trace_s results, final idVec3 start, final idVec TraceRenderModel(trace[0], start, end, radius, trmAxis, touch); } else { this.numTranslations++; - CollisionModel_local.collisionModelManager.Translation(trace, start, end, trm, trmAxis, contentMask, + collisionModelManager.Translation(trace, start, end, trm, trmAxis, contentMask, touch.Handle(), touch.origin, touch.axis); } @@ -1253,7 +1254,7 @@ public boolean GetModelContactFeature(final contactInfo_t contact, final idClipM winding.oPluSet(contact.point); return true; } else if (clipModel.traceModelIndex != -1) { - handle = CollisionModel_local.collisionModelManager.SetupTrmModel(idClipModel.GetCachedTraceModel(clipModel.traceModelIndex), clipModel.material); + handle = collisionModelManager.SetupTrmModel(idClipModel.GetCachedTraceModel(clipModel.traceModelIndex), clipModel.material); } else { handle = clipModel.collisionModelHandle; } @@ -1264,14 +1265,14 @@ public boolean GetModelContactFeature(final contactInfo_t contact, final idClipM switch (contact.type) { case CONTACT_EDGE: { // the model contact feature is a collision model edge - CollisionModel_local.collisionModelManager.GetModelEdge(handle, contact.modelFeature, start, end); + collisionModelManager.GetModelEdge(handle, contact.modelFeature, start, end); winding.oPluSet(start); winding.oPluSet(end); break; } case CONTACT_MODELVERTEX: { // the model contact feature is a collision model vertex - CollisionModel_local.collisionModelManager.GetModelVertex(handle, contact.modelFeature, start); + collisionModelManager.GetModelVertex(handle, contact.modelFeature, start); winding.oPluSet(start); break; } @@ -1378,7 +1379,7 @@ public void DrawClipModels(final idVec3 eye, final float radius, final idEntity if (clipModel.renderModelHandle != -1) { gameRenderWorld.DebugBounds(colorCyan, clipModel.GetAbsBounds()); } else { - CollisionModel_local.collisionModelManager.DrawModel(clipModel.Handle(), clipModel.GetOrigin(), clipModel.GetAxis(), eye, radius); + collisionModelManager.DrawModel(clipModel.Handle(), clipModel.GetOrigin(), clipModel.GetAxis(), eye, radius); } } } diff --git a/src/main/java/neo/Game/Physics/Physics_RigidBody.java b/src/main/java/neo/Game/Physics/Physics_RigidBody.java index 52806feb..622466b5 100644 --- a/src/main/java/neo/Game/Physics/Physics_RigidBody.java +++ b/src/main/java/neo/Game/Physics/Physics_RigidBody.java @@ -101,6 +101,9 @@ public static class rigidBodyIState_s { idVec3 linearMomentum; // translational momentum relative to center of mass idVec3 angularMomentum; // rotational momentum relative to center of mass + private static int DBG_counter = 0; + private final int DBG_count = DBG_counter++; + private rigidBodyIState_s() { position = new idVec3(); orientation = new idMat3(); @@ -457,8 +460,8 @@ public boolean Evaluate(int timeStepMSec, int endTimeMSec) { current.lastTimeStep = timeStep; if (hasMaster) { - oldOrigin = current.i.position; - oldAxis = current.i.orientation; + oldOrigin = new idVec3(current.i.position); + oldAxis = new idMat3(current.i.orientation); self.GetMasterPosition(masterOrigin, masterAxis); current.i.position.oSet(masterOrigin.oPlus(current.localOrigin.oMultiply(masterAxis))); if (isOrientated) { diff --git a/src/main/java/neo/Renderer/RenderSystem_init.java b/src/main/java/neo/Renderer/RenderSystem_init.java index 282a9818..e0ad7ca1 100644 --- a/src/main/java/neo/Renderer/RenderSystem_init.java +++ b/src/main/java/neo/Renderer/RenderSystem_init.java @@ -21,8 +21,6 @@ import neo.Renderer.MegaTexture.idMegaTexture; import static neo.Renderer.ModelManager.renderModelManager; import static neo.Renderer.RenderSystem.renderSystem; -import static neo.Renderer.RenderSystem_init.r_vidModes; -import static neo.Renderer.RenderSystem_init.s_numVidModes; import neo.Renderer.RenderWorld.R_ListRenderEntityDefs_f; import neo.Renderer.RenderWorld.R_ListRenderLightDefs_f; import neo.Renderer.RenderWorld.modelTrace_s; @@ -464,7 +462,7 @@ public class RenderSystem_init { r_showInteractionScissors = new idCVar("r_showInteractionScissors", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = show screen rectangle which contains the interaction frustum, 2 = also draw construction lines", 0, 2, new idCmdSystem.ArgCompletion_Integer(0, 2)); r_showLightCount = new idCVar("r_showLightCount", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = colors surfaces based on light count, 2 = also count everything through walls, 3 = also print overdraw", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); r_showViewEntitys = new idCVar("r_showViewEntitys", "1", CVAR_RENDERER | CVAR_INTEGER, "1 = displays the bounding boxes of all view models, 2 = print index numbers"); - r_showTris = new idCVar("r_showTris", "1", CVAR_RENDERER | CVAR_INTEGER, "enables wireframe rendering of the world, 1 = only draw visible ones, 2 = draw all front facing, 3 = draw all", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); + r_showTris = new idCVar("r_showTris", "3", CVAR_RENDERER | CVAR_INTEGER, "enables wireframe rendering of the world, 1 = only draw visible ones, 2 = draw all front facing, 3 = draw all", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); r_showSurfaceInfo = new idCVar("r_showSurfaceInfo", "0", CVAR_RENDERER | CVAR_BOOL, "show surface material name under crosshair"); r_showNormals = new idCVar("r_showNormals", "0", CVAR_RENDERER | CVAR_FLOAT, "draws wireframe normals"); r_showMemory = new idCVar("r_showMemory", "0", CVAR_RENDERER | CVAR_BOOL, "print frame memory utilization"); diff --git a/src/main/java/neo/Renderer/tr_main.java b/src/main/java/neo/Renderer/tr_main.java index b43cbcba..d764b847 100644 --- a/src/main/java/neo/Renderer/tr_main.java +++ b/src/main/java/neo/Renderer/tr_main.java @@ -996,14 +996,14 @@ public static class R_QsortSurfaces implements cmp_t { public int compare(drawSurf_s a, drawSurf_s b) { //this check assumes that the array contains nothing but nulls from this point. - if (null == a || null == b) { + if (null == a && null == b) { return 0; } - if (a.sort < b.sort) { + if (null == b || (null != a && a.sort < b.sort)) { return -1; } - if (a.sort > b.sort) { + if (null == a || (null != b && a.sort > b.sort)) { return 1; } return 0; diff --git a/src/main/java/neo/framework/UsercmdGen.java b/src/main/java/neo/framework/UsercmdGen.java index b9b87ed7..c532a112 100644 --- a/src/main/java/neo/framework/UsercmdGen.java +++ b/src/main/java/neo/framework/UsercmdGen.java @@ -1,27 +1,33 @@ package neo.framework; +import neo.TempDump.SERiAL; +import neo.framework.Async.AsyncNetwork.idAsyncNetwork; +import neo.framework.CVarSystem.idCVar; +import neo.framework.CmdSystem.idCmdSystem; +import neo.framework.KeyInput.idKeyInput; +import neo.idlib.Lib.idException; +import neo.idlib.Text.Str.idStr; +import neo.idlib.math.Math_h.idMath; +import neo.idlib.math.Vector.idVec3; +import org.lwjgl.input.Mouse; + import java.nio.ByteBuffer; import java.util.Arrays; -import static neo.TempDump.*; -import static neo.TempDump.SERIAL_SIZE; +import static neo.TempDump.TODO_Exception; import static neo.TempDump.btoi; import static neo.TempDump.etoi; - -import neo.TempDump; -import neo.TempDump.SERiAL; -import neo.framework.Async.AsyncNetwork.idAsyncNetwork; import static neo.framework.CVarSystem.CVAR_ARCHIVE; import static neo.framework.CVarSystem.CVAR_BOOL; import static neo.framework.CVarSystem.CVAR_FLOAT; import static neo.framework.CVarSystem.CVAR_INTEGER; import static neo.framework.CVarSystem.CVAR_SYSTEM; -import neo.framework.CVarSystem.idCVar; -import neo.framework.CmdSystem.idCmdSystem; import static neo.framework.Common.com_ticNumber; import static neo.framework.Common.common; import static neo.framework.KeyInput.K_LAST_KEY; -import neo.framework.KeyInput.idKeyInput; +import static neo.framework.KeyInput.K_MOUSE1; +import static neo.framework.KeyInput.K_MWHEELDOWN; +import static neo.framework.KeyInput.K_MWHEELUP; import static neo.framework.UsercmdGen.usercmdButton_t.UB_ATTACK; import static neo.framework.UsercmdGen.usercmdButton_t.UB_BACK; import static neo.framework.UsercmdGen.usercmdButton_t.UB_BUTTON0; @@ -115,22 +121,20 @@ import static neo.idlib.Lib.BIT; import static neo.idlib.Lib.LittleLong; import static neo.idlib.Lib.LittleShort; -import neo.idlib.Lib.idException; -import neo.idlib.Text.Str.idStr; import static neo.idlib.math.Angles.PITCH; import static neo.idlib.math.Angles.YAW; import static neo.idlib.math.Math_h.ANGLE2SHORT; -import neo.idlib.math.Math_h.idMath; -import neo.idlib.math.Vector.idVec3; import static neo.sys.sys_public.joystickAxis_t.AXIS_FORWARD; import static neo.sys.sys_public.joystickAxis_t.AXIS_SIDE; import static neo.sys.sys_public.joystickAxis_t.AXIS_UP; import static neo.sys.sys_public.joystickAxis_t.MAX_JOYSTICK_AXIS; +import static neo.sys.sys_public.sysEventType_t.SE_KEY; +import static neo.sys.sys_public.sysEventType_t.SE_MOUSE; import static neo.sys.win_input.Sys_EndKeyboardInputEvents; import static neo.sys.win_input.Sys_PollKeyboardInputEvents; import static neo.sys.win_input.Sys_ReturnKeyboardInputEvent; -import static neo.sys.win_input.Sys_ReturnMouseInputEvent; import static neo.sys.win_main.Sys_DebugPrintf; +import static neo.sys.win_main.Sys_QueEvent; /** * @@ -1160,52 +1164,56 @@ private void CmdButtons() { } private void Mouse() { - int i, numEvents; -// // numEvents = Sys_PollMouseInputEvents(); -// if (numEvents != 0) { // // Study each of the buffer elements and process them. // -// if (Mouse.next()) { -// sys_mEvents[] action = new sys_mEvents[1];; - int[] action = {0}; - int[] value = {0}; - Sys_ReturnMouseInputEvent(action, value); -// if (Sys_ReturnMouseInputEvent(action, value)) { -// if (action[0] >= etoi(M_ACTION1) && action[0] <= etoi(M_ACTION8)) { -// mouseButton = K_MOUSE1 + (action[0] - etoi(M_ACTION1)); -// mouseDown = (value[0] != 0); -// Key(mouseButton, mouseDown); -// } else { -// switch (sys_mEvents.values()[action[0]]) { -// case M_DELTAX: -// mouseDx += value[0]; -// continuousMouseX += value[0]; -// break; -// case M_DELTAY: -// mouseDy += value[0]; -// continuousMouseY += value[0]; -// break; -// case M_DELTAZ: -// int key = value[0] < 0 ? K_MWHEELDOWN : K_MWHEELUP; -// value[0] = Math.abs(value[0]); -// while (value[0]-- > 0) { -// Key(key, true); -// Key(key, false); -// mouseButton = key; -// mouseDown = true; -// } -// break; -// } -// } -// } -// } + final long dwTimeStamp = Mouse.getEventNanoseconds(); + while (Mouse.next()) { + final int x, y, w; + if ((x = Mouse.getDX()) != 0) { + mouseDx += x; + continuousMouseX += x; + Sys_QueEvent(dwTimeStamp, SE_MOUSE, x, 0, 0, null); + } + if ((y = -Mouse.getDY()) != 0) {//TODO:negative a la ogl? + mouseDy += y; + continuousMouseY += y; + Sys_QueEvent(dwTimeStamp, SE_MOUSE, 0, y, 0, null); + } + if ((w = Mouse.getDWheel()) != 0) { + // mouse wheel actions are impulses, without a specific up / down + int wheelValue = w;//(int) polled_didod[n].dwData ) / WHEEL_DELTA; + final int key = w < 0 ? K_MWHEELDOWN : K_MWHEELUP; + + while (wheelValue-- > 0) { + Key(key, true); + Key(key, false); + mouseButton = key; + mouseDown = true; + Sys_QueEvent(dwTimeStamp, SE_KEY, key, btoi(true), 0, null); + Sys_QueEvent(dwTimeStamp, SE_KEY, key, btoi(false), 0, null); + } + } + if (Mouse.getEventButtonState()) {//TODO:find out what Mouse.next() does exactly. + final int diaction = Mouse.getEventButton(); + final int button = Mouse.isButtonDown(diaction) ? 0x80 : 0;// (polled_didod[n].dwData & 0x80) == 0x80; + mouseButton = K_MOUSE1 + diaction; + mouseDown = (button != 0); + Key(mouseButton, mouseDown); + B1 = true; + Sys_QueEvent(dwTimeStamp, SE_KEY, mouseButton, button, 0, null); + } else if (B1) { + Sys_QueEvent(dwTimeStamp, SE_KEY, mouseButton, 0, 0, null); + B1 = false; + } + } // } // Sys_EndMouseInputEvents(); } + private static boolean B1 = false; private void Keyboard() { diff --git a/src/main/java/neo/sys/win_input.java b/src/main/java/neo/sys/win_input.java index 52ac954f..d426d346 100644 --- a/src/main/java/neo/sys/win_input.java +++ b/src/main/java/neo/sys/win_input.java @@ -1100,6 +1100,7 @@ public static int Sys_PollMouseInputEvents() { // return dwElements; } + @Deprecated public static void Sys_ReturnMouseInputEvent(int[] action, int[] value) { final long dwTimeStamp = Mouse.getEventNanoseconds(); diff --git a/src/main/java/neo/sys/win_main.java b/src/main/java/neo/sys/win_main.java index f8afcd29..7492eb0e 100644 --- a/src/main/java/neo/sys/win_main.java +++ b/src/main/java/neo/sys/win_main.java @@ -415,16 +415,7 @@ public static void Sys_Printf(final String fmt, Object... arg) { ============== */ public static void Sys_DebugPrintf(final String fmt, Object... arg) { - throw new TODO_Exception(); -// char msg[MAXPRINTMSG]; -// -// va_list argptr; -// va_start( argptr, fmt ); -// idStr::vsnPrintf( msg, MAXPRINTMSG-1, fmt, argptr ); -// msg[ sizeof(msg)-1 ] = '\0'; -// va_end( argptr ); -// -// OutputDebugString( msg ); + System.out.printf(fmt + '\n', arg); } /* From 5336c6e8ebf2ef880cd2b5c3cf6abbb69e5ef1a0 Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Fri, 29 Apr 2016 13:03:26 +0200 Subject: [PATCH 03/17] -added some deconstructors --- .gitignore | 4 + src/main/java/neo/Game/AI/AI.java | 2 +- src/main/java/neo/Game/Entity.java | 72 ++- src/main/java/neo/Game/GameEdit.java | 3 +- src/main/java/neo/Game/GameSys/SaveGame.java | 15 +- src/main/java/neo/Game/Game_local.java | 419 ++++++++---------- .../neo/Game/Physics/Physics_Monster.java | 3 +- src/main/java/neo/Game/Projectile.java | 22 +- src/main/java/neo/idlib/BitMsg.java | 12 +- .../java/neo/idlib/containers/LinkList.java | 3 - src/misc/bug_report_04.txt | 40 ++ 11 files changed, 331 insertions(+), 264 deletions(-) create mode 100644 src/misc/bug_report_04.txt diff --git a/.gitignore b/.gitignore index 9fc49938..7bfb5ee3 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,7 @@ crashlytics-build.properties # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +### NotepadPP template +# Notepad++ backups # +*.bak + diff --git a/src/main/java/neo/Game/AI/AI.java b/src/main/java/neo/Game/AI/AI.java index 75a48142..01887821 100644 --- a/src/main/java/neo/Game/AI/AI.java +++ b/src/main/java/neo/Game/AI/AI.java @@ -1326,7 +1326,7 @@ public void Spawn() { projectileVelocity = idProjectile.GetVelocity(projectileDef); projectileGravity = idProjectile.GetGravity(projectileDef); projectileSpeed = projectileVelocity.Length(); -// delete projectile.GetEntity(); + idEntity.delete(projectile.GetEntity()); projectile.oSet(null); } diff --git a/src/main/java/neo/Game/Entity.java b/src/main/java/neo/Game/Entity.java index 854568e3..de62c7e0 100644 --- a/src/main/java/neo/Game/Entity.java +++ b/src/main/java/neo/Game/Entity.java @@ -10,6 +10,7 @@ import neo.Game.Animation.Anim_Blend.idAnimator; import static neo.Game.Entity.signalNum_t.NUM_SIGNALS; import static neo.Game.Entity.signalNum_t.SIG_BLOCKED; +import static neo.Game.Entity.signalNum_t.SIG_REMOVED; import static neo.Game.Entity.signalNum_t.SIG_TOUCH; import static neo.Game.Entity.signalNum_t.SIG_TRIGGER; import neo.Game.FX.idEntityFx; @@ -22,9 +23,11 @@ import static neo.Game.GameSys.SysCvar.g_bloodEffects; import static neo.Game.GameSys.SysCvar.g_decals; import static neo.Game.Game_local.ENTITYNUM_NONE; +import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_DELETE_ENT; import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_EVENT; import static neo.Game.Game_local.GENTITYNUM_BITS; import static neo.Game.Game_local.MASK_SOLID; +import static neo.Game.Game_local.MAX_CLIENTS; import static neo.Game.Game_local.MAX_EVENT_PARAM_SIZE; import static neo.Game.Game_local.MAX_GAME_MESSAGE_SIZE; import static neo.Game.Game_local.MAX_GENTITIES; @@ -384,12 +387,14 @@ public ByteBuffer Write() { // private int mpGUIState; // local cache to avoid systematic SetStateInt // - // // + // + private static int DBG_counter = 0; + private final int DBG_count = DBG_counter++; // // public static final idTypeInfo Type; -// +// // public static idClass CreateInstance(); // // public abstract idTypeInfo GetType(); @@ -410,7 +415,7 @@ public idEntity() { snapshotNode.SetOwner(this); snapshotSequence = -1; snapshotBits = 0; - + name = new idStr(); spawnArgs = new idDict(); scriptObject = new idScriptObject(); @@ -444,7 +449,52 @@ public idEntity() { mpGUIState = -1; } -// // ~idEntity(); + + protected void _deconstructor() { + if (gameLocal.GameState() != GAMESTATE_SHUTDOWN && !gameLocal.isClient && fl.networkSync && entityNumber >= MAX_CLIENTS) { + idBitMsg msg = new idBitMsg(); + byte[] msgBuf = new byte[MAX_GAME_MESSAGE_SIZE]; + + msg.Init(msgBuf); + msg.WriteByte(GAME_RELIABLE_MESSAGE_DELETE_ENT); + msg.WriteBits(gameLocal.GetSpawnId(this), 32); + networkSystem.ServerSendReliableMessage(-1, msg); + } + + DeconstructScriptObject(); + scriptObject.Free(); + + if (thinkFlags != 0) { + BecomeInactive(thinkFlags); + } + activeNode.Remove(); + + Signal(SIG_REMOVED); + + // we have to set back the default physics object before unbinding because the entity + // specific physics object might be an entity variable and as such could already be destroyed. + SetPhysics(null); + + // remove any entities that are bound to me + RemoveBinds(); + + // unbind from master + Unbind(); + QuitTeam(); + + gameLocal.RemoveEntityFromHash(name.toString(), this); + +// delete renderView; + renderView = null; + +// delete signals; + signals = null; + + FreeModelDef(); + FreeSoundEmitter(false); + + gameLocal.UnregisterEntity(this); + } @Override public void Spawn() { @@ -806,7 +856,7 @@ public renderView_s GetRenderView() { /* ********************************************************************** Thinking - + ***********************************************************************/ // thinking public void Think() { @@ -930,7 +980,7 @@ public void UpdatePVSAreas(final idVec3 pos) { /* ********************************************************************** Visuals - + ***********************************************************************/ // visuals /* @@ -1283,7 +1333,7 @@ public idAnimator GetAnimator() { // returns animator object used by this ent /* ********************************************************************** Sound - + ***********************************************************************/ // sound /* @@ -1451,7 +1501,7 @@ public void FreeSoundEmitter(boolean immediate) { /* ********************************************************************** entity binding - + ***********************************************************************/ // entity binding public void PreBind() { @@ -1527,7 +1577,7 @@ public void JoinTeam(idEntity teammember) { teamMaster = master; - // reorder the active entity list + // reorder the active entity list gameLocal.sortTeamMasters = true; } @@ -4070,6 +4120,10 @@ private void Event_SetNeverDormant(int enable) { fl.neverDormant = (enable != 0); dormantStart = 0; } + + public static void delete(final idEntity entity){ + entity._deconstructor(); + } } /* diff --git a/src/main/java/neo/Game/GameEdit.java b/src/main/java/neo/Game/GameEdit.java index d1d5e375..5d379d61 100644 --- a/src/main/java/neo/Game/GameEdit.java +++ b/src/main/java/neo/Game/GameEdit.java @@ -402,6 +402,7 @@ public static class idEditEntities { public idEditEntities() { selectableEntityClasses = new idList<>(); + selectedEntities = new idList<>(); nextSelectTime = 0; } @@ -445,7 +446,7 @@ public void AddSelectedEntity(idEntity ent) { } public void RemoveSelectedEntity(idEntity ent) { - if (selectedEntities.Find(ent) != 0) { + if (selectedEntities.Find(ent) != Integer.valueOf(0)) { selectedEntities.Remove(ent); } } diff --git a/src/main/java/neo/Game/GameSys/SaveGame.java b/src/main/java/neo/Game/GameSys/SaveGame.java index 407c3421..ba00fc87 100644 --- a/src/main/java/neo/Game/GameSys/SaveGame.java +++ b/src/main/java/neo/Game/GameSys/SaveGame.java @@ -835,13 +835,14 @@ public void ReadAngles(idAngles angles) { } public void ReadObject(idClass obj) { - int[] index = {0}; - - ReadInt(index); - if ((index[0] < 0) || (index[0] >= objects.Num())) { - Error("idRestoreGame::ReadObject: invalid object index"); - } - obj.oSet(objects.oGet(index[0])); + throw new TODO_Exception();//TODO:remove the parameter, and return obj instead +// int[] index = {0}; +// +// ReadInt(index); +// if ((index[0] < 0) || (index[0] >= objects.Num())) { +// Error("idRestoreGame::ReadObject: invalid object index"); +// } +// obj.oSet(objects.oGet(index[0])); } public void ReadStaticObject(idClass obj) { diff --git a/src/main/java/neo/Game/Game_local.java b/src/main/java/neo/Game/Game_local.java index c833251d..e503759a 100644 --- a/src/main/java/neo/Game/Game_local.java +++ b/src/main/java/neo/Game/Game_local.java @@ -1,22 +1,10 @@ package neo.Game; -import static java.lang.Math.abs; -import static java.lang.Math.atan2; -import static java.lang.Math.cos; -import static java.lang.Math.sin; -import static java.lang.Math.tan; -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.stream.Stream; - import neo.CM.CollisionModel.trace_s; import neo.CM.CollisionModel_local; import neo.Game.AFEntity.idAFAttachment; import neo.Game.AFEntity.idAFEntity_Generic; import neo.Game.AI.AAS.idAAS; -import static neo.Game.AI.AI.SE_BLOCKED; -import static neo.Game.AI.AI.SE_ENTER_LEDGE_AREA; -import static neo.Game.AI.AI.SE_ENTER_OBSTACLE; import neo.Game.AI.AI.idAI; import neo.Game.AI.AI.idCombatNode; import neo.Game.AI.AI.obstaclePath_s; @@ -29,26 +17,15 @@ import neo.Game.Camera.idCamera; import neo.Game.Camera.idCameraAnim; import neo.Game.Camera.idCameraView; -import static neo.Game.Entity.TH_PHYSICS; import neo.Game.Entity.idEntity; import neo.Game.FX.idEntityFx; -import static neo.Game.Game.GAME_API_VERSION; -import static neo.Game.Game.SCRIPT_DEFAULT; -import static neo.Game.Game.SCRIPT_DEFAULTFUNC; import neo.Game.Game.allowReply_t; -import static neo.Game.Game.allowReply_t.ALLOW_BADPASS; -import static neo.Game.Game.allowReply_t.ALLOW_NOTYET; -import static neo.Game.Game.allowReply_t.ALLOW_YES; import neo.Game.Game.escReply_t; -import static neo.Game.Game.escReply_t.ESC_GUI; -import static neo.Game.Game.escReply_t.ESC_IGNORE; -import static neo.Game.Game.escReply_t.ESC_MAIN; import neo.Game.Game.gameExport_t; import neo.Game.Game.gameImport_t; import neo.Game.Game.gameReturn_t; import neo.Game.Game.idGame; import neo.Game.GameEdit.idEditEntities; -import static neo.Game.GameSys.Class.EV_Remove; import neo.Game.GameSys.Class.idAllocError; import neo.Game.GameSys.Class.idClass; import neo.Game.GameSys.Class.idTypeInfo; @@ -118,106 +95,10 @@ import neo.Game.GameSys.SysCmds.Cmd_Trigger_f; import neo.Game.GameSys.SysCmds.Cmd_UnbindRagdoll_f; import neo.Game.GameSys.SysCmds.Cmd_WeaponSplat_f; -import static neo.Game.GameSys.SysCmds.D_DrawDebugLines; -import static neo.Game.GameSys.SysCvar.__DATE__; -import static neo.Game.GameSys.SysCvar.aas_test; -import static neo.Game.GameSys.SysCvar.ai_showCombatNodes; -import static neo.Game.GameSys.SysCvar.ai_showObstacleAvoidance; -import static neo.Game.GameSys.SysCvar.ai_showPaths; -import static neo.Game.GameSys.SysCvar.ai_testPredictPath; -import static neo.Game.GameSys.SysCvar.developer; -import static neo.Game.GameSys.SysCvar.g_bloodEffects; -import static neo.Game.GameSys.SysCvar.g_cinematic; -import static neo.Game.GameSys.SysCvar.g_cinematicMaxSkipTime; -import static neo.Game.GameSys.SysCvar.g_decals; -import static neo.Game.GameSys.SysCvar.g_editEntityMode; -import static neo.Game.GameSys.SysCvar.g_flushSave; -import static neo.Game.GameSys.SysCvar.g_frametime; -import static neo.Game.GameSys.SysCvar.g_gravity; -import static neo.Game.GameSys.SysCvar.g_mapCycle; -import static neo.Game.GameSys.SysCvar.g_maxShowDistance; -import static neo.Game.GameSys.SysCvar.g_showActiveEntities; -import static neo.Game.GameSys.SysCvar.g_showCollisionModels; -import static neo.Game.GameSys.SysCvar.g_showCollisionTraces; -import static neo.Game.GameSys.SysCvar.g_showCollisionWorld; -import static neo.Game.GameSys.SysCvar.g_showEntityInfo; -import static neo.Game.GameSys.SysCvar.g_showPVS; -import static neo.Game.GameSys.SysCvar.g_showTargets; -import static neo.Game.GameSys.SysCvar.g_skill; -import static neo.Game.GameSys.SysCvar.g_stopTime; -import static neo.Game.GameSys.SysCvar.g_timeentities; -import static neo.Game.GameSys.SysCvar.pm_thirdPerson; -import static neo.Game.GameSys.SysCvar.r_aspectRatio; import neo.Game.GameSys.TypeInfo.ListTypeInfo_f; import neo.Game.GameSys.TypeInfo.TestSaveGame_f; import neo.Game.GameSys.TypeInfo.WriteGameState_f; -import static neo.Game.Game_local.ASYNC_WRITE_PVS; -import static neo.Game.Game_local.CINEMATIC_SKIP_DELAY; -import static neo.Game.Game_local.DEFAULT_GRAVITY; -import static neo.Game.Game_local.ENTITYNUM_MAX_NORMAL; -import static neo.Game.Game_local.ENTITYNUM_NONE; -import static neo.Game.Game_local.ENTITYNUM_WORLD; -import static neo.Game.Game_local.ENTITY_PVS_SIZE; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_CALLVOTE; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_CASTVOTE; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_CHAT; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_DB; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_DELETE_ENT; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_DROPWEAPON; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_EVENT; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_INIT_DECL_REMAP; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_KILL; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_PORTAL; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_PORTALSTATES; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_REMAP_DECL; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_RESTART; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_SERVERINFO; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_SOUND_EVENT; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_SOUND_INDEX; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_SPAWN_PLAYER; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_STARTSTATE; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_STARTVOTE; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_TCHAT; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_TOURNEYLINE; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_UPDATEVOTE; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_VCHAT; -import static neo.Game.Game_local.GAME_RELIABLE_MESSAGE_WARMUPTIME; -import static neo.Game.Game_local.GAME_VERSION; -import static neo.Game.Game_local.GENTITYNUM_BITS; -import static neo.Game.Game_local.LAGO_HEIGHT; -import static neo.Game.Game_local.LAGO_IMG_HEIGHT; -import static neo.Game.Game_local.LAGO_IMG_WIDTH; -import static neo.Game.Game_local.LAGO_WIDTH; -import static neo.Game.Game_local.MAX_CLIENTS; -import static neo.Game.Game_local.MAX_ENTITY_STATE_SIZE; -import static neo.Game.Game_local.MAX_EVENT_PARAM_SIZE; -import static neo.Game.Game_local.MAX_GAME_MESSAGE_SIZE; -import static neo.Game.Game_local.MAX_GENTITIES; -import static neo.Game.Game_local.NUM_RENDER_PORTAL_BITS; -import static neo.Game.Game_local.animationLib; -import neo.Game.Game_local.entityNetEvent_s; -import neo.Game.Game_local.entityState_s; -import static neo.Game.Game_local.gameLocal; -import static neo.Game.Game_local.gameRenderWorld; -import static neo.Game.Game_local.gameSoundWorld; -import neo.Game.Game_local.gameState_t; -import static neo.Game.Game_local.gameState_t.GAMESTATE_ACTIVE; -import static neo.Game.Game_local.gameState_t.GAMESTATE_NOMAP; -import static neo.Game.Game_local.gameState_t.GAMESTATE_SHUTDOWN; -import static neo.Game.Game_local.gameState_t.GAMESTATE_STARTUP; -import static neo.Game.Game_local.gameState_t.GAMESTATE_UNINITIALIZED; -import neo.Game.Game_local.idEntityPtr; -import neo.Game.Game_local.idGameLocal; -import neo.Game.Game_local.snapshot_s; -import neo.Game.Game_local.spawnSpot_t; -import static neo.Game.Game_network.ASYNC_WRITE_TAGS; import neo.Game.Game_network.idEventQueue; -import static neo.Game.Game_network.idEventQueue.outOfOrderBehaviour_t.OUTOFORDER_DROP; -import static neo.Game.Game_network.idEventQueue.outOfOrderBehaviour_t.OUTOFORDER_IGNORE; -import static neo.Game.Game_network.net_clientMaxPrediction; -import static neo.Game.Game_network.net_clientShowSnapshot; -import static neo.Game.Game_network.net_clientShowSnapshotRadius; -import static neo.Game.Game_network.net_clientSmoothing; import neo.Game.Item.idItem; import neo.Game.Item.idMoveablePDAItem; import neo.Game.Item.idObjective; @@ -237,14 +118,8 @@ import neo.Game.Mover.idMover; import neo.Game.Mover.idSplinePath; import neo.Game.MultiplayerGame.gameType_t; -import static neo.Game.MultiplayerGame.gameType_t.GAME_DM; -import static neo.Game.MultiplayerGame.gameType_t.GAME_LASTMAN; -import static neo.Game.MultiplayerGame.gameType_t.GAME_SP; -import static neo.Game.MultiplayerGame.gameType_t.GAME_TDM; -import static neo.Game.MultiplayerGame.gameType_t.GAME_TOURNEY; import neo.Game.MultiplayerGame.idMultiplayerGame; import neo.Game.MultiplayerGame.snd_evt_t; -import static neo.Game.MultiplayerGame.snd_evt_t.SND_COUNT; import neo.Game.Physics.Clip.idClip; import neo.Game.Physics.Clip.idClipModel; import neo.Game.Physics.Force.idForce; @@ -258,9 +133,6 @@ import neo.Game.Pvs.idPVS; import neo.Game.Pvs.pvsHandle_t; import neo.Game.Pvs.pvsType_t; -import static neo.Game.Pvs.pvsType_t.PVS_ALL_PORTALS_OPEN; -import static neo.Game.Pvs.pvsType_t.PVS_CONNECTED_AREAS; -import static neo.Game.Pvs.pvsType_t.PVS_NORMAL; import neo.Game.Script.Script_Program.function_t; import neo.Game.Script.Script_Thread.idThread; import neo.Game.Script.idProgram; @@ -280,6 +152,140 @@ import neo.Game.Trigger.idTrigger_Hurt; import neo.Game.Trigger.idTrigger_Multi; import neo.Game.WorldSpawn.idWorldspawn; +import neo.Renderer.Material.idMaterial; +import neo.Renderer.ModelManager; +import neo.Renderer.RenderSystem; +import neo.Renderer.RenderWorld.idRenderWorld; +import neo.Renderer.RenderWorld.modelTrace_s; +import neo.Renderer.RenderWorld.renderView_s; +import neo.Sound.snd_shader.idSoundShader; +import neo.Sound.snd_shader.soundShaderParms_t; +import neo.Sound.snd_system; +import neo.Sound.sound.idSoundWorld; +import neo.TempDump.void_callback; +import neo.framework.Async.NetworkSystem; +import neo.framework.CVarSystem; +import neo.framework.CVarSystem.idCVar; +import neo.framework.CmdSystem; +import neo.framework.CmdSystem.argCompletion_t; +import neo.framework.CmdSystem.cmdFunction_t; +import neo.framework.CmdSystem.idCmdSystem; +import neo.framework.Common; +import neo.framework.DeclEntityDef.idDeclEntityDef; +import neo.framework.DeclManager; +import neo.framework.DeclManager.declType_t; +import neo.framework.DeclManager.idDecl; +import neo.framework.DeclManager.idListDecls_f; +import neo.framework.DeclManager.idPrintDecls_f; +import neo.framework.FileSystem_h; +import neo.framework.File_h.idFile; +import neo.framework.UsercmdGen.usercmd_t; +import neo.idlib.BV.Bounds.idBounds; +import neo.idlib.BitMsg.idBitMsg; +import neo.idlib.BitMsg.idBitMsgDelta; +import neo.idlib.CmdArgs.idCmdArgs; +import neo.idlib.Dict_h.idDict; +import neo.idlib.Dict_h.idKeyValue; +import neo.idlib.Lib.idException; +import neo.idlib.Lib.idLib; +import neo.idlib.MapFile.idMapEntity; +import neo.idlib.MapFile.idMapFile; +import neo.idlib.Text.Str.idStr; +import neo.idlib.Timer.idTimer; +import neo.idlib.containers.HashIndex.idHashIndex; +import neo.idlib.containers.LinkList.idLinkList; +import neo.idlib.containers.List.cmp_t; +import neo.idlib.containers.List.idList; +import neo.idlib.containers.StaticList.idStaticList; +import neo.idlib.containers.StrList.idStrList; +import neo.idlib.geometry.TraceModel.idTraceModel; +import neo.idlib.geometry.TraceModel.traceModelPoly_t; +import neo.idlib.geometry.Winding.idFixedWinding; +import neo.idlib.math.Math_h.idMath; +import neo.idlib.math.Matrix.idMat3; +import neo.idlib.math.Random.idRandom; +import neo.idlib.math.Simd.idSIMD; +import neo.idlib.math.Vector.idVec2; +import neo.idlib.math.Vector.idVec3; +import neo.idlib.math.Vector.idVec5; +import neo.sys.sys_public; +import neo.ui.UserInterface; +import neo.ui.UserInterface.idUserInterface; + +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.stream.Stream; + +import static java.lang.Math.abs; +import static java.lang.Math.atan2; +import static java.lang.Math.cos; +import static java.lang.Math.sin; +import static java.lang.Math.tan; +import static neo.Game.AI.AI.SE_BLOCKED; +import static neo.Game.AI.AI.SE_ENTER_LEDGE_AREA; +import static neo.Game.AI.AI.SE_ENTER_OBSTACLE; +import static neo.Game.Entity.TH_PHYSICS; +import static neo.Game.Game.GAME_API_VERSION; +import static neo.Game.Game.SCRIPT_DEFAULT; +import static neo.Game.Game.SCRIPT_DEFAULTFUNC; +import static neo.Game.Game.allowReply_t.ALLOW_BADPASS; +import static neo.Game.Game.allowReply_t.ALLOW_NOTYET; +import static neo.Game.Game.allowReply_t.ALLOW_YES; +import static neo.Game.Game.escReply_t.ESC_GUI; +import static neo.Game.Game.escReply_t.ESC_IGNORE; +import static neo.Game.Game.escReply_t.ESC_MAIN; +import static neo.Game.GameSys.Class.EV_Remove; +import static neo.Game.GameSys.SysCmds.D_DrawDebugLines; +import static neo.Game.GameSys.SysCvar.__DATE__; +import static neo.Game.GameSys.SysCvar.aas_test; +import static neo.Game.GameSys.SysCvar.ai_showCombatNodes; +import static neo.Game.GameSys.SysCvar.ai_showObstacleAvoidance; +import static neo.Game.GameSys.SysCvar.ai_showPaths; +import static neo.Game.GameSys.SysCvar.ai_testPredictPath; +import static neo.Game.GameSys.SysCvar.developer; +import static neo.Game.GameSys.SysCvar.g_bloodEffects; +import static neo.Game.GameSys.SysCvar.g_cinematic; +import static neo.Game.GameSys.SysCvar.g_cinematicMaxSkipTime; +import static neo.Game.GameSys.SysCvar.g_decals; +import static neo.Game.GameSys.SysCvar.g_editEntityMode; +import static neo.Game.GameSys.SysCvar.g_flushSave; +import static neo.Game.GameSys.SysCvar.g_frametime; +import static neo.Game.GameSys.SysCvar.g_gravity; +import static neo.Game.GameSys.SysCvar.g_mapCycle; +import static neo.Game.GameSys.SysCvar.g_maxShowDistance; +import static neo.Game.GameSys.SysCvar.g_showActiveEntities; +import static neo.Game.GameSys.SysCvar.g_showCollisionModels; +import static neo.Game.GameSys.SysCvar.g_showCollisionTraces; +import static neo.Game.GameSys.SysCvar.g_showCollisionWorld; +import static neo.Game.GameSys.SysCvar.g_showEntityInfo; +import static neo.Game.GameSys.SysCvar.g_showPVS; +import static neo.Game.GameSys.SysCvar.g_showTargets; +import static neo.Game.GameSys.SysCvar.g_skill; +import static neo.Game.GameSys.SysCvar.g_stopTime; +import static neo.Game.GameSys.SysCvar.g_timeentities; +import static neo.Game.GameSys.SysCvar.pm_thirdPerson; +import static neo.Game.GameSys.SysCvar.r_aspectRatio; +import static neo.Game.Game_local.gameState_t.GAMESTATE_ACTIVE; +import static neo.Game.Game_local.gameState_t.GAMESTATE_NOMAP; +import static neo.Game.Game_local.gameState_t.GAMESTATE_SHUTDOWN; +import static neo.Game.Game_local.gameState_t.GAMESTATE_STARTUP; +import static neo.Game.Game_local.gameState_t.GAMESTATE_UNINITIALIZED; +import static neo.Game.Game_network.ASYNC_WRITE_TAGS; +import static neo.Game.Game_network.idEventQueue.outOfOrderBehaviour_t.OUTOFORDER_DROP; +import static neo.Game.Game_network.idEventQueue.outOfOrderBehaviour_t.OUTOFORDER_IGNORE; +import static neo.Game.Game_network.net_clientMaxPrediction; +import static neo.Game.Game_network.net_clientShowSnapshot; +import static neo.Game.Game_network.net_clientShowSnapshotRadius; +import static neo.Game.Game_network.net_clientSmoothing; +import static neo.Game.MultiplayerGame.gameType_t.GAME_DM; +import static neo.Game.MultiplayerGame.gameType_t.GAME_LASTMAN; +import static neo.Game.MultiplayerGame.gameType_t.GAME_SP; +import static neo.Game.MultiplayerGame.gameType_t.GAME_TDM; +import static neo.Game.MultiplayerGame.gameType_t.GAME_TOURNEY; +import static neo.Game.MultiplayerGame.snd_evt_t.SND_COUNT; +import static neo.Game.Pvs.pvsType_t.PVS_ALL_PORTALS_OPEN; +import static neo.Game.Pvs.pvsType_t.PVS_CONNECTED_AREAS; +import static neo.Game.Pvs.pvsType_t.PVS_NORMAL; import static neo.Renderer.Material.CONTENTS_BODY; import static neo.Renderer.Material.CONTENTS_MONSTERCLIP; import static neo.Renderer.Material.CONTENTS_OPAQUE; @@ -289,58 +295,36 @@ import static neo.Renderer.Material.CONTENTS_TRIGGER; import static neo.Renderer.Material.CONTENTS_WATER; import static neo.Renderer.Material.MAX_SURFACE_TYPES; -import neo.Renderer.Material.idMaterial; import static neo.Renderer.Model.INVALID_JOINT; -import neo.Renderer.ModelManager; import static neo.Renderer.ModelManager.renderModelManager; -import neo.Renderer.RenderSystem; import static neo.Renderer.RenderSystem.renderSystem; import static neo.Renderer.RenderWorld.MAX_GLOBAL_SHADER_PARMS; -import neo.Renderer.RenderWorld.idRenderWorld; -import neo.Renderer.RenderWorld.modelTrace_s; import static neo.Renderer.RenderWorld.portalConnection_t.PS_BLOCK_ALL; import static neo.Renderer.RenderWorld.portalConnection_t.PS_BLOCK_LOCATION; -import neo.Renderer.RenderWorld.renderView_s; -import neo.Sound.snd_shader.idSoundShader; -import neo.Sound.snd_shader.soundShaderParms_t; -import neo.Sound.snd_system; -import neo.Sound.sound.idSoundWorld; import static neo.TempDump.NOT; import static neo.TempDump.atoi; import static neo.TempDump.ctos; import static neo.TempDump.etoi; import static neo.TempDump.isNotNullOrEmpty; -import neo.TempDump.void_callback; import static neo.Tools.Compilers.AAS.AASFileManager.AASFileManager; -import neo.framework.Async.NetworkSystem; import static neo.framework.Async.NetworkSystem.networkSystem; import static neo.framework.BuildDefines.ID_DEMO_BUILD; import static neo.framework.BuildDefines._DEBUG; import static neo.framework.BuildVersion.BUILD_NUMBER; -import neo.framework.CVarSystem; import static neo.framework.CVarSystem.CVAR_BOOL; import static neo.framework.CVarSystem.CVAR_GAME; import static neo.framework.CVarSystem.CVAR_SERVERINFO; import static neo.framework.CVarSystem.CVAR_SYSTEM; import static neo.framework.CVarSystem.cvarSystem; -import neo.framework.CVarSystem.idCVar; -import neo.framework.CmdSystem; import static neo.framework.CmdSystem.CMD_FL_CHEAT; import static neo.framework.CmdSystem.CMD_FL_GAME; import static neo.framework.CmdSystem.CMD_FL_SYSTEM; -import neo.framework.CmdSystem.argCompletion_t; import static neo.framework.CmdSystem.cmdExecution_t.CMD_EXEC_APPEND; import static neo.framework.CmdSystem.cmdExecution_t.CMD_EXEC_NOW; -import neo.framework.CmdSystem.cmdFunction_t; import static neo.framework.CmdSystem.cmdSystem; -import neo.framework.CmdSystem.idCmdSystem; -import neo.framework.Common; import static neo.framework.Common.common; -import neo.framework.DeclEntityDef.idDeclEntityDef; -import neo.framework.DeclManager; import static neo.framework.DeclManager.declManager; import static neo.framework.DeclManager.declState_t.DS_DEFAULTED; -import neo.framework.DeclManager.declType_t; import static neo.framework.DeclManager.declType_t.DECL_AF; import static neo.framework.DeclManager.declType_t.DECL_AUDIO; import static neo.framework.DeclManager.declType_t.DECL_ENTITYDEF; @@ -354,21 +338,9 @@ import static neo.framework.DeclManager.declType_t.DECL_SKIN; import static neo.framework.DeclManager.declType_t.DECL_SOUND; import static neo.framework.DeclManager.declType_t.DECL_VIDEO; -import neo.framework.DeclManager.idDecl; import static neo.framework.DeclManager.idDeclAllocator; -import neo.framework.DeclManager.idListDecls_f; -import neo.framework.DeclManager.idPrintDecls_f; -import neo.framework.FileSystem_h; import static neo.framework.FileSystem_h.fileSystem; -import neo.framework.File_h.idFile; import static neo.framework.UsercmdGen.USERCMD_MSEC; -import neo.framework.UsercmdGen.usercmd_t; -import neo.idlib.BV.Bounds.idBounds; -import neo.idlib.BitMsg.idBitMsg; -import neo.idlib.BitMsg.idBitMsgDelta; -import neo.idlib.CmdArgs.idCmdArgs; -import neo.idlib.Dict_h.idDict; -import neo.idlib.Dict_h.idKeyValue; import static neo.idlib.Heap.Mem_EnableLeakTest; import static neo.idlib.Lib.LittleRevBytes; import static neo.idlib.Lib.MAX_STRING_CHARS; @@ -381,38 +353,13 @@ import static neo.idlib.Lib.colorOrange; import static neo.idlib.Lib.colorWhite; import static neo.idlib.Lib.colorYellow; -import neo.idlib.Lib.idException; -import neo.idlib.Lib.idLib; -import neo.idlib.MapFile.idMapEntity; -import neo.idlib.MapFile.idMapFile; -import neo.idlib.Text.Str.idStr; import static neo.idlib.Text.Str.va; -import neo.idlib.Timer.idTimer; -import neo.idlib.containers.HashIndex.idHashIndex; -import neo.idlib.containers.LinkList.idLinkList; -import neo.idlib.containers.List.cmp_t; -import neo.idlib.containers.List.idList; -import neo.idlib.containers.StaticList.idStaticList; -import neo.idlib.containers.StrList.idStrList; -import neo.idlib.geometry.TraceModel.idTraceModel; -import neo.idlib.geometry.TraceModel.traceModelPoly_t; -import neo.idlib.geometry.Winding.idFixedWinding; import static neo.idlib.math.Math_h.DEG2RAD; import static neo.idlib.math.Math_h.INTSIGNBITSET; import static neo.idlib.math.Math_h.SEC2MS; -import neo.idlib.math.Math_h.idMath; -import neo.idlib.math.Matrix.idMat3; import static neo.idlib.math.Matrix.idMat3.getMat3_identity; -import neo.idlib.math.Random.idRandom; -import neo.idlib.math.Simd.idSIMD; import static neo.idlib.math.Vector.getVec3_origin; -import neo.idlib.math.Vector.idVec2; -import neo.idlib.math.Vector.idVec3; -import neo.idlib.math.Vector.idVec5; -import neo.sys.sys_public; import static neo.sys.sys_public.sys; -import neo.ui.UserInterface; -import neo.ui.UserInterface.idUserInterface; import static neo.ui.UserInterface.uiManager; /** @@ -424,7 +371,7 @@ public class Game_local { // the rest of the engine will only reference the "game" variable, while all local aspects stay hidden public static final idGameLocal gameLocal = new idGameLocal();//TODO:these globals should either be collected to a single file, or always be set at the top. - public static final idGame game = gameLocal;// statically pointed at an idGameLocal + public static final idGame game = gameLocal;// statically pointed at an idGameLocal /* =============================================================================== @@ -433,12 +380,12 @@ public class Game_local { =============================================================================== */ - public static final int LAGO_IMG_WIDTH = 64; - public static final int LAGO_IMG_HEIGHT = 64; - public static final int LAGO_WIDTH = 64; - public static final int LAGO_HEIGHT = 44; - public static final String LAGO_MATERIAL = "textures/sfx/lagometer"; - public static final String LAGO_IMAGE = "textures/sfx/lagometer.tga"; + public static final int LAGO_IMG_WIDTH = 64; + public static final int LAGO_IMG_HEIGHT = 64; + public static final int LAGO_WIDTH = 64; + public static final int LAGO_HEIGHT = 44; + public static final String LAGO_MATERIAL = "textures/sfx/lagometer"; + public static final String LAGO_IMAGE = "textures/sfx/lagometer.tga"; // // if set to 1 the server sends the client PVS with snapshots and the client compares against what it sees //#ifndef ASYNC_WRITE_PVS @@ -453,26 +400,26 @@ public class Game_local { public static idRenderWorld gameRenderWorld; public static idSoundWorld gameSoundWorld; // - private static gameExport_t gameExport = new gameExport_t(); -// + private static gameExport_t gameExport = new gameExport_t(); + // // the "gameversion" client command will print this plus compile date - public static final String GAME_VERSION = "baseDOOM-1"; -// - public static final int MAX_CLIENTS = 32; - public static final int GENTITYNUM_BITS = 12; -// - public static final int MAX_GENTITIES = 1 << GENTITYNUM_BITS; - public static final int ENTITYNUM_NONE = MAX_GENTITIES - 1; - public static final int ENTITYNUM_WORLD = MAX_GENTITIES - 2; - public static final int ENTITYNUM_MAX_NORMAL = MAX_GENTITIES - 2; + public static final String GAME_VERSION = "baseDOOM-1"; + // + public static final int MAX_CLIENTS = 32; + public static final int GENTITYNUM_BITS = 12; + // + public static final int MAX_GENTITIES = 1 << GENTITYNUM_BITS; + public static final int ENTITYNUM_NONE = MAX_GENTITIES - 1; + public static final int ENTITYNUM_WORLD = MAX_GENTITIES - 2; + public static final int ENTITYNUM_MAX_NORMAL = MAX_GENTITIES - 2; //============================================================================ //============================================================================ - public static final int MAX_GAME_MESSAGE_SIZE = 8192; - public static final int MAX_ENTITY_STATE_SIZE = 512; - public static final int ENTITY_PVS_SIZE = ((MAX_GENTITIES + 31) >> 5); - public static final int NUM_RENDER_PORTAL_BITS = idMath.BitsForInteger(etoi(PS_BLOCK_ALL)); + public static final int MAX_GAME_MESSAGE_SIZE = 8192; + public static final int MAX_ENTITY_STATE_SIZE = 512; + public static final int ENTITY_PVS_SIZE = ((MAX_GENTITIES + 31) >> 5); + public static final int NUM_RENDER_PORTAL_BITS = idMath.BitsForInteger(etoi(PS_BLOCK_ALL)); // - static final idCVar com_forceGenericSIMD = new idCVar("com_forceGenericSIMD", "0", CVAR_BOOL | CVAR_SYSTEM, "force generic platform independent SIMD"); + static final idCVar com_forceGenericSIMD = new idCVar("com_forceGenericSIMD", "0", CVAR_BOOL | CVAR_SYSTEM, "force generic platform independent SIMD"); /* =============================================================================== @@ -481,7 +428,7 @@ public class Game_local { */ public static class entityState_s { - int entityNumber; + int entityNumber; idBitMsg state; ByteBuffer stateBuf = ByteBuffer.allocate(MAX_ENTITY_STATE_SIZE); entityState_s next; @@ -489,7 +436,7 @@ public static class entityState_s { public static class snapshot_s { - int sequence; + int sequence; entityState_s firstEntityState; int[] pvs = new int[ENTITY_PVS_SIZE]; snapshot_s next; @@ -508,30 +455,30 @@ public static class entityNetEvent_s { }; // enum { public static final int GAME_RELIABLE_MESSAGE_INIT_DECL_REMAP = 0; - public static final int GAME_RELIABLE_MESSAGE_REMAP_DECL = 1; - public static final int GAME_RELIABLE_MESSAGE_SPAWN_PLAYER = 2; - public static final int GAME_RELIABLE_MESSAGE_DELETE_ENT = 3; - public static final int GAME_RELIABLE_MESSAGE_CHAT = 4; - public static final int GAME_RELIABLE_MESSAGE_TCHAT = 5; - public static final int GAME_RELIABLE_MESSAGE_SOUND_EVENT = 6; - public static final int GAME_RELIABLE_MESSAGE_SOUND_INDEX = 7; - public static final int GAME_RELIABLE_MESSAGE_DB = 8; - public static final int GAME_RELIABLE_MESSAGE_KILL = 9; - public static final int GAME_RELIABLE_MESSAGE_DROPWEAPON = 10; - public static final int GAME_RELIABLE_MESSAGE_RESTART = 11; - public static final int GAME_RELIABLE_MESSAGE_SERVERINFO = 12; - public static final int GAME_RELIABLE_MESSAGE_TOURNEYLINE = 13; - public static final int GAME_RELIABLE_MESSAGE_CALLVOTE = 14; - public static final int GAME_RELIABLE_MESSAGE_CASTVOTE = 15; - public static final int GAME_RELIABLE_MESSAGE_STARTVOTE = 16; - public static final int GAME_RELIABLE_MESSAGE_UPDATEVOTE = 17; - public static final int GAME_RELIABLE_MESSAGE_PORTALSTATES = 18; - public static final int GAME_RELIABLE_MESSAGE_PORTAL = 19; - public static final int GAME_RELIABLE_MESSAGE_VCHAT = 20; - public static final int GAME_RELIABLE_MESSAGE_STARTSTATE = 21; - public static final int GAME_RELIABLE_MESSAGE_MENU = 22; - public static final int GAME_RELIABLE_MESSAGE_WARMUPTIME = 23; - public static final int GAME_RELIABLE_MESSAGE_EVENT = 24; + public static final int GAME_RELIABLE_MESSAGE_REMAP_DECL = 1; + public static final int GAME_RELIABLE_MESSAGE_SPAWN_PLAYER = 2; + public static final int GAME_RELIABLE_MESSAGE_DELETE_ENT = 3; + public static final int GAME_RELIABLE_MESSAGE_CHAT = 4; + public static final int GAME_RELIABLE_MESSAGE_TCHAT = 5; + public static final int GAME_RELIABLE_MESSAGE_SOUND_EVENT = 6; + public static final int GAME_RELIABLE_MESSAGE_SOUND_INDEX = 7; + public static final int GAME_RELIABLE_MESSAGE_DB = 8; + public static final int GAME_RELIABLE_MESSAGE_KILL = 9; + public static final int GAME_RELIABLE_MESSAGE_DROPWEAPON = 10; + public static final int GAME_RELIABLE_MESSAGE_RESTART = 11; + public static final int GAME_RELIABLE_MESSAGE_SERVERINFO = 12; + public static final int GAME_RELIABLE_MESSAGE_TOURNEYLINE = 13; + public static final int GAME_RELIABLE_MESSAGE_CALLVOTE = 14; + public static final int GAME_RELIABLE_MESSAGE_CASTVOTE = 15; + public static final int GAME_RELIABLE_MESSAGE_STARTVOTE = 16; + public static final int GAME_RELIABLE_MESSAGE_UPDATEVOTE = 17; + public static final int GAME_RELIABLE_MESSAGE_PORTALSTATES = 18; + public static final int GAME_RELIABLE_MESSAGE_PORTAL = 19; + public static final int GAME_RELIABLE_MESSAGE_VCHAT = 20; + public static final int GAME_RELIABLE_MESSAGE_STARTSTATE = 21; + public static final int GAME_RELIABLE_MESSAGE_MENU = 22; + public static final int GAME_RELIABLE_MESSAGE_WARMUPTIME = 23; + public static final int GAME_RELIABLE_MESSAGE_EVENT = 24; // }; public enum gameState_t { diff --git a/src/main/java/neo/Game/Physics/Physics_Monster.java b/src/main/java/neo/Game/Physics/Physics_Monster.java index b7ccef0f..c203b099 100644 --- a/src/main/java/neo/Game/Physics/Physics_Monster.java +++ b/src/main/java/neo/Game/Physics/Physics_Monster.java @@ -218,9 +218,10 @@ public void DisableImpact() { noImpact = true; } + private static int DBG_Evaluate = 0; // common physics interface @Override - public boolean Evaluate(int timeStepMSec, int endTimeMSec) { + public boolean Evaluate(int timeStepMSec, int endTimeMSec) { DBG_Evaluate++; idVec3 masterOrigin = new idVec3(), oldOrigin; idMat3 masterAxis = new idMat3(); float timeStep; diff --git a/src/main/java/neo/Game/Projectile.java b/src/main/java/neo/Game/Projectile.java index f2e7c4eb..bddd8bf7 100644 --- a/src/main/java/neo/Game/Projectile.java +++ b/src/main/java/neo/Game/Projectile.java @@ -214,7 +214,14 @@ public idProjectile() { physicsObj = new idPhysics_RigidBody(); } - // virtual ~idProjectile(); + + @Override + protected void _deconstructor() { + super._deconstructor(); + + StopSound(SND_CHANNEL_ANY.ordinal(), false); + FreeLightDef(); + } @Override public void Spawn() { @@ -1672,7 +1679,18 @@ public idBFGProjectile() { nextDamageTime = 0; damageFreq = new idStr(); } - // ~idBFGProjectile(); + + @Override + protected void _deconstructor() { + super._deconstructor(); + + FreeBeams(); + + if (secondModelDefHandle >= 0) { + gameRenderWorld.FreeEntityDef(secondModelDefHandle); + secondModelDefHandle = -1; + } + } @Override public void Save(idSaveGame savefile) { diff --git a/src/main/java/neo/idlib/BitMsg.java b/src/main/java/neo/idlib/BitMsg.java index c8b1695e..3b79670f 100644 --- a/src/main/java/neo/idlib/BitMsg.java +++ b/src/main/java/neo/idlib/BitMsg.java @@ -62,16 +62,20 @@ public idBitMsg() { } //public ~idBitMsg() {} - public void Init(ByteBuffer data, int length) { - writeData = data; - readData = data; - maxSize = length; + public void Init(byte[] data) { + this.Init(ByteBuffer.wrap(data), data.length); } public void Init(ByteBuffer data) { this.Init(data, data.capacity()); } + public void Init(ByteBuffer data, int length) { + writeData = data; + readData = data; + maxSize = length; + } + public void InitReadOnly(final ByteBuffer data, int length) { writeData = null; readData = data; diff --git a/src/main/java/neo/idlib/containers/LinkList.java b/src/main/java/neo/idlib/containers/LinkList.java index ee0497f6..385e7182 100644 --- a/src/main/java/neo/idlib/containers/LinkList.java +++ b/src/main/java/neo/idlib/containers/LinkList.java @@ -101,7 +101,6 @@ public void Clear() { Remove(); } } -// /* ================ @@ -160,7 +159,6 @@ public void AddToEnd(idLinkList node) { public void AddToFront(idLinkList node) { InsertAfter(node.head); } -// /* ================ @@ -177,7 +175,6 @@ public void Remove() { prev = this; head = this; } -// /* ================ diff --git a/src/misc/bug_report_04.txt b/src/misc/bug_report_04.txt new file mode 100644 index 00000000..be12f025 --- /dev/null +++ b/src/misc/bug_report_04.txt @@ -0,0 +1,40 @@ +blanco ingame, go: +-when enabling r_showViewEntitys & r_showTris we see some wireframes. are we missing light? + +-or, let's start by backtracking r_showViewEntitys & r_showTris. +-also look at the warnings like "rigid body moved outside world bounds for entity..." & "clip model outside world bounds for entity..." + -DBG_DropToFloorAndRest = 966 + -idPhysics_RigidBody::DropToFloorAndRest() is only called 110 times in the original and 591 in our fake version + -idClip::Contents() returns no nzero + -collisionModelManager.Contents() + -ok, so the japanese version is printing more values, which means somewhere a conditional is misfiring + -will this help us, no idea, just roll with it + -printing the values of current.i.position in Evaluate() is already yielding more results + -so the correct value is set in SetOrigin(), which means that this object shouldn't be in the linked list. + -idPhysics_Monster::DBG_Evaluate == 1278 + -self.name.equals("marscity_cinematic_betruger_1") + -this one is triggered during idSessionLocal::StartNewGame() in the translation, but not the original + -idGameLocal::RunFrame() --> activeEntities.Next() returns wrong value after Next().Next() + -idGameLocal::SortActiveEntityList() --> activeEntities.next.owner is the same, + but activeEntities.prev.owner is different. + -good 2087, bad 2093 + -2093 is added to the linkedlist twice..the second being in BecomeActive() originating at SetupWeaponEntity() + -which is added in idEntity::BecomeActive() + -2087 is the max loaded by the original, anything afterwards isn't supposed to be + -the same idGameLocal::RegisterEntity() call scores 2081 in the original, 2087 in the imitation. + -idGameLocal.entities[] seems to have nulls and values at different locations + -some entities are being spawned with the same spawn_entnum + -idGameLocal::SpawnMapEntities() 67, 68 + -firstFreeIndex++ + -105 is unregistered in the original. idGameLocal::UnregisterEntity() + -in da ~idEntity() deconstructor...who would have thought deconstructors would serve this much purpose. + + +-let's centering all the debug drawrings +-is our input working properly? + -let's assume it isn't...are movement commands being sent properly? + -idPlayer::Move()::oldOrigin == -3632.0 -3416.0 195.89555 + -idClipModel.SetPosition() + -are we moving? + -if we are, is everything on screen moving with us? + -if we aren't, then why not? \ No newline at end of file From 1de76b4e8ede61fbe707fadab2daffa6f50cf5ed Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Wed, 4 May 2016 14:01:34 +0200 Subject: [PATCH 04/17] -functionalized some of the callbacks, mostly idEntity --- src/main/java/neo/Game/Entity.java | 493 +++++++++++------- src/main/java/neo/Game/GameSys/Class.java | 64 ++- src/main/java/neo/Game/GameSys/Event.java | 22 +- src/main/java/neo/Game/Physics/Clip.java | 12 + .../java/neo/Game/Physics/Physics_Base.java | 3 +- .../java/neo/Game/Script/Script_Thread.java | 4 +- src/main/java/neo/Renderer/Image.java | 8 +- src/misc/bug_report_04.txt | 30 +- 8 files changed, 412 insertions(+), 224 deletions(-) diff --git a/src/main/java/neo/Game/Entity.java b/src/main/java/neo/Game/Entity.java index de62c7e0..3ffc345f 100644 --- a/src/main/java/neo/Game/Entity.java +++ b/src/main/java/neo/Game/Entity.java @@ -1,6 +1,11 @@ package neo.Game; import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Function; import java.util.stream.Stream; import neo.CM.CollisionModel.trace_s; import neo.Game.AFEntity.idAFEntity_Base; @@ -17,6 +22,14 @@ import neo.Game.Game.refSound_t; import neo.Game.GameSys.Class; import static neo.Game.GameSys.Class.EV_Remove; + +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.eventCallback_t2; +import neo.Game.GameSys.Class.eventCallback_t3; +import neo.Game.GameSys.Class.eventCallback_t4; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -216,6 +229,74 @@ public class Entity { public static final idEventDef EV_GetJointAngle = new idEventDef("getJointAngle", "d", 'v'); // + static Map eventCallbacks = new HashMap<>(); + static { + final eventCallback_t event_setName = (eventCallback_t1) idEntity::Event_SetName; + eventCallbacks.put(EV_GetName, (eventCallback_t0) idEntity::Event_GetName); + eventCallbacks.put(EV_SetName, (eventCallback_t1) idEntity::Event_SetName); + eventCallbacks.put(EV_FindTargets, (eventCallback_t0) idEntity::Event_FindTargets); + eventCallbacks.put(EV_ActivateTargets, (eventCallback_t1) idEntity::Event_ActivateTargets); + eventCallbacks.put(EV_NumTargets, (eventCallback_t0) idEntity::Event_NumTargets); + eventCallbacks.put(EV_GetTarget, (eventCallback_t1) idEntity::Event_GetTarget); + eventCallbacks.put(EV_RandomTarget, (eventCallback_t1) idEntity::Event_RandomTarget); + eventCallbacks.put(EV_BindToJoint, (eventCallback_t3) idEntity::Event_BindToJoint); + eventCallbacks.put(EV_RemoveBinds, (eventCallback_t0) idEntity::Event_RemoveBinds); + eventCallbacks.put(EV_Bind, (eventCallback_t1) idEntity::Event_Bind); + eventCallbacks.put(EV_BindPosition, (eventCallback_t1) idEntity::Event_BindPosition); + eventCallbacks.put(EV_Unbind, (eventCallback_t0) idEntity::Event_Unbind); + eventCallbacks.put(EV_SpawnBind, (eventCallback_t0) idEntity::Event_SpawnBind); + eventCallbacks.put(EV_SetOwner, (eventCallback_t1) idEntity::Event_SetOwner); + eventCallbacks.put(EV_SetModel, (eventCallback_t1) idEntity::Event_SetModel); + eventCallbacks.put(EV_SetSkin, (eventCallback_t1) idEntity::Event_SetSkin); + eventCallbacks.put(EV_GetShaderParm, (eventCallback_t1) idEntity::Event_GetShaderParm); + eventCallbacks.put(EV_SetShaderParm, (eventCallback_t2) idEntity::Event_SetShaderParm); + eventCallbacks.put(EV_SetShaderParms, (eventCallback_t4) idEntity::Event_SetShaderParms); + eventCallbacks.put(EV_SetColor, (eventCallback_t3) idEntity::Event_SetColor); + eventCallbacks.put(EV_GetColor, (eventCallback_t0) idEntity::Event_GetColor); + eventCallbacks.put(EV_IsHidden, (eventCallback_t0) idEntity::Event_IsHidden); + eventCallbacks.put(EV_Hide, (eventCallback_t0) idEntity::Event_Hide); + eventCallbacks.put(EV_Show, (eventCallback_t0) idEntity::Event_Show); + eventCallbacks.put(EV_CacheSoundShader, (eventCallback_t1) idEntity::Event_CacheSoundShader); + eventCallbacks.put(EV_StartSoundShader, (eventCallback_t2) idEntity::Event_StartSoundShader); + eventCallbacks.put(EV_StartSound, (eventCallback_t3) idEntity::Event_StartSound); + eventCallbacks.put(EV_StopSound, (eventCallback_t2) idEntity::Event_StopSound); + eventCallbacks.put(EV_FadeSound, (eventCallback_t3) idEntity::Event_FadeSound); + eventCallbacks.put(EV_GetWorldOrigin, (eventCallback_t0) idEntity::Event_GetWorldOrigin); + eventCallbacks.put(EV_SetWorldOrigin, (eventCallback_t1) idEntity::Event_SetWorldOrigin); + eventCallbacks.put(EV_GetOrigin, (eventCallback_t0) idEntity::Event_GetOrigin); + eventCallbacks.put(EV_SetOrigin, (eventCallback_t1) idEntity::Event_SetOrigin); + eventCallbacks.put(EV_GetAngles, (eventCallback_t0) idEntity::Event_GetAngles); + eventCallbacks.put(EV_SetAngles, (eventCallback_t1) idEntity::Event_SetAngles); + eventCallbacks.put(EV_GetLinearVelocity, (eventCallback_t0) idEntity::Event_GetLinearVelocity); + eventCallbacks.put(EV_SetLinearVelocity, (eventCallback_t1) idEntity::Event_SetLinearVelocity); + eventCallbacks.put(EV_GetAngularVelocity, (eventCallback_t0) idEntity::Event_GetAngularVelocity); + eventCallbacks.put(EV_SetAngularVelocity, (eventCallback_t1) idEntity::Event_SetAngularVelocity); + eventCallbacks.put(EV_GetSize, (eventCallback_t0) idEntity::Event_GetSize); + eventCallbacks.put(EV_SetSize, (eventCallback_t2) idEntity::Event_SetSize); + eventCallbacks.put(EV_GetMins, (eventCallback_t0) idEntity::Event_GetMins); + eventCallbacks.put(EV_GetMaxs, (eventCallback_t0) idEntity::Event_GetMaxs); + eventCallbacks.put(EV_Touches, (eventCallback_t1) idEntity::Event_Touches); + eventCallbacks.put(EV_SetGuiParm, (eventCallback_t2) idEntity::Event_SetGuiParm); + eventCallbacks.put(EV_SetGuiFloat, (eventCallback_t2) idEntity::Event_SetGuiFloat); + eventCallbacks.put(EV_GetNextKey, (eventCallback_t2) idEntity::Event_GetNextKey); + eventCallbacks.put(EV_SetKey, (eventCallback_t2) idEntity::Event_SetKey); + eventCallbacks.put(EV_GetKey, (eventCallback_t1) idEntity::Event_GetKey); + eventCallbacks.put(EV_GetIntKey, (eventCallback_t1) idEntity::Event_GetIntKey); + eventCallbacks.put(EV_GetFloatKey, (eventCallback_t1) idEntity::Event_GetFloatKey); + eventCallbacks.put(EV_GetVectorKey, (eventCallback_t1) idEntity::Event_GetVectorKey); + eventCallbacks.put(EV_GetEntityKey, (eventCallback_t1) idEntity::Event_GetEntityKey); + eventCallbacks.put(EV_RestorePosition, (eventCallback_t0) idEntity::Event_RestorePosition); + eventCallbacks.put(EV_UpdateCameraTarget, (eventCallback_t0) idEntity::Event_UpdateCameraTarget); + eventCallbacks.put(EV_DistanceTo, (eventCallback_t1) idEntity::Event_DistanceTo); + eventCallbacks.put(EV_DistanceToPoint, (eventCallback_t1) idEntity::Event_DistanceToPoint); + eventCallbacks.put(EV_StartFx, (eventCallback_t1) idEntity::Event_StartFx); +// eventCallbacks.put(EV_Thread_WaitFrame, (eventCallback_t0) idEntity::Event_WaitFrame); +// eventCallbacks.put(EV_Thread_Wait, (eventCallback_t0) idEntity::Event_Wait); +// eventCallbacks.put(EV_HasFunction, (eventCallback_t0) idEntity::Event_HasFunction); +// eventCallbacks.put(EV_CallFunction, (eventCallback_t0) idEntity::Event_CallFunction); +// eventCallbacks.put(EV_SetNeverDormant, (eventCallback_t0) idEntity::Event_SetNeverDormant); + } + // Think flags //enum { public static final int TH_ALL = -1; @@ -3573,16 +3654,16 @@ private void UpdatePVSAreas() { ***********************************************************************/ // events - private void Event_GetName() { - idThread.ReturnString(name.toString()); + private static void Event_GetName(idEntity e) { + idThread.ReturnString(e.name.toString()); } - private void Event_SetName(final String newName) { - SetName(newName); + private static void Event_SetName(idEntity e, final idEventArg newName) { + e.SetName(newName.value); } - private void Event_FindTargets() { - FindTargets(); + private static void Event_FindTargets(idEntity e) { + e.FindTargets(); } /* @@ -3593,41 +3674,42 @@ private void Event_FindTargets() { event to delay activating targets. ============ */ - private void Event_ActivateTargets(idEntity activator) { - ActivateTargets(activator); + private static void Event_ActivateTargets(idEntity e, idEventArg activator) { + e.ActivateTargets(activator.value); } - private void Event_NumTargets() { - idThread.ReturnFloat(targets.Num()); + private static void Event_NumTargets(idEntity e) { + idThread.ReturnFloat(e.targets.Num()); } - private void Event_GetTarget(float index) { + private static void Event_GetTarget(idEntity e, idEventArg index) { int i; - i = (int) index; - if ((i < 0) || i >= targets.Num()) { + i = index.value.intValue(); + if ((i < 0) || i >= e.targets.Num()) { idThread.ReturnEntity(null); } else { - idThread.ReturnEntity(targets.oGet(i).GetEntity()); + idThread.ReturnEntity(e.targets.oGet(i).GetEntity()); } } - private void Event_RandomTarget(final String ignore) { + private static void Event_RandomTarget(idEntity e, final idEventArg ignor) { int num; idEntity ent; int i; int ignoreNum; + final String ignore = ignor.value; - RemoveNullTargets(); - if (0 == targets.Num()) { + e.RemoveNullTargets(); + if (0 == e.targets.Num()) { idThread.ReturnEntity(null); return; } ignoreNum = -1; - if (ignore != null && (!ignore.isEmpty()) && (targets.Num() > 1)) { - for (i = 0; i < targets.Num(); i++) { - ent = targets.oGet(i).GetEntity(); + if (ignore != null && (!ignore.isEmpty()) && (e.targets.Num() > 1)) { + for (i = 0; i < e.targets.Num(); i++) { + ent = e.targets.oGet(i).GetEntity(); if (ent != null && (ent.name.equals(ignore))) { ignoreNum = i; break; @@ -3636,39 +3718,39 @@ private void Event_RandomTarget(final String ignore) { } if (ignoreNum >= 0) { - num = gameLocal.random.RandomInt(targets.Num() - 1); + num = gameLocal.random.RandomInt(e.targets.Num() - 1); if (num >= ignoreNum) { num++; } } else { - num = gameLocal.random.RandomInt(targets.Num()); + num = gameLocal.random.RandomInt(e.targets.Num()); } - ent = targets.oGet(num).GetEntity(); + ent = e.targets.oGet(num).GetEntity(); idThread.ReturnEntity(ent); } - private void Event_Bind(idEntity master) { - Bind(master, true); + private static void Event_Bind(idEntity e, idEventArg master) { + e.Bind(master.value, true); } - private void Event_BindPosition(idEntity master) { - Bind(master, false); + private static void Event_BindPosition(idEntity e, idEventArg master) { + e.Bind(master.value, false); } - private void Event_BindToJoint(idEntity master, final String jointname, float orientated) { - BindToJoint(master, jointname, (orientated != 0)); + private static void Event_BindToJoint(idEntity e, idEventArg master, final idEventArg jointname, idEventArg orientated) { + e.BindToJoint(master.value, jointname.value, (orientated.value != 0)); } - private void Event_Unbind() { - Unbind(); + private static void Event_Unbind(idEntity e) { + e.Unbind(); } - private void Event_RemoveBinds() { - RemoveBinds(); + private static void Event_RemoveBinds(idEntity e) { + e.RemoveBinds(); } - private void Event_SpawnBind() { + private static void Event_SpawnBind(idEntity e) { idEntity parent; String[] bind = new String[1], joint = new String[1], bindanim = new String[1]; int/*jointHandle_t*/ bindJoint; @@ -3678,35 +3760,35 @@ private void Event_SpawnBind() { int animNum; idAnimator parentAnimator; - if (spawnArgs.GetString("bind", "", bind)) { + if (e.spawnArgs.GetString("bind", "", bind)) { if (idStr.Icmp(bind[0], "worldspawn") == 0) { //FIXME: Completely unneccessary since the worldspawn is called "world" parent = gameLocal.world; } else { parent = gameLocal.FindEntity(bind[0]); } - bindOrientated = spawnArgs.GetBool("bindOrientated", "1"); + bindOrientated = e.spawnArgs.GetBool("bindOrientated", "1"); if (parent != null) { // bind to a joint of the skeletal model of the parent - if (spawnArgs.GetString("bindToJoint", "", joint) && joint[0] != null) {//TODO:check if java actually compiles them in the right order. + if (e.spawnArgs.GetString("bindToJoint", "", joint) && joint[0] != null) {//TODO:check if java actually compiles them in the right order. parentAnimator = parent.GetAnimator(); if (NOT(parentAnimator)) { - gameLocal.Error("Cannot bind to joint '%s' on '%s'. Entity does not support skeletal models.", joint[0], name); + gameLocal.Error("Cannot bind to joint '%s' on '%s'. Entity does not support skeletal models.", joint[0], e.name); } bindJoint = parentAnimator.GetJointHandle(joint[0]); if (bindJoint == INVALID_JOINT) { - gameLocal.Error("Joint '%s' not found for bind on '%s'", joint[0], name); + gameLocal.Error("Joint '%s' not found for bind on '%s'", joint[0], e.name); } // bind it relative to a specific anim if ((parent.spawnArgs.GetString("bindanim", "", bindanim) || parent.spawnArgs.GetString("anim", "", bindanim)) && bindanim[0] != null) { animNum = parentAnimator.GetAnim(bindanim[0]); if (0 == animNum) { - gameLocal.Error("Anim '%s' not found for bind on '%s'", bindanim[0], name); + gameLocal.Error("Anim '%s' not found for bind on '%s'", bindanim[0], e.name); } anim = parentAnimator.GetAnim(animNum); if (NOT(anim)) { - gameLocal.Error("Anim '%s' not found for bind on '%s'", bindanim[0], name); + gameLocal.Error("Anim '%s' not found for bind on '%s'", bindanim[0], e.name); } // make sure parent's render origin has been set @@ -3716,215 +3798,218 @@ private void Event_SpawnBind() { parentAnimator.CreateFrame(gameLocal.time, true); idJointMat[] frame = parent.renderEntity.joints; GameEdit.gameEdit.ANIM_CreateAnimFrame(parentAnimator.ModelHandle(), anim.MD5Anim(0), parent.renderEntity.numJoints, frame, 0, parentAnimator.ModelDef().GetVisualOffset(), parentAnimator.RemoveOrigin()); - BindToJoint(parent, joint[0], bindOrientated); + e.BindToJoint(parent, joint[0], bindOrientated); parentAnimator.ForceUpdate(); } else { - BindToJoint(parent, joint[0], bindOrientated); + e.BindToJoint(parent, joint[0], bindOrientated); } } // bind to a body of the physics object of the parent - else if (spawnArgs.GetInt("bindToBody", "0", id)) { - BindToBody(parent, id[0], bindOrientated); + else if (e.spawnArgs.GetInt("bindToBody", "0", id)) { + e.BindToBody(parent, id[0], bindOrientated); } // bind to the parent else { - Bind(parent, bindOrientated); + e.Bind(parent, bindOrientated); } } } } - private void Event_SetOwner(idEntity owner) { + private static void Event_SetOwner(idEntity e, idEventArg owner) { int i; - for (i = 0; i < GetPhysics().GetNumClipModels(); i++) { - GetPhysics().GetClipModel(i).SetOwner(owner); + for (i = 0; i < e.GetPhysics().GetNumClipModels(); i++) { + e.GetPhysics().GetClipModel(i).SetOwner(owner.value); } } - private void Event_SetModel(final String modelname) { - SetModel(modelname); + private static void Event_SetModel(idEntity e, final idEventArg modelname) { + e.SetModel(modelname.value); } - private void Event_SetSkin(final String skinname) { - renderEntity.customSkin = declManager.FindSkin(skinname); - UpdateVisuals(); + private static void Event_SetSkin(idEntity e, final idEventArg skinname) { + e.renderEntity.customSkin = declManager.FindSkin(skinname.value); + e.UpdateVisuals(); } - private void Event_GetShaderParm(int parmnum) { + private static void Event_GetShaderParm(idEntity e, idEventArg parm) { + final int parmnum = parm.value; if ((parmnum < 0) || (parmnum >= MAX_ENTITY_SHADER_PARMS)) { gameLocal.Error("shader parm index (%d) out of range", parmnum); } - idThread.ReturnFloat(renderEntity.shaderParms[parmnum]); + idThread.ReturnFloat(e.renderEntity.shaderParms[parmnum]); } - private void Event_SetShaderParm(int parmnum, float value) { - SetShaderParm(parmnum, value); + private static void Event_SetShaderParm(idEntity e, idEventArg parmnum, idEventArg value) { + e.SetShaderParm(parmnum.value, value.value); } - private void Event_SetShaderParms(float parm0, float parm1, float parm2, float parm3) { - renderEntity.shaderParms[SHADERPARM_RED] = parm0; - renderEntity.shaderParms[SHADERPARM_GREEN] = parm1; - renderEntity.shaderParms[SHADERPARM_BLUE] = parm2; - renderEntity.shaderParms[SHADERPARM_ALPHA] = parm3; - UpdateVisuals(); + private static void Event_SetShaderParms(idEntity e, idEventArg parm0, idEventArg parm1, idEventArg parm2, idEventArg parm3) { + e.renderEntity.shaderParms[SHADERPARM_RED] = parm0.value; + e.renderEntity.shaderParms[SHADERPARM_GREEN] = parm1.value; + e.renderEntity.shaderParms[SHADERPARM_BLUE] = parm2.value; + e.renderEntity.shaderParms[SHADERPARM_ALPHA] = parm3.value; + e.UpdateVisuals(); } - private void Event_SetColor(float red, float green, float blue) { - SetColor(red, green, blue); + private static void Event_SetColor(idEntity e, idEventArg red, idEventArg green, idEventArg blue) { + e.SetColor(red.value, green.value, blue.value); } - private void Event_GetColor() { + private static void Event_GetColor(idEntity e) { idVec3 out = new idVec3(); - GetColor(out); + e.GetColor(out); idThread.ReturnVector(out); } - private void Event_IsHidden() { - idThread.ReturnInt(fl.hidden); + private static void Event_IsHidden(idEntity e) { + idThread.ReturnInt(e.fl.hidden); } - private void Event_Hide() { - Hide(); + private static void Event_Hide(idEntity e) { + e.Hide(); } - private void Event_Show() { - Show(); + private static void Event_Show(idEntity e) { + e.Show(); } - private void Event_CacheSoundShader(final String soundName) { - declManager.FindSound(soundName); + private static void Event_CacheSoundShader(idEntity e, final idEventArg soundName) { + declManager.FindSound(soundName.value); } - private void Event_StartSoundShader(final String soundName, int channel) { + private static void Event_StartSoundShader(idEntity e, final idEventArg soundName, idEventArg channel) { int[] length = new int[1]; - StartSoundShader(declManager.FindSound(soundName), /*(s_channelType)*/ channel, 0, false, length); + e.StartSoundShader(declManager.FindSound(soundName.value), /*(s_channelType)*/ channel.value, 0, false, length); idThread.ReturnFloat(MS2SEC(length[0])); } - private void Event_StopSound(int channel, int netSync) { - StopSound(channel, (netSync != 0)); + private static void Event_StopSound(idEntity e, idEventArg channel, idEventArg netSync) { + e.StopSound(channel.value, (netSync.value != 0)); } - private void Event_StartSound(final String soundName, int channel, int netSync) { + private static void Event_StartSound(idEntity e, final idEventArg soundName, idEventArg channel, idEventArg netSync) { int[] time = new int[1]; - StartSound(soundName, /*(s_channelType)*/ channel, 0, (netSync != 0), time); + e.StartSound(soundName.value, /*(s_channelType)*/ channel.value, 0, (netSync.value != 0), time); idThread.ReturnFloat(MS2SEC(time[0])); } - private void Event_FadeSound(int channel, float to, float over) { - if (refSound.referenceSound != null) { - refSound.referenceSound.FadeSound(channel, to, over); + private static void Event_FadeSound(idEntity e, idEventArg channel, idEventArg to, idEventArg over) { + if (e.refSound.referenceSound != null) { + e.refSound.referenceSound.FadeSound(channel.value, to.value, over.value); } } - private void Event_GetWorldOrigin() { - idThread.ReturnVector(GetPhysics().GetOrigin()); + private static void Event_GetWorldOrigin(idEntity e) { + idThread.ReturnVector(e.GetPhysics().GetOrigin()); } - private void Event_SetWorldOrigin(final idVec3 org) { - idVec3 neworg = GetLocalCoordinates(org); - SetOrigin(neworg); + private static void Event_SetWorldOrigin(idEntity e, final idEventArg org) { + idVec3 neworg = e.GetLocalCoordinates(org.value); + e.SetOrigin(neworg); } - private void Event_GetOrigin() { - idThread.ReturnVector(GetLocalCoordinates(GetPhysics().GetOrigin())); + private static void Event_GetOrigin(idEntity e) { + idThread.ReturnVector(e.GetLocalCoordinates(e.GetPhysics().GetOrigin())); } - private void Event_SetOrigin(final idVec3 org) { - SetOrigin(org); + private static void Event_SetOrigin(idEntity e, final idEventArg org) { + e.SetOrigin(org.value); } - private void Event_GetAngles() { - idAngles ang = GetPhysics().GetAxis().ToAngles(); + private static void Event_GetAngles(idEntity e) { + idAngles ang = e.GetPhysics().GetAxis().ToAngles(); idThread.ReturnVector(new idVec3(ang.oGet(0), ang.oGet(1), ang.oGet(2))); } - private void Event_SetAngles(final idAngles ang) { - SetAngles(ang); + private static void Event_SetAngles(idEntity e, final idEventArg ang) { + e.SetAngles(ang.value); } - private void Event_SetLinearVelocity(final idVec3 velocity) { - GetPhysics().SetLinearVelocity(velocity); + private static void Event_SetLinearVelocity(idEntity e, final idEventArg velocity) { + e.GetPhysics().SetLinearVelocity(velocity.value); } - private void Event_GetLinearVelocity() { - idThread.ReturnVector(GetPhysics().GetLinearVelocity()); + private static void Event_GetLinearVelocity(idEntity e) { + idThread.ReturnVector(e.GetPhysics().GetLinearVelocity()); } - private void Event_SetAngularVelocity(final idVec3 velocity) { - GetPhysics().SetAngularVelocity(velocity); + private static void Event_SetAngularVelocity(idEntity e, final idEventArg velocity) { + e.GetPhysics().SetAngularVelocity(velocity.value); } - private void Event_GetAngularVelocity() { - idThread.ReturnVector(GetPhysics().GetAngularVelocity()); + private static void Event_GetAngularVelocity(idEntity e) { + idThread.ReturnVector(e.GetPhysics().GetAngularVelocity()); } - private void Event_SetSize(final idVec3 mins, final idVec3 maxs) { - GetPhysics().SetClipBox(new idBounds(mins, maxs), 1.0f); + private static void Event_SetSize(idEntity e, final idEventArg mins, final idEventArg maxs) { + e.GetPhysics().SetClipBox(new idBounds(mins.value, maxs.value), 1.0f); } - private void Event_GetSize() { + private static void Event_GetSize(idEntity e) { idBounds bounds; - bounds = GetPhysics().GetBounds(); + bounds = e.GetPhysics().GetBounds(); idThread.ReturnVector(bounds.oGet(1).oMinus(bounds.oGet(0))); } - private void Event_GetMins() { - idThread.ReturnVector(GetPhysics().GetBounds().oGet(0)); + private static void Event_GetMins(idEntity e) { + idThread.ReturnVector(e.GetPhysics().GetBounds().oGet(0)); } - private void Event_GetMaxs() { - idThread.ReturnVector(GetPhysics().GetBounds().oGet(1)); + private static void Event_GetMaxs(idEntity e) { + idThread.ReturnVector(e.GetPhysics().GetBounds().oGet(1)); } - private void Event_Touches(idEntity ent) { - if (NOT(ent)) { + private static void Event_Touches(idEntity e, idEventArg ent) { + if (NOT(ent.value)) { idThread.ReturnInt(false); return; } - final idBounds myBounds = GetPhysics().GetAbsBounds(); - final idBounds entBounds = ent.GetPhysics().GetAbsBounds(); + final idBounds myBounds = e.GetPhysics().GetAbsBounds(); + final idBounds entBounds = ent.value.GetPhysics().GetAbsBounds(); idThread.ReturnInt(myBounds.IntersectsBounds(entBounds)); } - private void Event_SetGuiParm(final String key, final String val) { + private static void Event_SetGuiParm(idEntity e, final idEventArg k, final idEventArg v) { + final String key = k.value; + final String val = v.value; for (int i = 0; i < MAX_RENDERENTITY_GUI; i++) { - if (renderEntity.gui[i] != null) { + if (e.renderEntity.gui[i] != null) { if (idStr.Icmpn(key, "gui_", 4) == 0) { - spawnArgs.Set(key, val); + e.spawnArgs.Set(key, val); } - renderEntity.gui[i].SetStateString(key, val); - renderEntity.gui[i].StateChanged(gameLocal.time); + e.renderEntity.gui[i].SetStateString(key, val); + e.renderEntity.gui[i].StateChanged(gameLocal.time); } } } - private void Event_SetGuiFloat(final String key, float f) { + private static void Event_SetGuiFloat(idEntity e, final idEventArg key, idEventArg f) { for (int i = 0; i < MAX_RENDERENTITY_GUI; i++) { - if (renderEntity.gui[i] != null) { - renderEntity.gui[i].SetStateString(key, va("%f", f)); - renderEntity.gui[i].StateChanged(gameLocal.time); + if (e.renderEntity.gui[i] != null) { + e.renderEntity.gui[i].SetStateString(key.value, va("%f", f.value)); + e.renderEntity.gui[i].StateChanged(gameLocal.time); } } } - private void Event_GetNextKey(final String prefix, final String lastMatch) { + private static void Event_GetNextKey(idEntity e, final idEventArg prefix, final idEventArg lastMatch) { final idKeyValue kv; final idKeyValue previous; - if (!lastMatch.isEmpty()) { - previous = spawnArgs.FindKey(lastMatch); + if (!lastMatch.value.isEmpty()) { + previous = e.spawnArgs.FindKey(lastMatch.value); } else { previous = null; } - kv = spawnArgs.MatchPrefix(prefix, previous); + kv = e.spawnArgs.MatchPrefix(prefix.value, previous); if (null == kv) { idThread.ReturnString(""); } else { @@ -3932,136 +4017,136 @@ private void Event_GetNextKey(final String prefix, final String lastMatch) { } } - private void Event_SetKey(final String key, final String value) { - spawnArgs.Set(key, value); + private static void Event_SetKey(idEntity e, final idEventArg key, final idEventArg value) { + e.spawnArgs.Set(key.value, value.value); } - private void Event_GetKey(final String key) { + private static void Event_GetKey(idEntity e, final idEventArg key) { String[] value = new String[1]; - spawnArgs.GetString(key, "", value); + e.spawnArgs.GetString(key.value, "", value); idThread.ReturnString(value[0]); } - private void Event_GetIntKey(final String key) { + private static void Event_GetIntKey(idEntity e, final idEventArg key) { int[] value = new int[1]; - spawnArgs.GetInt(key, "0", value); + e.spawnArgs.GetInt(key.value, "0", value); // scripts only support floats idThread.ReturnFloat(value[0]); } - private void Event_GetFloatKey(final String key) { + private static void Event_GetFloatKey(idEntity e, final idEventArg key) { float[] value = new float[1]; - spawnArgs.GetFloat(key, "0", value); + e.spawnArgs.GetFloat(key.value, "0", value); idThread.ReturnFloat(value[0]); } - private void Event_GetVectorKey(final String key) { + private static void Event_GetVectorKey(idEntity e, final idEventArg key) { idVec3 value = new idVec3(); - spawnArgs.GetVector(key, "0 0 0", value); + e.spawnArgs.GetVector(key.value, "0 0 0", value); idThread.ReturnVector(value); } - private void Event_GetEntityKey(final String key) { + private static void Event_GetEntityKey(idEntity e, final idEventArg key) { idEntity ent; String[] entName = new String[1]; - if (!spawnArgs.GetString(key, null, entName)) { + if (!e.spawnArgs.GetString(key.value, null, entName)) { idThread.ReturnEntity(null); return; } ent = gameLocal.FindEntity(entName[0]); if (null == ent) { - gameLocal.Warning("Couldn't find entity '%s' specified in '%s' key in entity '%s'", entName, key, name); + gameLocal.Warning("Couldn't find entity '%s' specified in '%s' key in entity '%s'", entName, key, e.name); } idThread.ReturnEntity(ent); } - private void Event_RestorePosition() { + private static void Event_RestorePosition(idEntity e) { idVec3 org = new idVec3(); idAngles angles = new idAngles(); idMat3 axis = new idMat3(); idEntity part; - spawnArgs.GetVector("origin", "0 0 0", org); + e.spawnArgs.GetVector("origin", "0 0 0", org); // get the rotation matrix in either full form, or single angle form - if (spawnArgs.GetMatrix("rotation", "1 0 0 0 1 0 0 0 1", axis)) { + if (e.spawnArgs.GetMatrix("rotation", "1 0 0 0 1 0 0 0 1", axis)) { angles = axis.ToAngles(); } else { angles.oSet(0, 0); - angles.oSet(1, spawnArgs.GetFloat("angle")); + angles.oSet(1, e.spawnArgs.GetFloat("angle")); angles.oSet(2, 0); } - Teleport(org, angles, null); + e.Teleport(org, angles, null); - for (part = teamChain; part != null; part = part.teamChain) { - if (part.bindMaster != this) { + for (part = e.teamChain; part != null; part = part.teamChain) { + if (part.bindMaster != e) { continue; } if (part.GetPhysics().IsType(idPhysics_Parametric.class)) { if (((idPhysics_Parametric) part.GetPhysics()).IsPusher()) { - gameLocal.Warning("teleported '%s' which has the pushing mover '%s' bound to it\n", GetName(), part.GetName()); + gameLocal.Warning("teleported '%s' which has the pushing mover '%s' bound to it\n", e.GetName(), part.GetName()); } } else if (part.GetPhysics().IsType(idPhysics_AF.class)) { - gameLocal.Warning("teleported '%s' which has the articulated figure '%s' bound to it\n", GetName(), part.GetName()); + gameLocal.Warning("teleported '%s' which has the articulated figure '%s' bound to it\n", e.GetName(), part.GetName()); } } } - private void Event_UpdateCameraTarget() { + private static void Event_UpdateCameraTarget(idEntity e) { final String target; idKeyValue kv; idVec3 dir; - target = spawnArgs.GetString("cameraTarget"); + target = e.spawnArgs.GetString("cameraTarget"); - cameraTarget = gameLocal.FindEntity(target); + e.cameraTarget = gameLocal.FindEntity(target); - if (cameraTarget != null) { - kv = cameraTarget.spawnArgs.MatchPrefix("target", null); + if (e.cameraTarget != null) { + kv = e.cameraTarget.spawnArgs.MatchPrefix("target", null); while (kv != null) { idEntity ent = gameLocal.FindEntity(kv.GetValue()); if (ent != null && idStr.Icmp(ent.GetEntityDefName(), "target_null") == 0) { - dir = ent.GetPhysics().GetOrigin().oMinus(cameraTarget.GetPhysics().GetOrigin()); + dir = ent.GetPhysics().GetOrigin().oMinus(e.cameraTarget.GetPhysics().GetOrigin()); dir.Normalize(); - cameraTarget.SetAxis(dir.ToMat3()); - SetAxis(dir.ToMat3()); + e.cameraTarget.SetAxis(dir.ToMat3()); + e.SetAxis(dir.ToMat3()); break; } - kv = cameraTarget.spawnArgs.MatchPrefix("target", kv); + kv = e.cameraTarget.spawnArgs.MatchPrefix("target", kv); } } - UpdateVisuals(); + e.UpdateVisuals(); } - private void Event_DistanceTo(idEntity ent) { - if (null == ent) { + private static void Event_DistanceTo(idEntity e, idEventArg ent) { + if (null == ent.value) { // just say it's really far away idThread.ReturnFloat(MAX_WORLD_SIZE); } else { - float dist = GetPhysics().GetOrigin().oMinus(ent.GetPhysics().GetOrigin()).LengthFast(); + float dist = e.GetPhysics().GetOrigin().oMinus(ent.value.GetPhysics().GetOrigin()).LengthFast(); idThread.ReturnFloat(dist); } } - private void Event_DistanceToPoint(final idVec3 point) { - float dist = GetPhysics().GetOrigin().oMinus(point).LengthFast(); + private static void Event_DistanceToPoint(idEntity e, final idEventArg point) { + float dist = e.GetPhysics().GetOrigin().oMinus(point.value).LengthFast(); idThread.ReturnFloat(dist); } - private void Event_StartFx(final String fx) { - idEntityFx.StartFx(fx, null, null, this, true); + private static void Event_StartFx(idEntity e, final idEventArg fx) { + idEntityFx.StartFx(fx.value, null, null, e, true); } - private void Event_WaitFrame() { + private static void Event_WaitFrame() { idThread thread; thread = idThread.CurrentThread(); @@ -4070,7 +4155,7 @@ private void Event_WaitFrame() { } } - private void Event_Wait(float time) { + private static void Event_Wait(float time) { idThread thread = idThread.CurrentThread(); if (null == thread) { @@ -4080,10 +4165,10 @@ private void Event_Wait(float time) { thread.WaitSec(time); } - private void Event_HasFunction(final String name) { + private static void Event_HasFunction(idEntity e, final String name) { function_t func; - func = scriptObject.GetFunction(name); + func = e.scriptObject.GetFunction(name); if (func != null) { idThread.ReturnInt(true); } else { @@ -4091,7 +4176,7 @@ private void Event_HasFunction(final String name) { } } - private void Event_CallFunction(final String funcName) { + private static void Event_CallFunction(idEntity e, final String funcName) { function_t func; idThread thread; @@ -4100,25 +4185,25 @@ private void Event_CallFunction(final String funcName) { gameLocal.Error("Event 'callFunction' called from outside thread"); } - func = scriptObject.GetFunction(funcName); + func = e.scriptObject.GetFunction(funcName); if (NOT(func)) { - gameLocal.Error("Unknown function '%s' in '%s'", funcName, scriptObject.GetTypeName()); + gameLocal.Error("Unknown function '%s' in '%s'", funcName, e.scriptObject.GetTypeName()); } if (func.type.NumParameters() != 1) { gameLocal.Error("Function '%s' has the wrong number of parameters for 'callFunction'", funcName); } - if (!scriptObject.GetTypeDef().Inherits(func.type.GetParmType(0))) { + if (!e.scriptObject.GetTypeDef().Inherits(func.type.GetParmType(0))) { gameLocal.Error("Function '%s' is the wrong type for 'callFunction'", funcName); } // function args will be invalid after this call - thread.CallFunction(this, func, false); + thread.CallFunction(e, func, false); } - private void Event_SetNeverDormant(int enable) { - fl.neverDormant = (enable != 0); - dormantStart = 0; + private static void Event_SetNeverDormant(idEntity e, int enable) { + e.fl.neverDormant = (enable != 0); + e.dormantStart = 0; } public static void delete(final idEntity entity){ @@ -4152,6 +4237,16 @@ public static class damageEffect_s { */ public static class idAnimatedEntity extends idEntity { + static { + eventCallbacks.put(EV_GetJointHandle, (eventCallback_t1) idAnimatedEntity::Event_GetJointHandle); + eventCallbacks.put(EV_ClearAllJoints, (eventCallback_t0) idAnimatedEntity::Event_ClearAllJoints); + eventCallbacks.put(EV_ClearJoint, (eventCallback_t1) idAnimatedEntity::Event_ClearJoint); + eventCallbacks.put(EV_SetJointPos, (eventCallback_t3) idAnimatedEntity::Event_SetJointPos); + eventCallbacks.put(EV_SetJointAngle, (eventCallback_t3) idAnimatedEntity::Event_SetJointAngle); + eventCallbacks.put(EV_GetJointPos, (eventCallback_t1) idAnimatedEntity::Event_GetJointPos); + eventCallbacks.put(EV_GetJointAngle, (eventCallback_t1) idAnimatedEntity::Event_GetJointAngle); + } + // enum { public static final int EVENT_ADD_DAMAGE_EFFECT = idEntity.EVENT_MAXEVENTS; public static final int EVENT_MAXEVENTS = EVENT_ADD_DAMAGE_EFFECT + 1; @@ -4520,11 +4615,11 @@ public boolean ClientReceiveEvent(int event, int time, final idBitMsg msg) { looks up the number of the specified joint. returns INVALID_JOINT if the joint is not found. ================ */ - private void Event_GetJointHandle(final String jointname) { + private static void Event_GetJointHandle(idEntity e, final idEventArg jointname) { // jointHandle_t joint = new jointHandle_t(); int joint; - joint = animator.GetJointHandle(jointname); + joint = ((idAnimatedEntity) e).animator.GetJointHandle(jointname.value); idThread.ReturnInt(joint); } @@ -4535,8 +4630,8 @@ private void Event_GetJointHandle(final String jointname) { removes any custom transforms on all joints ================ */ - private void Event_ClearAllJoints() { - animator.ClearAllJoints(); + private static void Event_ClearAllJoints(idEntity e) { + ((idAnimatedEntity) e).animator.ClearAllJoints(); } /* @@ -4546,8 +4641,8 @@ private void Event_ClearAllJoints() { removes any custom transforms on the specified joint ================ */ - private void Event_ClearJoint(int/*jointHandle_t*/ jointnum) { - animator.ClearJoint(jointnum); + private static void Event_ClearJoint(idEntity e, idEventArg/*jointHandle_t*/ jointnum) { + ((idAnimatedEntity) e).animator.ClearJoint(jointnum.value); } /* @@ -4557,8 +4652,8 @@ private void Event_ClearJoint(int/*jointHandle_t*/ jointnum) { modifies the position of the joint based on the transform type ================ */ - private void Event_SetJointPos(int/*jointHandle_t*/ jointnum, jointModTransform_t transform_type, final idVec3 pos) { - animator.SetJointPos(jointnum, transform_type, pos); + private static void Event_SetJointPos(idEntity e, idEventArg/*jointHandle_t*/ jointnum, idEventArg transform_type, final idEventArg pos) { + ((idAnimatedEntity) e).animator.SetJointPos(jointnum.value, transform_type.value, pos.value); } /* @@ -4568,11 +4663,11 @@ private void Event_SetJointPos(int/*jointHandle_t*/ jointnum, jointModTransform_ modifies the orientation of the joint based on the transform type ================ */ - private void Event_SetJointAngle(int/*jointHandle_t*/ jointnum, jointModTransform_t transform_type, final idAngles angles) { + private static void Event_SetJointAngle(idEntity e, idEventArg/*jointHandle_t*/ jointnum, idEventArg transform_type, final idEventArg angles) { idMat3 mat; - mat = angles.ToMat3(); - animator.SetJointAxis(jointnum, transform_type, mat); + mat = angles.value.ToMat3(); + ((idAnimatedEntity) e).animator.SetJointAxis(jointnum.value, transform_type.value, mat); } /* @@ -4582,12 +4677,12 @@ private void Event_SetJointAngle(int/*jointHandle_t*/ jointnum, jointModTransfor returns the position of the joint in worldspace ================ */ - private void Event_GetJointPos(int/*jointHandle_t*/ jointnum) { + private static void Event_GetJointPos(idEntity e, idEventArg/*jointHandle_t*/ jointnum) { idVec3 offset = new idVec3(); idMat3 axis = new idMat3(); - if (!GetJointWorldTransform(jointnum, gameLocal.time, offset, axis)) { - gameLocal.Warning("Joint # %d out of range on entity '%s'", jointnum, name); + if (!((idAnimatedEntity) e).GetJointWorldTransform(jointnum.value, gameLocal.time, offset, axis)) { + gameLocal.Warning("Joint # %d out of range on entity '%s'", jointnum, e.name); } idThread.ReturnVector(offset); @@ -4601,12 +4696,12 @@ private void Event_GetJointPos(int/*jointHandle_t*/ jointnum) { returns the orientation of the joint in worldspace ================ */ - private void Event_GetJointAngle(int/*jointHandle_t*/ jointnum) { + private static void Event_GetJointAngle(idEntity e, idEventArg/*jointHandle_t*/ jointnum) { idVec3 offset = new idVec3(); idMat3 axis = new idMat3(); - if (!GetJointWorldTransform(jointnum, gameLocal.time, offset, axis)) { - gameLocal.Warning("Joint # %d out of range on entity '%s'", jointnum, name); + if (!((idAnimatedEntity) e).GetJointWorldTransform(jointnum.value, gameLocal.time, offset, axis)) { + gameLocal.Warning("Joint # %d out of range on entity '%s'", jointnum, e.name); } idAngles ang = axis.ToAngles(); diff --git a/src/main/java/neo/Game/GameSys/Class.java b/src/main/java/neo/Game/GameSys/Class.java index b57a2102..84ea004f 100644 --- a/src/main/java/neo/Game/GameSys/Class.java +++ b/src/main/java/neo/Game/GameSys/Class.java @@ -4,7 +4,6 @@ import neo.CM.CollisionModel.trace_s; import static neo.Game.Entity.EV_Activate; import neo.Game.Entity.idEntity; -import neo.Game.GameSys.Class.eventCallback_t; import static neo.Game.GameSys.Class.idEventArg.toEvent; import static neo.Game.GameSys.Event.D_EVENT_ENTITY; import static neo.Game.GameSys.Event.D_EVENT_FLOAT; @@ -49,9 +48,60 @@ public class Class { static idHierarchy classHierarchy = new idHierarchy<>(); static int eventCallbackMemory = 0; - public static abstract class eventCallback_t { + @FunctionalInterface + public interface eventCallback_t { + void accept(idEntity e, idEventArg...args); + } + + @FunctionalInterface + public interface eventCallback_t0 extends eventCallback_t { + @Override + default void accept(idEntity e, idEventArg... args) { + accept(e); + } + + void accept(idEntity e); + } + + @FunctionalInterface + public interface eventCallback_t1 extends eventCallback_t { + @Override + default void accept(idEntity e, idEventArg... args) { + accept(e, args[0]); + } + + void accept(idEntity e, idEventArg a); + } + + + @FunctionalInterface + public interface eventCallback_t2 extends eventCallback_t { + @Override + default void accept(idEntity e, idEventArg... args) { + accept(e, args[0], args[1]); + } + + void accept(idEntity e, idEventArg a, idEventArg b); + } + + @FunctionalInterface + public interface eventCallback_t3 extends eventCallback_t { + @Override + default void accept(idEntity e, idEventArg... args) { + accept(e, args[0], args[1], args[2]); + } + + void accept(idEntity e, idEventArg a, idEventArg b, idEventArg c); + } + + @FunctionalInterface + public interface eventCallback_t4 extends eventCallback_t { + @Override + default void accept(idEntity e, idEventArg... args) { + accept(e, args[0], args[1], args[2], args[3]); + } - public abstract void run(final int... data); + void accept(idEntity e, idEventArg a, idEventArg b, idEventArg c, idEventArg d); } public static abstract class classSpawnFunc_t { @@ -75,14 +125,14 @@ public static class idEventFunc { eventCallback_t function; }; - public static class idEventArg { + public static class idEventArg { - public final int type; - public final Object value; + public final int type; + public final T value; // // - public idEventArg(Object data) { + public idEventArg(T data) { if(data instanceof Integer) type = D_EVENT_INTEGER; else if(data instanceof Float) type = D_EVENT_FLOAT; else if(data instanceof idVec3) type = D_EVENT_VECTOR; diff --git a/src/main/java/neo/Game/GameSys/Event.java b/src/main/java/neo/Game/GameSys/Event.java index ba060aed..98879462 100644 --- a/src/main/java/neo/Game/GameSys/Event.java +++ b/src/main/java/neo/Game/GameSys/Event.java @@ -525,6 +525,7 @@ public static void ServiceEvents() { String formatspec; trace_s[] tracePtr; idEventDef ev; + Object[] data; String materialName; num = 0; @@ -542,12 +543,13 @@ public static void ServiceEvents() { numargs = ev.GetNumArgs(); for (i = 0; i < numargs; i++) { offset = ev.GetArgOffset(i); -// switch( formatspec[ i ] ) { -// case D_EVENT_FLOAT : -// case D_EVENT_INTEGER : -// args[ i ] = *reinterpret_cast( &data[ offset ] ); -// break; -// + data = event.data; + switch (formatspec.charAt(i)) { + case D_EVENT_FLOAT: + case D_EVENT_INTEGER: + args[i] = (int) data[offset]; + break; + // case D_EVENT_VECTOR : // *reinterpret_cast( &args[ i ] ) = reinterpret_cast( &data[ offset ] ); // break; @@ -575,10 +577,10 @@ public static void ServiceEvents() { // *tracePtr = NULL; // } // break; -// -// default: -// gameLocal.Error( "idEvent::ServiceEvents : Invalid arg format '%s' string for '%s' event.", formatspec, ev.GetName() ); -// }//TODO:S ^^^^^^^^^^^^^^^^^^^^^ + + default: + gameLocal.Error("idEvent::ServiceEvents : Invalid arg format '%s' string for '%s' event.", formatspec, ev.GetName()); + }//TODO:S ^^^^^^^^^^^^^^^^^^^^^ } // the event is removed from its list so that if then object diff --git a/src/main/java/neo/Game/Physics/Clip.java b/src/main/java/neo/Game/Physics/Clip.java index dac05354..b7c3ef43 100644 --- a/src/main/java/neo/Game/Physics/Clip.java +++ b/src/main/java/neo/Game/Physics/Clip.java @@ -332,6 +332,9 @@ public void Link(idClip clp, idEntity ent, int newId, final idVec3 newOrigin, fi this.id = newId; this.origin.oSet(newOrigin); this.axis.oSet(newAxis); + if (origin.z < -1111) { + int a = 0; + } if (renderModelHandle != -1) { this.renderModelHandle = renderModelHandle; final renderEntity_s renderEntity = gameRenderWorld.GetRenderEntity(renderModelHandle); @@ -364,17 +367,26 @@ public void SetPosition(final idVec3 newOrigin, final idMat3 newAxis) { // unlin Unlink(); // unlink from old position } origin.oSet(newOrigin); + if (origin.z < -1111) { + int a = 0; + } axis.oSet(newAxis); } public void Translate(final idVec3 translation) { // unlinks the clip model Unlink(); origin.oPluSet(translation); + if (origin.z < -1111) { + int a = 0; + } } public void Rotate(final idRotation rotation) { // unlinks the clip model Unlink(); origin.oMulSet(rotation); + if (origin.z < -1111) { + int a = 0; + } axis.oMulSet(rotation.ToMat3()); } diff --git a/src/main/java/neo/Game/Physics/Physics_Base.java b/src/main/java/neo/Game/Physics/Physics_Base.java index 1c861100..3761b09a 100644 --- a/src/main/java/neo/Game/Physics/Physics_Base.java +++ b/src/main/java/neo/Game/Physics/Physics_Base.java @@ -527,8 +527,9 @@ protected void ActivateContactEntities() { } } + private static int DBG_IsOutsideWorld = 0; // returns true if the whole physics object is outside the world bounds - protected boolean IsOutsideWorld() { + protected boolean IsOutsideWorld() { DBG_IsOutsideWorld++; if (!gameLocal.clip.GetWorldBounds().Expand(128.0f).IntersectsBounds(GetAbsBounds())) { return true; } diff --git a/src/main/java/neo/Game/Script/Script_Thread.java b/src/main/java/neo/Game/Script/Script_Thread.java index f8f0b7a2..66f8c670 100644 --- a/src/main/java/neo/Game/Script/Script_Thread.java +++ b/src/main/java/neo/Game/Script/Script_Thread.java @@ -59,8 +59,8 @@ public class Script_Thread { // script callable events static final idEventDef EV_Thread_TerminateThread = new idEventDef("terminate", "d"); static final idEventDef EV_Thread_Pause = new idEventDef("pause", null); - static final idEventDef EV_Thread_Wait = new idEventDef("wait", "f"); - static final idEventDef EV_Thread_WaitFrame = new idEventDef("waitFrame"); + public static final idEventDef EV_Thread_Wait = new idEventDef("wait", "f"); + public static final idEventDef EV_Thread_WaitFrame = new idEventDef("waitFrame"); static final idEventDef EV_Thread_WaitFor = new idEventDef("waitFor", "e"); static final idEventDef EV_Thread_WaitForThread = new idEventDef("waitForThread", "d"); static final idEventDef EV_Thread_Print = new idEventDef("print", "s"); diff --git a/src/main/java/neo/Renderer/Image.java b/src/main/java/neo/Renderer/Image.java index 360d3161..fc0774bd 100644 --- a/src/main/java/neo/Renderer/Image.java +++ b/src/main/java/neo/Renderer/Image.java @@ -831,7 +831,7 @@ public void GenerateImage(final ByteBuffer pic, int width, int height, // scaledBuffer = null; // generate the texture number texNum = qglGenTextures(); - System.out.println(imgName + ": " + texNum); +// System.out.println(imgName + ": " + texNum); // select proper internal format before we resample internalFormat = SelectInternalFormat(pic, 1, width, height, depth, isMonochrome); @@ -1056,7 +1056,7 @@ public void Generate3DImage(final ByteBuffer pic, int width, int height, int pic // FIXME: allow picmip here // generate the texture number texNum = qglGenTextures(); - System.out.println(imgName + ": " + texNum); +// System.out.println(imgName + ": " + texNum); // select proper internal format before we resample // this function doesn't need to know it is 3D, so just make it very "tall" @@ -1190,7 +1190,7 @@ public void GenerateCubeImage(final ByteBuffer[] pics/*[6]*/, int size, // generate the texture number texNum = qglGenTextures(); - System.out.println(imgName + ": " + texNum); +// System.out.println(imgName + ": " + texNum); // select proper internal format before we resample internalFormat = SelectInternalFormat(pics, 6, width, height, depth, isMonochrome); @@ -2288,7 +2288,7 @@ public void UploadPrecompressedImage(ByteBuffer data, int len) { // generate the texture number texNum = qglGenTextures(); - System.out.println(imgName + ": " + texNum); +// System.out.println(imgName + ": " + texNum); // if (texNum == 58) { // DBG_UploadPrecompressedImage = data.duplicate(); diff --git a/src/misc/bug_report_04.txt b/src/misc/bug_report_04.txt index be12f025..ca6d2507 100644 --- a/src/misc/bug_report_04.txt +++ b/src/misc/bug_report_04.txt @@ -28,7 +28,35 @@ blanco ingame, go: -firstFreeIndex++ -105 is unregistered in the original. idGameLocal::UnregisterEntity() -in da ~idEntity() deconstructor...who would have thought deconstructors would serve this much purpose. - + -fixed, but still no ingame shit. . . + -back to backtracking from the warnings. + -so the idClipModel.origin values are out of whack, especially the Z. + -printed out all 2064 origins. + -they seem to match at first glance + -idPhysics_Base::IsOutsideWorld()->GetAbsBounds() returns zeroes in the original, but weird arzse values in the jafa. + -feels like we're going in circles, but we should've been checking idClipModel.absBounds instead of origin. + -let's start by printing out the classnames + -the jafa version prints out 880 names vs 254 in the cpp. + -a total of 4 instances in the cpp version though. + -wrong moron! + -is the teamChain part in idEntity::RunPhysics() fucked up? + - cpp jj + idEntity::QuitTeam() 7 6 + idEntity::JoinTeam() 205 97 + idEntity::Unbind() 207 98 + -func_door_17 is the last common idEntity(), then there's a gap, and then player1_head + -idEvent::ServiceEvents() + -idEntity::Event_SpawnBind(), we're missing callbacks(missing being the understatement of the year) + -idEvent::Schedule() + -idClass::PostEventArgs() + idTypeInfo::Init() for c.eventMap[] + -idClass::ProcessEventArgPtr() + -plan: + static methods + give object as param - ServiceEvents + varargs object - ProcessEventArgPtr + varargs[0] is object - ProcessEventArgPtr + -let's centering all the debug drawrings -is our input working properly? From 048ecfa9de9028feb2e3c54cd62a6def7d253a37 Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Thu, 5 May 2016 10:58:53 +0200 Subject: [PATCH 05/17] -the idThread events have been functionalized as well(fucking grunt work) -made eventCallback uglier and more generic --- src/main/java/neo/Game/Entity.java | 187 +++---- src/main/java/neo/Game/GameSys/Class.java | 80 +-- src/main/java/neo/Game/GameSys/Event.java | 230 +++++---- src/main/java/neo/Game/Physics/Force.java | 8 +- src/main/java/neo/Game/Physics/Physics.java | 7 + .../java/neo/Game/Script/Script_Thread.java | 455 ++++++++++++------ 6 files changed, 581 insertions(+), 386 deletions(-) diff --git a/src/main/java/neo/Game/Entity.java b/src/main/java/neo/Game/Entity.java index 3ffc345f..c638858a 100644 --- a/src/main/java/neo/Game/Entity.java +++ b/src/main/java/neo/Game/Entity.java @@ -3,9 +3,6 @@ import java.nio.ByteBuffer; import java.util.HashMap; import java.util.Map; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.function.Function; import java.util.stream.Stream; import neo.CM.CollisionModel.trace_s; import neo.Game.AFEntity.idAFEntity_Base; @@ -30,6 +27,7 @@ import neo.Game.GameSys.Class.eventCallback_t3; import neo.Game.GameSys.Class.eventCallback_t4; import neo.Game.GameSys.Class.idEventArg; +import neo.Game.GameSys.Event; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -229,74 +227,6 @@ public class Entity { public static final idEventDef EV_GetJointAngle = new idEventDef("getJointAngle", "d", 'v'); // - static Map eventCallbacks = new HashMap<>(); - static { - final eventCallback_t event_setName = (eventCallback_t1) idEntity::Event_SetName; - eventCallbacks.put(EV_GetName, (eventCallback_t0) idEntity::Event_GetName); - eventCallbacks.put(EV_SetName, (eventCallback_t1) idEntity::Event_SetName); - eventCallbacks.put(EV_FindTargets, (eventCallback_t0) idEntity::Event_FindTargets); - eventCallbacks.put(EV_ActivateTargets, (eventCallback_t1) idEntity::Event_ActivateTargets); - eventCallbacks.put(EV_NumTargets, (eventCallback_t0) idEntity::Event_NumTargets); - eventCallbacks.put(EV_GetTarget, (eventCallback_t1) idEntity::Event_GetTarget); - eventCallbacks.put(EV_RandomTarget, (eventCallback_t1) idEntity::Event_RandomTarget); - eventCallbacks.put(EV_BindToJoint, (eventCallback_t3) idEntity::Event_BindToJoint); - eventCallbacks.put(EV_RemoveBinds, (eventCallback_t0) idEntity::Event_RemoveBinds); - eventCallbacks.put(EV_Bind, (eventCallback_t1) idEntity::Event_Bind); - eventCallbacks.put(EV_BindPosition, (eventCallback_t1) idEntity::Event_BindPosition); - eventCallbacks.put(EV_Unbind, (eventCallback_t0) idEntity::Event_Unbind); - eventCallbacks.put(EV_SpawnBind, (eventCallback_t0) idEntity::Event_SpawnBind); - eventCallbacks.put(EV_SetOwner, (eventCallback_t1) idEntity::Event_SetOwner); - eventCallbacks.put(EV_SetModel, (eventCallback_t1) idEntity::Event_SetModel); - eventCallbacks.put(EV_SetSkin, (eventCallback_t1) idEntity::Event_SetSkin); - eventCallbacks.put(EV_GetShaderParm, (eventCallback_t1) idEntity::Event_GetShaderParm); - eventCallbacks.put(EV_SetShaderParm, (eventCallback_t2) idEntity::Event_SetShaderParm); - eventCallbacks.put(EV_SetShaderParms, (eventCallback_t4) idEntity::Event_SetShaderParms); - eventCallbacks.put(EV_SetColor, (eventCallback_t3) idEntity::Event_SetColor); - eventCallbacks.put(EV_GetColor, (eventCallback_t0) idEntity::Event_GetColor); - eventCallbacks.put(EV_IsHidden, (eventCallback_t0) idEntity::Event_IsHidden); - eventCallbacks.put(EV_Hide, (eventCallback_t0) idEntity::Event_Hide); - eventCallbacks.put(EV_Show, (eventCallback_t0) idEntity::Event_Show); - eventCallbacks.put(EV_CacheSoundShader, (eventCallback_t1) idEntity::Event_CacheSoundShader); - eventCallbacks.put(EV_StartSoundShader, (eventCallback_t2) idEntity::Event_StartSoundShader); - eventCallbacks.put(EV_StartSound, (eventCallback_t3) idEntity::Event_StartSound); - eventCallbacks.put(EV_StopSound, (eventCallback_t2) idEntity::Event_StopSound); - eventCallbacks.put(EV_FadeSound, (eventCallback_t3) idEntity::Event_FadeSound); - eventCallbacks.put(EV_GetWorldOrigin, (eventCallback_t0) idEntity::Event_GetWorldOrigin); - eventCallbacks.put(EV_SetWorldOrigin, (eventCallback_t1) idEntity::Event_SetWorldOrigin); - eventCallbacks.put(EV_GetOrigin, (eventCallback_t0) idEntity::Event_GetOrigin); - eventCallbacks.put(EV_SetOrigin, (eventCallback_t1) idEntity::Event_SetOrigin); - eventCallbacks.put(EV_GetAngles, (eventCallback_t0) idEntity::Event_GetAngles); - eventCallbacks.put(EV_SetAngles, (eventCallback_t1) idEntity::Event_SetAngles); - eventCallbacks.put(EV_GetLinearVelocity, (eventCallback_t0) idEntity::Event_GetLinearVelocity); - eventCallbacks.put(EV_SetLinearVelocity, (eventCallback_t1) idEntity::Event_SetLinearVelocity); - eventCallbacks.put(EV_GetAngularVelocity, (eventCallback_t0) idEntity::Event_GetAngularVelocity); - eventCallbacks.put(EV_SetAngularVelocity, (eventCallback_t1) idEntity::Event_SetAngularVelocity); - eventCallbacks.put(EV_GetSize, (eventCallback_t0) idEntity::Event_GetSize); - eventCallbacks.put(EV_SetSize, (eventCallback_t2) idEntity::Event_SetSize); - eventCallbacks.put(EV_GetMins, (eventCallback_t0) idEntity::Event_GetMins); - eventCallbacks.put(EV_GetMaxs, (eventCallback_t0) idEntity::Event_GetMaxs); - eventCallbacks.put(EV_Touches, (eventCallback_t1) idEntity::Event_Touches); - eventCallbacks.put(EV_SetGuiParm, (eventCallback_t2) idEntity::Event_SetGuiParm); - eventCallbacks.put(EV_SetGuiFloat, (eventCallback_t2) idEntity::Event_SetGuiFloat); - eventCallbacks.put(EV_GetNextKey, (eventCallback_t2) idEntity::Event_GetNextKey); - eventCallbacks.put(EV_SetKey, (eventCallback_t2) idEntity::Event_SetKey); - eventCallbacks.put(EV_GetKey, (eventCallback_t1) idEntity::Event_GetKey); - eventCallbacks.put(EV_GetIntKey, (eventCallback_t1) idEntity::Event_GetIntKey); - eventCallbacks.put(EV_GetFloatKey, (eventCallback_t1) idEntity::Event_GetFloatKey); - eventCallbacks.put(EV_GetVectorKey, (eventCallback_t1) idEntity::Event_GetVectorKey); - eventCallbacks.put(EV_GetEntityKey, (eventCallback_t1) idEntity::Event_GetEntityKey); - eventCallbacks.put(EV_RestorePosition, (eventCallback_t0) idEntity::Event_RestorePosition); - eventCallbacks.put(EV_UpdateCameraTarget, (eventCallback_t0) idEntity::Event_UpdateCameraTarget); - eventCallbacks.put(EV_DistanceTo, (eventCallback_t1) idEntity::Event_DistanceTo); - eventCallbacks.put(EV_DistanceToPoint, (eventCallback_t1) idEntity::Event_DistanceToPoint); - eventCallbacks.put(EV_StartFx, (eventCallback_t1) idEntity::Event_StartFx); -// eventCallbacks.put(EV_Thread_WaitFrame, (eventCallback_t0) idEntity::Event_WaitFrame); -// eventCallbacks.put(EV_Thread_Wait, (eventCallback_t0) idEntity::Event_Wait); -// eventCallbacks.put(EV_HasFunction, (eventCallback_t0) idEntity::Event_HasFunction); -// eventCallbacks.put(EV_CallFunction, (eventCallback_t0) idEntity::Event_CallFunction); -// eventCallbacks.put(EV_SetNeverDormant, (eventCallback_t0) idEntity::Event_SetNeverDormant); - } - // Think flags //enum { public static final int TH_ALL = -1; @@ -345,7 +275,73 @@ public static class signalList_t { } public static class idEntity extends neo.Game.GameSys.Class.idClass implements neo.TempDump.NiLLABLE, neo.TempDump.SERiAL { -// ABSTRACT_PROTOTYPE( idEntity ); + // ABSTRACT_PROTOTYPE( idEntity ); + protected static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_GetName, (eventCallback_t0) idEntity::Event_GetName); + eventCallbacks.put(EV_SetName, (eventCallback_t1) idEntity::Event_SetName); + eventCallbacks.put(EV_FindTargets, (eventCallback_t0) idEntity::Event_FindTargets); + eventCallbacks.put(EV_ActivateTargets, (eventCallback_t1) idEntity::Event_ActivateTargets); + eventCallbacks.put(EV_NumTargets, (eventCallback_t0) idEntity::Event_NumTargets); + eventCallbacks.put(EV_GetTarget, (eventCallback_t1) idEntity::Event_GetTarget); + eventCallbacks.put(EV_RandomTarget, (eventCallback_t1) idEntity::Event_RandomTarget); + eventCallbacks.put(EV_BindToJoint, (eventCallback_t3) idEntity::Event_BindToJoint); + eventCallbacks.put(EV_RemoveBinds, (eventCallback_t0) idEntity::Event_RemoveBinds); + eventCallbacks.put(EV_Bind, (eventCallback_t1) idEntity::Event_Bind); + eventCallbacks.put(EV_BindPosition, (eventCallback_t1) idEntity::Event_BindPosition); + eventCallbacks.put(EV_Unbind, (eventCallback_t0) idEntity::Event_Unbind); + eventCallbacks.put(EV_SpawnBind, (eventCallback_t0) idEntity::Event_SpawnBind); + eventCallbacks.put(EV_SetOwner, (eventCallback_t1) idEntity::Event_SetOwner); + eventCallbacks.put(EV_SetModel, (eventCallback_t1) idEntity::Event_SetModel); + eventCallbacks.put(EV_SetSkin, (eventCallback_t1) idEntity::Event_SetSkin); + eventCallbacks.put(EV_GetShaderParm, (eventCallback_t1) idEntity::Event_GetShaderParm); + eventCallbacks.put(EV_SetShaderParm, (eventCallback_t2) idEntity::Event_SetShaderParm); + eventCallbacks.put(EV_SetShaderParms, (eventCallback_t4) idEntity::Event_SetShaderParms); + eventCallbacks.put(EV_SetColor, (eventCallback_t3) idEntity::Event_SetColor); + eventCallbacks.put(EV_GetColor, (eventCallback_t0) idEntity::Event_GetColor); + eventCallbacks.put(EV_IsHidden, (eventCallback_t0) idEntity::Event_IsHidden); + eventCallbacks.put(EV_Hide, (eventCallback_t0) idEntity::Event_Hide); + eventCallbacks.put(EV_Show, (eventCallback_t0) idEntity::Event_Show); + eventCallbacks.put(EV_CacheSoundShader, (eventCallback_t1) idEntity::Event_CacheSoundShader); + eventCallbacks.put(EV_StartSoundShader, (eventCallback_t2) idEntity::Event_StartSoundShader); + eventCallbacks.put(EV_StartSound, (eventCallback_t3) idEntity::Event_StartSound); + eventCallbacks.put(EV_StopSound, (eventCallback_t2) idEntity::Event_StopSound); + eventCallbacks.put(EV_FadeSound, (eventCallback_t3) idEntity::Event_FadeSound); + eventCallbacks.put(EV_GetWorldOrigin, (eventCallback_t0) idEntity::Event_GetWorldOrigin); + eventCallbacks.put(EV_SetWorldOrigin, (eventCallback_t1) idEntity::Event_SetWorldOrigin); + eventCallbacks.put(EV_GetOrigin, (eventCallback_t0) idEntity::Event_GetOrigin); + eventCallbacks.put(EV_SetOrigin, (eventCallback_t1) idEntity::Event_SetOrigin); + eventCallbacks.put(EV_GetAngles, (eventCallback_t0) idEntity::Event_GetAngles); + eventCallbacks.put(EV_SetAngles, (eventCallback_t1) idEntity::Event_SetAngles); + eventCallbacks.put(EV_GetLinearVelocity, (eventCallback_t0) idEntity::Event_GetLinearVelocity); + eventCallbacks.put(EV_SetLinearVelocity, (eventCallback_t1) idEntity::Event_SetLinearVelocity); + eventCallbacks.put(EV_GetAngularVelocity, (eventCallback_t0) idEntity::Event_GetAngularVelocity); + eventCallbacks.put(EV_SetAngularVelocity, (eventCallback_t1) idEntity::Event_SetAngularVelocity); + eventCallbacks.put(EV_GetSize, (eventCallback_t0) idEntity::Event_GetSize); + eventCallbacks.put(EV_SetSize, (eventCallback_t2) idEntity::Event_SetSize); + eventCallbacks.put(EV_GetMins, (eventCallback_t0) idEntity::Event_GetMins); + eventCallbacks.put(EV_GetMaxs, (eventCallback_t0) idEntity::Event_GetMaxs); + eventCallbacks.put(EV_Touches, (eventCallback_t1) idEntity::Event_Touches); + eventCallbacks.put(EV_SetGuiParm, (eventCallback_t2) idEntity::Event_SetGuiParm); + eventCallbacks.put(EV_SetGuiFloat, (eventCallback_t2) idEntity::Event_SetGuiFloat); + eventCallbacks.put(EV_GetNextKey, (eventCallback_t2) idEntity::Event_GetNextKey); + eventCallbacks.put(EV_SetKey, (eventCallback_t2) idEntity::Event_SetKey); + eventCallbacks.put(EV_GetKey, (eventCallback_t1) idEntity::Event_GetKey); + eventCallbacks.put(EV_GetIntKey, (eventCallback_t1) idEntity::Event_GetIntKey); + eventCallbacks.put(EV_GetFloatKey, (eventCallback_t1) idEntity::Event_GetFloatKey); + eventCallbacks.put(EV_GetVectorKey, (eventCallback_t1) idEntity::Event_GetVectorKey); + eventCallbacks.put(EV_GetEntityKey, (eventCallback_t1) idEntity::Event_GetEntityKey); + eventCallbacks.put(EV_RestorePosition, (eventCallback_t0) idEntity::Event_RestorePosition); + eventCallbacks.put(EV_UpdateCameraTarget, (eventCallback_t0) idEntity::Event_UpdateCameraTarget); + eventCallbacks.put(EV_DistanceTo, (eventCallback_t1) idEntity::Event_DistanceTo); + eventCallbacks.put(EV_DistanceToPoint, (eventCallback_t1) idEntity::Event_DistanceToPoint); + eventCallbacks.put(EV_StartFx, (eventCallback_t1) idEntity::Event_StartFx); +// eventCallbacks.put(EV_Thread_WaitFrame, (eventCallback_t0) idEntity::Event_WaitFrame); +// eventCallbacks.put(EV_Thread_Wait, (eventCallback_t0) idEntity::Event_Wait); +// eventCallbacks.put(EV_HasFunction, (eventCallback_t0) idEntity::Event_HasFunction); +// eventCallbacks.put(EV_CallFunction, (eventCallback_t0) idEntity::Event_CallFunction); +// eventCallbacks.put(EV_SetNeverDormant, (eventCallback_t0) idEntity::Event_SetNeverDormant); + } public static final int MAX_PVS_AREAS = 4; // @@ -385,6 +381,11 @@ public Class.idClass CreateInstance() { return getClass(); } + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } + @Override public idEntity oSet(idEntity node) { throw new UnsupportedOperationException("Not supported yet."); @@ -4238,13 +4239,13 @@ public static class damageEffect_s { public static class idAnimatedEntity extends idEntity { static { - eventCallbacks.put(EV_GetJointHandle, (eventCallback_t1) idAnimatedEntity::Event_GetJointHandle); - eventCallbacks.put(EV_ClearAllJoints, (eventCallback_t0) idAnimatedEntity::Event_ClearAllJoints); - eventCallbacks.put(EV_ClearJoint, (eventCallback_t1) idAnimatedEntity::Event_ClearJoint); - eventCallbacks.put(EV_SetJointPos, (eventCallback_t3) idAnimatedEntity::Event_SetJointPos); - eventCallbacks.put(EV_SetJointAngle, (eventCallback_t3) idAnimatedEntity::Event_SetJointAngle); - eventCallbacks.put(EV_GetJointPos, (eventCallback_t1) idAnimatedEntity::Event_GetJointPos); - eventCallbacks.put(EV_GetJointAngle, (eventCallback_t1) idAnimatedEntity::Event_GetJointAngle); + eventCallbacks.put(EV_GetJointHandle, (eventCallback_t1) idAnimatedEntity::Event_GetJointHandle); + eventCallbacks.put(EV_ClearAllJoints, (eventCallback_t0) idAnimatedEntity::Event_ClearAllJoints); + eventCallbacks.put(EV_ClearJoint, (eventCallback_t1) idAnimatedEntity::Event_ClearJoint); + eventCallbacks.put(EV_SetJointPos, (eventCallback_t3) idAnimatedEntity::Event_SetJointPos); + eventCallbacks.put(EV_SetJointAngle, (eventCallback_t3) idAnimatedEntity::Event_SetJointAngle); + eventCallbacks.put(EV_GetJointPos, (eventCallback_t1) idAnimatedEntity::Event_GetJointPos); + eventCallbacks.put(EV_GetJointAngle, (eventCallback_t1) idAnimatedEntity::Event_GetJointAngle); } // enum { @@ -4615,11 +4616,11 @@ public boolean ClientReceiveEvent(int event, int time, final idBitMsg msg) { looks up the number of the specified joint. returns INVALID_JOINT if the joint is not found. ================ */ - private static void Event_GetJointHandle(idEntity e, final idEventArg jointname) { + private static void Event_GetJointHandle(idAnimatedEntity e, final idEventArg jointname) { // jointHandle_t joint = new jointHandle_t(); int joint; - joint = ((idAnimatedEntity) e).animator.GetJointHandle(jointname.value); + joint = e.animator.GetJointHandle(jointname.value); idThread.ReturnInt(joint); } @@ -4630,8 +4631,8 @@ private static void Event_GetJointHandle(idEntity e, final idEventArg jo removes any custom transforms on all joints ================ */ - private static void Event_ClearAllJoints(idEntity e) { - ((idAnimatedEntity) e).animator.ClearAllJoints(); + private static void Event_ClearAllJoints(idAnimatedEntity e) { + e.animator.ClearAllJoints(); } /* @@ -4641,8 +4642,8 @@ private static void Event_ClearAllJoints(idEntity e) { removes any custom transforms on the specified joint ================ */ - private static void Event_ClearJoint(idEntity e, idEventArg/*jointHandle_t*/ jointnum) { - ((idAnimatedEntity) e).animator.ClearJoint(jointnum.value); + private static void Event_ClearJoint(idAnimatedEntity e, idEventArg/*jointHandle_t*/ jointnum) { + e.animator.ClearJoint(jointnum.value); } /* @@ -4652,8 +4653,8 @@ private static void Event_ClearJoint(idEntity e, idEventArg/*jointHandl modifies the position of the joint based on the transform type ================ */ - private static void Event_SetJointPos(idEntity e, idEventArg/*jointHandle_t*/ jointnum, idEventArg transform_type, final idEventArg pos) { - ((idAnimatedEntity) e).animator.SetJointPos(jointnum.value, transform_type.value, pos.value); + private static void Event_SetJointPos(idAnimatedEntity e, idEventArg/*jointHandle_t*/ jointnum, idEventArg transform_type, final idEventArg pos) { + e.animator.SetJointPos(jointnum.value, transform_type.value, pos.value); } /* @@ -4663,11 +4664,11 @@ private static void Event_SetJointPos(idEntity e, idEventArg/*jointHand modifies the orientation of the joint based on the transform type ================ */ - private static void Event_SetJointAngle(idEntity e, idEventArg/*jointHandle_t*/ jointnum, idEventArg transform_type, final idEventArg angles) { + private static void Event_SetJointAngle(idAnimatedEntity e, idEventArg/*jointHandle_t*/ jointnum, idEventArg transform_type, final idEventArg angles) { idMat3 mat; mat = angles.value.ToMat3(); - ((idAnimatedEntity) e).animator.SetJointAxis(jointnum.value, transform_type.value, mat); + e.animator.SetJointAxis(jointnum.value, transform_type.value, mat); } /* @@ -4677,11 +4678,11 @@ private static void Event_SetJointAngle(idEntity e, idEventArg/*jointHa returns the position of the joint in worldspace ================ */ - private static void Event_GetJointPos(idEntity e, idEventArg/*jointHandle_t*/ jointnum) { + private static void Event_GetJointPos(idAnimatedEntity e, idEventArg/*jointHandle_t*/ jointnum) { idVec3 offset = new idVec3(); idMat3 axis = new idMat3(); - if (!((idAnimatedEntity) e).GetJointWorldTransform(jointnum.value, gameLocal.time, offset, axis)) { + if (!e.GetJointWorldTransform(jointnum.value, gameLocal.time, offset, axis)) { gameLocal.Warning("Joint # %d out of range on entity '%s'", jointnum, e.name); } @@ -4696,11 +4697,11 @@ private static void Event_GetJointPos(idEntity e, idEventArg/*jointHand returns the orientation of the joint in worldspace ================ */ - private static void Event_GetJointAngle(idEntity e, idEventArg/*jointHandle_t*/ jointnum) { + private static void Event_GetJointAngle(idAnimatedEntity e, idEventArg/*jointHandle_t*/ jointnum) { idVec3 offset = new idVec3(); idMat3 axis = new idMat3(); - if (!((idAnimatedEntity) e).GetJointWorldTransform(jointnum.value, gameLocal.time, offset, axis)) { + if (!e.GetJointWorldTransform(jointnum.value, gameLocal.time, offset, axis)) { gameLocal.Warning("Joint # %d out of range on entity '%s'", jointnum, e.name); } diff --git a/src/main/java/neo/Game/GameSys/Class.java b/src/main/java/neo/Game/GameSys/Class.java index 84ea004f..76cdcace 100644 --- a/src/main/java/neo/Game/GameSys/Class.java +++ b/src/main/java/neo/Game/GameSys/Class.java @@ -49,59 +49,79 @@ public class Class { static int eventCallbackMemory = 0; @FunctionalInterface - public interface eventCallback_t { - void accept(idEntity e, idEventArg...args); + public interface eventCallback_t { + void accept(T t, idEventArg...args); } @FunctionalInterface - public interface eventCallback_t0 extends eventCallback_t { + public interface eventCallback_t0 extends eventCallback_t { @Override - default void accept(idEntity e, idEventArg... args) { - accept(e); + default void accept(T t, idEventArg... args) { + accept(t); } - void accept(idEntity e); + void accept(T e); } @FunctionalInterface - public interface eventCallback_t1 extends eventCallback_t { + public interface eventCallback_t1 extends eventCallback_t { @Override - default void accept(idEntity e, idEventArg... args) { - accept(e, args[0]); + default void accept(T t, idEventArg... args) { + accept(t, args[0]); } - void accept(idEntity e, idEventArg a); + void accept(T t, idEventArg a); } @FunctionalInterface - public interface eventCallback_t2 extends eventCallback_t { + public interface eventCallback_t2 extends eventCallback_t { @Override - default void accept(idEntity e, idEventArg... args) { - accept(e, args[0], args[1]); + default void accept(T t, idEventArg... args) { + accept(t, args[0], args[1]); } - void accept(idEntity e, idEventArg a, idEventArg b); + void accept(T t, idEventArg a, idEventArg b); } @FunctionalInterface - public interface eventCallback_t3 extends eventCallback_t { + public interface eventCallback_t3 extends eventCallback_t { @Override - default void accept(idEntity e, idEventArg... args) { - accept(e, args[0], args[1], args[2]); + default void accept(T t, idEventArg... args) { + accept(t, args[0], args[1], args[2]); } - void accept(idEntity e, idEventArg a, idEventArg b, idEventArg c); + void accept(T t, idEventArg a, idEventArg b, idEventArg c); } @FunctionalInterface - public interface eventCallback_t4 extends eventCallback_t { + public interface eventCallback_t4 extends eventCallback_t { @Override - default void accept(idEntity e, idEventArg... args) { - accept(e, args[0], args[1], args[2], args[3]); + default void accept(T t, idEventArg... args) { + accept(t, args[0], args[1], args[2], args[3]); } - void accept(idEntity e, idEventArg a, idEventArg b, idEventArg c, idEventArg d); + void accept(T t, idEventArg a, idEventArg b, idEventArg c, idEventArg d); + } + + @FunctionalInterface + public interface eventCallback_t5 extends eventCallback_t { + @Override + default void accept(T t, idEventArg... args) { + accept(t, args[0], args[1], args[2], args[3], args[4]); + } + + void accept(T t, idEventArg a, idEventArg b, idEventArg c, idEventArg d, idEventArg e); + } + + @FunctionalInterface + public interface eventCallback_t6 extends eventCallback_t { + @Override + default void accept(T t, idEventArg... args) { + accept(t, args[0], args[1], args[2], args[3], args[4], args[5]); + } + + void accept(T t, idEventArg a, idEventArg b, idEventArg c, idEventArg d, idEventArg e, idEventArg f); } public static abstract class classSpawnFunc_t { @@ -220,6 +240,8 @@ public static abstract class idClass/**/ { public abstract java.lang.Class/*idTypeInfo*/ GetType(); + public abstract eventCallback_t getEventCallBack(idEventDef event); + // #ifdef ID_REDIRECT_NEWDELETE // #undef new // #endif @@ -770,7 +792,7 @@ private classSpawnFunc_t CallSpawnFunc(idTypeInfo cls) { } private boolean PostEventArgs(final idEventDef ev, int time, int numargs, idEventArg... args) { - idTypeInfo c; + java.lang.Class c; idEvent event; // va_list args; @@ -781,11 +803,11 @@ private boolean PostEventArgs(final idEventDef ev, int time, int numargs, idEven } //TODO:disabled for medicinal reasons -// c = GetType(); -// if (NOT(c.eventMap[ev.GetEventNum()])) { -// // we don't respond to this event, so ignore it -// return false; -// } + c = this.getClass(); + if (NOT(this.getEventCallBack(ev))) { + // we don't respond to this event, so ignore it + return false; + } // we service events on the client to avoid any bad code filling up the event pool // we don't want them processed usually, unless when the map is (re)loading. @@ -799,7 +821,7 @@ private boolean PostEventArgs(final idEventDef ev, int time, int numargs, idEven // va_end(args); //TODO:same as line #755 -// event.Schedule(this, c, time); + event.Schedule(this, c, time); return true; } diff --git a/src/main/java/neo/Game/GameSys/Event.java b/src/main/java/neo/Game/GameSys/Event.java index 98879462..c397dc47 100644 --- a/src/main/java/neo/Game/GameSys/Event.java +++ b/src/main/java/neo/Game/GameSys/Event.java @@ -1,6 +1,5 @@ package neo.Game.GameSys; -import java.nio.ByteBuffer; import neo.CM.CollisionModel.contactType_t; import neo.CM.CollisionModel.trace_s; import neo.Game.AFEntity; @@ -10,15 +9,11 @@ import neo.Game.Actor; import neo.Game.Camera; import neo.Game.Entity; -import neo.Game.Entity.idEntity; import neo.Game.FX; import neo.Game.GameSys.Class.idClass; import neo.Game.GameSys.Class.idEventArg; -import neo.Game.GameSys.Class.idTypeInfo; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; -import static neo.Game.Game_local.gameLocal; -import neo.Game.Game_local.idEntityPtr; import neo.Game.Item; import neo.Game.Light; import neo.Game.Misc; @@ -26,22 +21,24 @@ import neo.Game.Mover; import neo.Game.Player; import neo.Game.Projectile; -import static neo.Game.Script.Script_Program.MAX_STRING_LEN; import neo.Game.Script.Script_Thread; import neo.Game.SecurityCamera; import neo.Game.Sound; import neo.Game.Target; import neo.Game.Trigger; import neo.Game.Weapon; -import neo.Renderer.Material.idMaterial; import neo.TempDump.CPP_class; -import static neo.TempDump.btoi; -import static neo.TempDump.etoi; -import static neo.TempDump.sizeof; +import neo.TempDump.TODO_Exception; import neo.idlib.Text.Str.idStr; import neo.idlib.containers.LinkList.idLinkList; import neo.idlib.math.Vector.idVec3; +import java.nio.ByteBuffer; + +import static neo.Game.Game_local.gameLocal; +import static neo.Game.Script.Script_Program.MAX_STRING_LEN; +import static neo.TempDump.etoi; + /** * */ @@ -298,6 +295,22 @@ public static idEventDef FindEvent(final String name) { return null; } + + @Override + public int hashCode() { + return eventnum; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + idEventDef that = (idEventDef) o; + + return eventnum == that.eventnum; + + } }; /* ********************************************************************** @@ -307,11 +320,11 @@ public static idEventDef FindEvent(final String name) { ***********************************************************************/ public static class idEvent { - private idEventDef eventdef; - private Object[] data; - private int time; - private idClass object; - private idTypeInfo typeinfo; + private idEventDef eventdef; + private idEventArg[] data; + private int time; + private idClass object; + private java.lang.Class typeinfo; // private idLinkList eventNode = new idLinkList<>(); // @@ -347,42 +360,42 @@ public static idEvent Alloc(final idEventDef evdef, int numargs, idEventArg... a if (size != 0) { // ev.data = eventDataAllocator.Alloc( size ); // memset( ev.data, 0, size ); - ev.data = new Object[size]; + ev.data = args.clone(); } else { ev.data = null; } format = evdef.GetArgFormat(); - for (i = 0; i < numargs; i++) { - for (idEventArg arg : args) { -// arg = va_arg(args, idEventArg); - if (format.charAt(i) != arg.type) { - // when NULL is passed in for an entity, it gets cast as an integer 0, so don't give an error when it happens - if (!(((format.charAt(i) == D_EVENT_TRACE) || (format.charAt(i) == D_EVENT_ENTITY)) && (arg.type == 'd') && (arg.value == Integer.valueOf(0)))) { - gameLocal.Error("idEvent::Alloc : Wrong type passed in for arg # %d on '%s' event.", i, evdef.GetName()); - } - } - - switch (format.charAt(i)) {//TODO:S - case D_EVENT_FLOAT: - case D_EVENT_INTEGER: - ev.data[i] = arg.value; - break; - case D_EVENT_VECTOR: - if (arg.value != null) { - ev.data[i] = arg.value; - } - break; - case D_EVENT_STRING: - if (arg.value != null) { - ev.data[i] = (String) arg.value; - } - break; - case D_EVENT_ENTITY: - case D_EVENT_ENTITY_NULL: - ev.data[i] = new idEntityPtr((idEntity) arg.value); - break; - case D_EVENT_TRACE: +// for (i = 0; i < numargs; i++) { +// for (idEventArg arg : args) { +//// arg = va_arg(args, idEventArg); +// if (format.charAt(i) != arg.type) { +// // when NULL is passed in for an entity, it gets cast as an integer 0, so don't give an error when it happens +// if (!(((format.charAt(i) == D_EVENT_TRACE) || (format.charAt(i) == D_EVENT_ENTITY)) && (arg.type == 'd') && (arg.value == Integer.valueOf(0)))) { +// gameLocal.Error("idEvent::Alloc : Wrong type passed in for arg # %d on '%s' event.", i, evdef.GetName()); +// } +// } +// +// switch (format.charAt(i)) {//TODO:S +// case D_EVENT_FLOAT: +// case D_EVENT_INTEGER: +// ev.data[i] = arg.value; +// break; +// case D_EVENT_VECTOR: +// if (arg.value != null) { +// ev.data[i] = arg.value; +// } +// break; +// case D_EVENT_STRING: +// if (arg.value != null) { +// ev.data[i] = (String) arg.value; +// } +// break; +// case D_EVENT_ENTITY: +// case D_EVENT_ENTITY_NULL: +// ev.data[i] = new idEntityPtr((idEntity) arg.value); +// break; +// case D_EVENT_TRACE: // if ( arg.value!=null ) { // *reinterpret_cast( ev.data[i] ) = true; // *reinterpret_cast( ev.data[i] + sizeof( bool ) ) = *reinterpret_cast( arg.value ); @@ -398,13 +411,13 @@ public static idEvent Alloc(final idEventDef evdef, int numargs, idEventArg... a // } else { // *reinterpret_cast( ev.data[i] ) = false; // } - break; - default: - gameLocal.Error("idEvent::Alloc : Invalid arg format '%s' string for '%s' event.", format, evdef.GetName()); - break; - } - } - } +// break; +// default: +// gameLocal.Error("idEvent::Alloc : Invalid arg format '%s' string for '%s' event.", format, evdef.GetName()); +// break; +// } +// } +// } return ev; } @@ -448,7 +461,7 @@ public void Free() { eventNode.AddToEnd(FreeEvents); } - public void Schedule(idClass obj, final idTypeInfo type, int time) { + public void Schedule(idClass obj, final java.lang.Class type, int time) { idEvent event; assert (initialized); @@ -667,7 +680,7 @@ public static void Save(idSaveGame savefile) { // archives object for save g while (event != null) { savefile.WriteInt(event.time); savefile.WriteString(event.eventdef.GetName()); - savefile.WriteString(event.typeinfo.classname); + savefile.WriteString(event.typeinfo.getSimpleName()); savefile.WriteObject(event.object); savefile.WriteInt(event.eventdef.GetArgSize()); format = event.eventdef.GetArgFormat(); @@ -742,8 +755,9 @@ public static void Restore(idRestoreGame savefile) { // unarchives object fro // read the classtype savefile.ReadString(name); - event.typeinfo = idClass.GetClass(name.toString()); - if (null == event.typeinfo) { + try { + event.typeinfo = java.lang.Class.forName(name.toString()); + } catch (ClassNotFoundException e) { savefile.Error("idEvent::Restore: unknown class '%s' on event '%s'", name.toString(), event.eventdef.GetName()); } @@ -754,56 +768,58 @@ public static void Restore(idRestoreGame savefile) { // unarchives object fro if (argsize[0] != event.eventdef.GetArgSize()) { savefile.Error("idEvent::Restore: arg size (%d) doesn't match saved arg size(%d) on event '%s'", event.eventdef.GetArgSize(), argsize[0], event.eventdef.GetName()); } - if (argsize[0] != 0) { - event.data = new Object[argsize[0]];//eventDataAllocator.Alloc(argsize[0]); - format = event.eventdef.GetArgFormat(); - assert (format != null); - for (j = 0, size = 0; j < event.eventdef.GetNumArgs(); ++j) { - switch (format.charAt(j)) {//TODOS:reint - case D_EVENT_FLOAT: - event.data[j] = savefile.ReadFloat( /*reinterpret_cast( dataPtr )*/); - size += Float.BYTES; - break; - case D_EVENT_INTEGER: - case D_EVENT_ENTITY: - case D_EVENT_ENTITY_NULL: - event.data[j] = savefile.ReadInt( /*reinterpret_cast( dataPtr )*/); - size += Integer.BYTES; - break; - case D_EVENT_VECTOR: - idVec3 buffer = new idVec3(); -// savefile.ReadVec3( *reinterpret_cast( dataPtr ) ); - savefile.ReadVec3(buffer); - event.data[j] = buffer.Write(); - size += idVec3.BYTES; - break; - case D_EVENT_TRACE: - boolean bOOl = savefile.ReadBool( /*reinterpret_cast( dataPtr )*/); - event.data[j] = ((byte) btoi(bOOl)); - size++; -// if ( *reinterpret_cast( dataPtr ) ) { - if (bOOl) { - size += sizeof(trace_s.class); -// trace_s t = *reinterpret_cast( dataPtr + sizeof( bool ) ); - trace_s t = new trace_s(); - RestoreTrace(savefile, t); - event.data[j] = t.Write(); - if (t.c.material != null) { - size += MAX_STRING_LEN; -// str = reinterpret_cast( dataPtr + sizeof( bool ) + sizeof( trace_t ) ); - savefile.Read(str, MAX_STRING_LEN); - event.data[j] = str; - } - } - break; - default: - break; - } - } - assert (size == event.eventdef.GetArgSize()); - } else { - event.data = null; - } + + throw new TODO_Exception(); +// if (argsize[0] != 0) { +// event.data = new Object[argsize[0]];//eventDataAllocator.Alloc(argsize[0]); +// format = event.eventdef.GetArgFormat(); +// assert (format != null); +// for (j = 0, size = 0; j < event.eventdef.GetNumArgs(); ++j) { +// switch (format.charAt(j)) {//TODOS:reint +// case D_EVENT_FLOAT: +// event.data[j] = savefile.ReadFloat( /*reinterpret_cast( dataPtr )*/); +// size += Float.BYTES; +// break; +// case D_EVENT_INTEGER: +// case D_EVENT_ENTITY: +// case D_EVENT_ENTITY_NULL: +// event.data[j] = savefile.ReadInt( /*reinterpret_cast( dataPtr )*/); +// size += Integer.BYTES; +// break; +// case D_EVENT_VECTOR: +// idVec3 buffer = new idVec3(); +//// savefile.ReadVec3( *reinterpret_cast( dataPtr ) ); +// savefile.ReadVec3(buffer); +// event.data[j] = buffer.Write(); +// size += idVec3.BYTES; +// break; +// case D_EVENT_TRACE: +// boolean bOOl = savefile.ReadBool( /*reinterpret_cast( dataPtr )*/); +// event.data[j] = ((byte) btoi(bOOl)); +// size++; +//// if ( *reinterpret_cast( dataPtr ) ) { +// if (bOOl) { +// size += sizeof(trace_s.class); +//// trace_s t = *reinterpret_cast( dataPtr + sizeof( bool ) ); +// trace_s t = new trace_s(); +// RestoreTrace(savefile, t); +// event.data[j] = t.Write(); +// if (t.c.material != null) { +// size += MAX_STRING_LEN; +//// str = reinterpret_cast( dataPtr + sizeof( bool ) + sizeof( trace_t ) ); +// savefile.Read(str, MAX_STRING_LEN); +// event.data[j] = str; +// } +// } +// break; +// default: +// break; +// } +// } +// assert (size == event.eventdef.GetArgSize()); +// } else { +// event.data = null; +// } } } diff --git a/src/main/java/neo/Game/Physics/Force.java b/src/main/java/neo/Game/Physics/Force.java index baa5feb7..35574a97 100644 --- a/src/main/java/neo/Game/Physics/Force.java +++ b/src/main/java/neo/Game/Physics/Force.java @@ -1,7 +1,8 @@ package neo.Game.Physics; -import neo.Game.GameSys.Class; +import neo.Game.GameSys.Class.eventCallback_t; import neo.Game.GameSys.Class.idClass; +import neo.Game.GameSys.Event.idEventDef; import neo.Game.Physics.Physics.idPhysics; import neo.idlib.containers.List.idList; @@ -63,6 +64,11 @@ public idClass CreateInstance() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return null; + } + @Override public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. diff --git a/src/main/java/neo/Game/Physics/Physics.java b/src/main/java/neo/Game/Physics/Physics.java index a1cf8637..73dd55d0 100644 --- a/src/main/java/neo/Game/Physics/Physics.java +++ b/src/main/java/neo/Game/Physics/Physics.java @@ -3,7 +3,9 @@ import neo.CM.CollisionModel.contactInfo_t; import neo.CM.CollisionModel.trace_s; import neo.Game.Entity.idEntity; +import neo.Game.GameSys.Class.eventCallback_t; import neo.Game.GameSys.Class.idClass; +import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; import neo.Game.Physics.Clip.idClipModel; @@ -327,5 +329,10 @@ public idVec3 GetAngularVelocity() { public abstract void WriteToSnapshot(idBitMsgDelta msg); public abstract void ReadFromSnapshot(final idBitMsgDelta msg); + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return null; + } }; } diff --git a/src/main/java/neo/Game/Script/Script_Thread.java b/src/main/java/neo/Game/Script/Script_Thread.java index 66f8c670..5cc4cda2 100644 --- a/src/main/java/neo/Game/Script/Script_Thread.java +++ b/src/main/java/neo/Game/Script/Script_Thread.java @@ -5,10 +5,21 @@ import neo.Game.Camera.idCamera; import static neo.Game.Entity.EV_Activate; import neo.Game.Entity.idEntity; + +import static neo.Game.Entity.EV_CacheSoundShader; +import static neo.Game.Entity.EV_SetShaderParm; import static neo.Game.Entity.signalNum_t.NUM_SIGNALS; import static neo.Game.Entity.signalNum_t.SIG_TRIGGER; -import static neo.Game.GameSys.Class.EV_Remove; +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.eventCallback_t2; +import neo.Game.GameSys.Class.eventCallback_t3; +import neo.Game.GameSys.Class.eventCallback_t4; +import neo.Game.GameSys.Class.eventCallback_t5; +import neo.Game.GameSys.Class.eventCallback_t6; import neo.Game.GameSys.Class.idClass; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -48,6 +59,9 @@ import neo.idlib.math.Vector.idVec3; import neo.idlib.math.Vector.idVec4; +import java.util.HashMap; +import java.util.Map; + /** * */ @@ -136,9 +150,89 @@ public class Script_Thread { public static class idThread extends idClass { public static final int BYTES = Integer.BYTES * 14;//TODO + protected static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Thread_Execute, (eventCallback_t0) idThread::Event_Execute); + eventCallbacks.put(EV_Thread_TerminateThread, (eventCallback_t1) idThread::Event_TerminateThread); + eventCallbacks.put(EV_Thread_Pause, (eventCallback_t0) idThread::Event_Pause); + eventCallbacks.put(EV_Thread_Wait, (eventCallback_t1) idThread::Event_Wait); + eventCallbacks.put(EV_Thread_WaitFrame, (eventCallback_t0) idThread::Event_WaitFrame); + eventCallbacks.put(EV_Thread_WaitFor, (eventCallback_t1) idThread::Event_WaitFor); + eventCallbacks.put(EV_Thread_WaitForThread, (eventCallback_t1) idThread::Event_WaitForThread); + eventCallbacks.put(EV_Thread_Print, (eventCallback_t1) idThread::Event_Print); + eventCallbacks.put(EV_Thread_PrintLn, (eventCallback_t1) idThread::Event_PrintLn); + eventCallbacks.put(EV_Thread_Say, (eventCallback_t1) idThread::Event_Say); + eventCallbacks.put(EV_Thread_Assert, (eventCallback_t1) idThread::Event_Assert); + eventCallbacks.put(EV_Thread_Trigger, (eventCallback_t1) idThread::Event_Trigger); + eventCallbacks.put(EV_Thread_SetCvar, (eventCallback_t2) idThread::Event_SetCvar); + eventCallbacks.put(EV_Thread_GetCvar, (eventCallback_t1) idThread::Event_GetCvar); + eventCallbacks.put(EV_Thread_Random, (eventCallback_t1) idThread::Event_Random); + eventCallbacks.put(EV_Thread_GetTime, (eventCallback_t0) idThread::Event_GetTime); + eventCallbacks.put(EV_Thread_KillThread, (eventCallback_t1) idThread::Event_KillThread); + eventCallbacks.put(EV_Thread_SetThreadName, (eventCallback_t1) idThread::Event_SetThreadName); + eventCallbacks.put(EV_Thread_GetEntity, (eventCallback_t1) idThread::Event_GetEntity); + eventCallbacks.put(EV_Thread_Spawn, (eventCallback_t1) idThread::Event_Spawn); + eventCallbacks.put(EV_Thread_CopySpawnArgs, (eventCallback_t1) idThread::Event_CopySpawnArgs); + eventCallbacks.put(EV_Thread_SetSpawnArg, (eventCallback_t2) idThread::Event_SetSpawnArg); + eventCallbacks.put(EV_Thread_SpawnString, (eventCallback_t2) idThread::Event_SpawnString); + eventCallbacks.put(EV_Thread_SpawnFloat, (eventCallback_t2) idThread::Event_SpawnFloat); + eventCallbacks.put(EV_Thread_SpawnVector, (eventCallback_t2) idThread::Event_SpawnVector); + eventCallbacks.put(EV_Thread_ClearPersistantArgs, (eventCallback_t0) idThread::Event_ClearPersistantArgs); + eventCallbacks.put(EV_Thread_SetPersistantArg, (eventCallback_t2) idThread::Event_SetPersistantArg); + eventCallbacks.put(EV_Thread_GetPersistantString, (eventCallback_t1) idThread::Event_GetPersistantString); + eventCallbacks.put(EV_Thread_GetPersistantFloat, (eventCallback_t1) idThread::Event_GetPersistantFloat); + eventCallbacks.put(EV_Thread_GetPersistantVector, (eventCallback_t1) idThread::Event_GetPersistantVector); + eventCallbacks.put(EV_Thread_AngToForward, (eventCallback_t1) idThread::Event_AngToForward); + eventCallbacks.put(EV_Thread_AngToRight, (eventCallback_t1) idThread::Event_AngToRight); + eventCallbacks.put(EV_Thread_AngToUp, (eventCallback_t1) idThread::Event_AngToUp); + eventCallbacks.put(EV_Thread_Sine, (eventCallback_t1) idThread::Event_GetSine); + eventCallbacks.put(EV_Thread_Cosine, (eventCallback_t1) idThread::Event_GetCosine); + eventCallbacks.put(EV_Thread_SquareRoot, (eventCallback_t1) idThread::Event_GetSquareRoot); + eventCallbacks.put(EV_Thread_Normalize, (eventCallback_t1) idThread::Event_VecNormalize); + eventCallbacks.put(EV_Thread_VecLength, (eventCallback_t1) idThread::Event_VecLength); + eventCallbacks.put(EV_Thread_VecDotProduct, (eventCallback_t2) idThread::Event_VecDotProduct); + eventCallbacks.put(EV_Thread_VecCrossProduct, (eventCallback_t2) idThread::Event_VecCrossProduct); + eventCallbacks.put(EV_Thread_VecToAngles, (eventCallback_t1) idThread::Event_VecToAngles); + eventCallbacks.put(EV_Thread_OnSignal, (eventCallback_t3) idThread::Event_OnSignal); + eventCallbacks.put(EV_Thread_ClearSignal, (eventCallback_t2) idThread::Event_ClearSignalThread); + eventCallbacks.put(EV_Thread_SetCamera, (eventCallback_t1) idThread::Event_SetCamera); + eventCallbacks.put(EV_Thread_FirstPerson, (eventCallback_t0) idThread::Event_FirstPerson); + eventCallbacks.put(EV_Thread_Trace, (eventCallback_t6) idThread::Event_Trace); + eventCallbacks.put(EV_Thread_TracePoint, (eventCallback_t4) idThread::Event_TracePoint); + eventCallbacks.put(EV_Thread_GetTraceFraction, (eventCallback_t0) idThread::Event_GetTraceFraction); + eventCallbacks.put(EV_Thread_GetTraceEndPos, (eventCallback_t0) idThread::Event_GetTraceEndPos); + eventCallbacks.put(EV_Thread_GetTraceNormal, (eventCallback_t0) idThread::Event_GetTraceNormal); + eventCallbacks.put(EV_Thread_GetTraceEntity, (eventCallback_t0) idThread::Event_GetTraceEntity); + eventCallbacks.put(EV_Thread_GetTraceJoint, (eventCallback_t0) idThread::Event_GetTraceJoint); + eventCallbacks.put(EV_Thread_GetTraceBody, (eventCallback_t0) idThread::Event_GetTraceBody); + eventCallbacks.put(EV_Thread_FadeIn, (eventCallback_t2) idThread::Event_FadeIn); + eventCallbacks.put(EV_Thread_FadeOut, (eventCallback_t2) idThread::Event_FadeOut); + eventCallbacks.put(EV_Thread_FadeTo, (eventCallback_t3) idThread::Event_FadeTo); + eventCallbacks.put(EV_SetShaderParm, (eventCallback_t2) idThread::Event_SetShaderParm); + eventCallbacks.put(EV_Thread_StartMusic, (eventCallback_t1) idThread::Event_StartMusic); + eventCallbacks.put(EV_Thread_Warning, (eventCallback_t1) idThread::Event_Warning); + eventCallbacks.put(EV_Thread_Error, (eventCallback_t1) idThread::Event_Error); + eventCallbacks.put(EV_Thread_StrLen, (eventCallback_t1) idThread::Event_StrLen); + eventCallbacks.put(EV_Thread_StrLeft, (eventCallback_t2) idThread::Event_StrLeft); + eventCallbacks.put(EV_Thread_StrRight, (eventCallback_t2) idThread::Event_StrRight); + eventCallbacks.put(EV_Thread_StrSkip, (eventCallback_t2) idThread::Event_StrSkip); + eventCallbacks.put(EV_Thread_StrMid, (eventCallback_t3) idThread::Event_StrMid); + eventCallbacks.put(EV_Thread_StrToFloat, (eventCallback_t1) idThread::Event_StrToFloat); + eventCallbacks.put(EV_Thread_RadiusDamage, (eventCallback_t6) idThread::Event_RadiusDamage); + eventCallbacks.put(EV_Thread_IsClient, (eventCallback_t0) idThread::Event_IsClient); + eventCallbacks.put(EV_Thread_IsMultiplayer, (eventCallback_t0) idThread::Event_IsMultiplayer); + eventCallbacks.put(EV_Thread_GetFrameTime, (eventCallback_t0) idThread::Event_GetFrameTime); + eventCallbacks.put(EV_Thread_GetTicsPerSecond, (eventCallback_t0) idThread::Event_GetTicsPerSecond); + eventCallbacks.put(EV_CacheSoundShader, (eventCallback_t1) idThread::Event_CacheSoundShader); + eventCallbacks.put(EV_Thread_DebugLine, (eventCallback_t4) idThread::Event_DebugLine); + eventCallbacks.put(EV_Thread_DebugArrow, (eventCallback_t5) idThread::Event_DebugArrow); + eventCallbacks.put(EV_Thread_DebugCircle, (eventCallback_t6) idThread::Event_DebugCircle); + eventCallbacks.put(EV_Thread_DebugBounds, (eventCallback_t4) idThread::Event_DebugBounds); + eventCallbacks.put(EV_Thread_DrawText, (eventCallback_t6) idThread::Event_DrawText); + eventCallbacks.put(EV_Thread_InfluenceActive, (eventCallback_t0) idThread::Event_InfluenceActive); + } // // CLASS_PROTOTYPE( idThread ); // public static final idTypeInfo Type = new idTypeInfo(null, null, eventCallbacks, null, null, null, null); -// public idEventFunc[] eventcallbacks; // // private static idThread currentThread; @@ -192,78 +286,80 @@ private void Pause() { interpreter.doneProcessing = true; } - private void Event_Execute() { - Execute(); + private static void Event_Execute(idThread t) { + t.Execute(); } - private void Event_SetThreadName(final String name) { - SetThreadName(name); + private static void Event_SetThreadName(idThread t, final idEventArg name) { + t.SetThreadName(name.value); } // // script callable Events // - private void Event_TerminateThread(int num) { + private static void Event_TerminateThread(idThread t, idEventArg num) { idThread thread; - thread = GetThread(num); - KillThread(num); + thread = t.GetThread(num.value); + t.KillThread(num.value); } - private void Event_Pause() { - Pause(); + private static void Event_Pause(idThread t) { + t.Pause(); } - private void Event_Wait(float time) { - WaitSec(time); + private static void Event_Wait(idThread t, idEventArg time) { + t.WaitSec(time.value); } - private void Event_WaitFrame() { - WaitFrame(); + private static void Event_WaitFrame(idThread t) { + t.WaitFrame(); } - private void Event_WaitFor(idEntity ent) { + private static void Event_WaitFor(idThread t, idEventArg e) { + idEntity ent = e.value; if (ent != null && ent.RespondsTo(EV_Thread_SetCallback)) { ent.ProcessEvent(EV_Thread_SetCallback); if (gameLocal.program.GetReturnedInteger() != 0) { - Pause(); - waitingFor = ent.entityNumber; + t.Pause(); + t.waitingFor = ent.entityNumber; } } } - private void Event_WaitForThread(int num) { + private static void Event_WaitForThread(idThread t, idEventArg num) { idThread thread; - thread = GetThread(num); + thread = GetThread(num.value); if (null == thread) { if (g_debugScript.GetBool()) { // just print a warning and continue executing - Warning("Thread %d not running", num); + t.Warning("Thread %d not running", num.value); } } else { - Pause(); - waitingForThread = thread; + t.Pause(); + t.waitingForThread = thread; } } - private void Event_Print(final String text) { - gameLocal.Printf("%s", text); + private static void Event_Print(idThread t, final idEventArg text) { + gameLocal.Printf("%s", text.value); } - private void Event_PrintLn(final String text) { - gameLocal.Printf("%s\n", text); + private static void Event_PrintLn(idThread t, final idEventArg text) { + gameLocal.Printf("%s\n", text.value); } - private void Event_Say(final String text) { - cmdSystem.BufferCommandText(CMD_EXEC_NOW, va("say \"%s\"", text)); + private static void Event_Say(idThread t, final idEventArg text) { + cmdSystem.BufferCommandText(CMD_EXEC_NOW, va("say \"%s\"", text.value)); } - private void Event_Assert(float value) { - assert (value != 0); + private static void Event_Assert(idThread t, idEventArg value) { + assert (value.value != 0); } - private void Event_Trigger(idEntity ent) { + private static void Event_Trigger(idThread t, idEventArg e) { + idEntity ent = e.value; if (ent != null) { ent.Signal(SIG_TRIGGER); ent.ProcessEvent(EV_Activate, gameLocal.GetLocalPlayer()); @@ -271,39 +367,40 @@ private void Event_Trigger(idEntity ent) { } } - private void Event_SetCvar(final String name, final String value) { - cvarSystem.SetCVarString(name, value); + private static void Event_SetCvar(idThread t, final idEventArg name, final idEventArg value) { + cvarSystem.SetCVarString(name.value, value.value); } - private void Event_GetCvar(final String name) { - ReturnString(cvarSystem.GetCVarString(name)); + private static void Event_GetCvar(idThread t, final idEventArg name) { + ReturnString(cvarSystem.GetCVarString(name.value)); } - private void Event_Random(float range) { + private static void Event_Random(idThread t, idEventArg range) { float result; result = gameLocal.random.RandomFloat(); - ReturnFloat(range * result); + ReturnFloat(range.value * result); } - private void Event_GetTime() { + private static void Event_GetTime(idThread t) { ReturnFloat(MS2SEC(gameLocal.realClientTime)); } - private void Event_KillThread(final String name) { - KillThread(name); + private static void Event_KillThread(idThread t, final idEventArg name) { + KillThread(name.value); } - private void Event_GetEntity(final String name) { + private static void Event_GetEntity(idThread t, final idEventArg n) { int entnum; idEntity ent; + String name = n.value; assert (name != null); if (name.charAt(0) == '*') { entnum = Integer.parseInt(name.substring(1)); if ((entnum < 0) || (entnum >= MAX_GENTITIES)) { - Error("Entity number in string out of range."); + t.Error("Entity number in string out of range."); } ReturnEntity(gameLocal.entities[entnum]); } else { @@ -312,210 +409,231 @@ private void Event_GetEntity(final String name) { } } - private void Event_Spawn(final String classname) { + private static void Event_Spawn(idThread t, final idEventArg classname) { idEntity[] ent = {null}; - spawnArgs.Set("classname", classname); - gameLocal.SpawnEntityDef(spawnArgs, ent); + t.spawnArgs.Set("classname", classname.value); + gameLocal.SpawnEntityDef(t.spawnArgs, ent); ReturnEntity(ent[0]); - spawnArgs.Clear(); + t.spawnArgs.Clear(); } - private void Event_CopySpawnArgs(idEntity ent) { - spawnArgs.Copy(ent.spawnArgs); + private static void Event_CopySpawnArgs(idThread t, idEventArg ent) { + t.spawnArgs.Copy(ent.value.spawnArgs); } - private void Event_SetSpawnArg(final String key, final String value) { - spawnArgs.Set(key, value); + private static void Event_SetSpawnArg(idThread t, final idEventArg key, final idEventArg value) { + t.spawnArgs.Set(key.value, value.value); } - private void Event_SpawnString(final String key, final String defaultvalue) { + private static void Event_SpawnString(idThread t, final idEventArg key, final idEventArg defaultvalue) { String[] result = {null}; - spawnArgs.GetString(key, defaultvalue, result); + t.spawnArgs.GetString(key.value, defaultvalue.value, result); ReturnString(result[0]); } - private void Event_SpawnFloat(final String key, float defaultvalue) { + private static void Event_SpawnFloat(idThread t, final idEventArg key, idEventArg defaultvalue) { float[] result = {0}; - spawnArgs.GetFloat(key, va("%f", defaultvalue), result); + t.spawnArgs.GetFloat(key.value, va("%f", defaultvalue.value), result); ReturnFloat(result[0]); } - private void Event_SpawnVector(final String key, idVec3 defaultvalue) { + private static void Event_SpawnVector(idThread t, final idEventArg key, idEventArg d) { idVec3 result = new idVec3(); + idVec3 defaultvalue = d.value; - spawnArgs.GetVector(key, va("%f %f %f", defaultvalue.x, defaultvalue.y, defaultvalue.z), result); + t.spawnArgs.GetVector(key.value, va("%f %f %f", defaultvalue.x, defaultvalue.y, defaultvalue.z), result); ReturnVector(result); } - private void Event_ClearPersistantArgs() { + private static void Event_ClearPersistantArgs(idThread t) { gameLocal.persistentLevelInfo.Clear(); } - private void Event_SetPersistantArg(final String key, final String value) { - gameLocal.persistentLevelInfo.Set(key, value); + private static void Event_SetPersistantArg(idThread t, final idEventArg key, final idEventArg value) { + gameLocal.persistentLevelInfo.Set(key.value, value.value); } - private void Event_GetPersistantString(final String key) { + private static void Event_GetPersistantString(idThread t, final idEventArg key) { String[] result = {null}; - gameLocal.persistentLevelInfo.GetString(key, "", result); + gameLocal.persistentLevelInfo.GetString(key.value, "", result); ReturnString(result[0]); } - private void Event_GetPersistantFloat(final String key) { + private static void Event_GetPersistantFloat(idThread t, final idEventArg key) { float[] result = {0}; - gameLocal.persistentLevelInfo.GetFloat(key, "0", result); + gameLocal.persistentLevelInfo.GetFloat(key.value, "0", result); ReturnFloat(result[0]); } - private void Event_GetPersistantVector(final String key) { + private static void Event_GetPersistantVector(idThread t, final idEventArg key) { idVec3 result = new idVec3(); - gameLocal.persistentLevelInfo.GetVector(key, "0 0 0", result); + gameLocal.persistentLevelInfo.GetVector(key.value, "0 0 0", result); ReturnVector(result); } - private void Event_AngToForward(idAngles ang) { - ReturnVector(ang.ToForward()); + private static void Event_AngToForward(idThread t, idEventArg ang) { + ReturnVector(ang.value.ToForward()); } - private void Event_AngToRight(idAngles ang) { + private static void Event_AngToRight(idThread t, idEventArg ang) { idVec3 vec = new idVec3(); - ang.ToVectors(null, vec); + ang.value.ToVectors(null, vec); ReturnVector(vec); } - private void Event_AngToUp(idAngles ang) { + private static void Event_AngToUp(idThread t, idEventArg ang) { idVec3 vec = new idVec3(); - ang.ToVectors(null, null, vec); + ang.value.ToVectors(null, null, vec); ReturnVector(vec); } - private void Event_GetSine(float angle) { - ReturnFloat(idMath.Sin(DEG2RAD(angle))); + private static void Event_GetSine(idThread t, idEventArg angle) { + ReturnFloat(idMath.Sin(DEG2RAD(angle.value))); } - private void Event_GetCosine(float angle) { - ReturnFloat(idMath.Cos(DEG2RAD(angle))); + private static void Event_GetCosine(idThread t, idEventArg angle) { + ReturnFloat(idMath.Cos(DEG2RAD(angle.value))); } - private void Event_GetSquareRoot(float theSquare) { - ReturnFloat(idMath.Sqrt(theSquare)); + private static void Event_GetSquareRoot(idThread t, idEventArg theSquare) { + ReturnFloat(idMath.Sqrt(theSquare.value)); } - private void Event_VecNormalize(idVec3 vec) { + private static void Event_VecNormalize(idThread t, idEventArg vec) { idVec3 n; - n = vec; + n = vec.value; n.Normalize(); ReturnVector(n); } - private void Event_VecLength(idVec3 vec) { - ReturnFloat(vec.Length()); + private static void Event_VecLength(idThread t, idEventArg vec) { + ReturnFloat(vec.value.Length()); } - private void Event_VecDotProduct(idVec3 vec1, idVec3 vec2) { - ReturnFloat(vec1.oMultiply(vec2)); + private static void Event_VecDotProduct(idThread t, idEventArg vec1, idEventArg vec2) { + ReturnFloat(vec1.value.oMultiply(vec2.value)); } - private void Event_VecCrossProduct(idVec3 vec1, idVec3 vec2) { - ReturnVector(vec1.Cross(vec2)); + private static void Event_VecCrossProduct(idThread t, idEventArg vec1, idEventArg vec2) { + ReturnVector(vec1.value.Cross(vec2.value)); } - private void Event_VecToAngles(idVec3 vec) { - idAngles ang = vec.ToAngles(); + private static void Event_VecToAngles(idThread t, idEventArg vec) { + idAngles ang = vec.value.ToAngles(); ReturnVector(new idVec3(ang.oGet(0), ang.oGet(1), ang.oGet(2))); } - private void Event_OnSignal(int signal, idEntity ent, final String func) { + private static void Event_OnSignal(idThread t, idEventArg s, idEventArg e, final idEventArg f) { function_t function; + int signal = s.value; + idEntity ent = e.value; + String func = f.value; assert (func != null); if (null == ent) { - Error("Entity not found"); + t.Error("Entity not found"); } if ((signal < 0) || (signal >= etoi(NUM_SIGNALS))) { - Error("Signal out of range"); + t.Error("Signal out of range"); } function = gameLocal.program.FindFunction(func); if (null == function) { - Error("Function '%s' not found", func); + t.Error("Function '%s' not found", func); } - ent.SetSignal(signal, this, function); + ent.SetSignal(signal, t, function); } - private void Event_ClearSignalThread(int signal, idEntity ent) { + private static void Event_ClearSignalThread(idThread t, idEventArg s, idEventArg e) { + int signal = s.value; + idEntity ent = e.value; + if (null == ent) { - Error("Entity not found"); + t.Error("Entity not found"); } if ((signal < 0) || (signal >= etoi(NUM_SIGNALS))) { - Error("Signal out of range"); + t.Error("Signal out of range"); } - ent.ClearSignalThread(signal, this); + ent.ClearSignalThread(signal, t); } - private void Event_SetCamera(idEntity ent) { + private static void Event_SetCamera(idThread t, idEventArg e) { + idEntity ent = e.value; + if (null == ent) { - Error("Entity not found"); + t.Error("Entity not found"); return; } if (!ent.IsType(idCamera.class)) { - Error("Entity is not a camera"); + t.Error("Entity is not a camera"); return; } gameLocal.SetCamera((idCamera) ent); } - private void Event_FirstPerson() { + private static void Event_FirstPerson(idThread t) { gameLocal.SetCamera(null); } - private void Event_Trace(final idVec3 start, final idVec3 end, final idVec3 mins, final idVec3 maxs, int contents_mask, idEntity passEntity) { + private static void Event_Trace(idThread t, final idEventArg s, final idEventArg e, final idEventArg mi, + final idEventArg ma, idEventArg c, idEventArg p) { + idVec3 start = s.value; + idVec3 end = e.value; + idVec3 mins = mi.value; + idVec3 maxs = ma.value; + int contents_mask = c.value; + idEntity passEntity = p.value; + { - trace_s[] trace = {this.trace}; + trace_s[] trace = {t.trace}; if (mins.equals(getVec3_origin()) && maxs.equals(getVec3_origin())) { gameLocal.clip.TracePoint(trace, start, end, contents_mask, passEntity); } else { gameLocal.clip.TraceBounds(trace, start, end, new idBounds(mins, maxs), contents_mask, passEntity); } - this.trace = trace[0]; + t.trace = trace[0]; } ReturnFloat(trace.fraction); } - private void Event_TracePoint(final idVec3 start, final idVec3 end, int contents_mask, idEntity passEntity) { + private static void Event_TracePoint(idThread t, final idEventArg startA, final idEventArg endA, idEventArg c, idEventArg p) { + idVec3 start = startA.value; + idVec3 end = endA.value; + int contents_mask = c.value; + idEntity passEntity = p.value; { - trace_s[] trace = {this.trace}; + trace_s[] trace = {t.trace}; gameLocal.clip.TracePoint(trace, start, end, contents_mask, passEntity); - this.trace = trace[0]; + t.trace = trace[0]; } ReturnFloat(trace.fraction); } - private void Event_GetTraceFraction() { + private static void Event_GetTraceFraction(idThread t) { ReturnFloat(trace.fraction); } - private void Event_GetTraceEndPos() { + private static void Event_GetTraceEndPos(idThread t) { ReturnVector(trace.endpos); } - private void Event_GetTraceNormal() { + private static void Event_GetTraceNormal(idThread t) { if (trace.fraction < 1.0f) { ReturnVector(trace.c.normal); } else { @@ -523,7 +641,7 @@ private void Event_GetTraceNormal() { } } - private void Event_GetTraceEntity() { + private static void Event_GetTraceEntity(idThread t) { if (trace.fraction < 1.0f) { ReturnEntity(gameLocal.entities[ trace.c.entityNum]); } else { @@ -531,7 +649,7 @@ private void Event_GetTraceEntity() { } } - private void Event_GetTraceJoint() { + private static void Event_GetTraceJoint(idThread t) { if (trace.fraction < 1.0f && trace.c.id < 0) { idAFEntity_Base af = (idAFEntity_Base) gameLocal.entities[trace.c.entityNum]; if (af != null && af.IsType(idAFEntity_Base.class) && af.IsActiveAF()) { @@ -542,7 +660,7 @@ private void Event_GetTraceJoint() { ReturnString(""); } - private void Event_GetTraceBody() { + private static void Event_GetTraceBody(idThread t) { if (trace.fraction < 1.0f && trace.c.id < 0) { idAFEntity_Base af = (idAFEntity_Base) gameLocal.entities[ trace.c.entityNum]; if (af != null && af.IsType(idAFEntity_Base.class) && af.IsActiveAF()) { @@ -557,68 +675,75 @@ private void Event_GetTraceBody() { ReturnString(""); } - private void Event_FadeIn(idVec3 color, float time) { + private static void Event_FadeIn(idThread t, idEventArg colorA, idEventArg time) { idVec4 fadeColor = new idVec4(); idPlayer player; + idVec3 color = colorA.value; player = gameLocal.GetLocalPlayer(); if (player != null) { fadeColor.Set(color.oGet(0), color.oGet(1), color.oGet(2), 0.0f); - player.playerView.Fade(fadeColor, (int) SEC2MS(time)); + player.playerView.Fade(fadeColor, (int) SEC2MS(time.value)); } } - private void Event_FadeOut(idVec3 color, float time) { + private static void Event_FadeOut(idThread t, idEventArg colorA, idEventArg time) { idVec4 fadeColor = new idVec4(); idPlayer player; + idVec3 color = colorA.value; player = gameLocal.GetLocalPlayer(); if (player != null) { fadeColor.Set(color.oGet(0), color.oGet(1), color.oGet(2), 1.0f); - player.playerView.Fade(fadeColor, (int) SEC2MS(time)); + player.playerView.Fade(fadeColor, (int) SEC2MS(time.value)); } } - private void Event_FadeTo(idVec3 color, float alpha, float time) { + private static void Event_FadeTo(idThread t, idEventArg colorA, idEventArg alpha, idEventArg time) { idVec4 fadeColor = new idVec4(); idPlayer player; + idVec3 color = colorA.value; player = gameLocal.GetLocalPlayer(); if (player != null) { - fadeColor.Set(color.oGet(0), color.oGet(1), color.oGet(2), alpha); - player.playerView.Fade(fadeColor, (int) SEC2MS(time)); + fadeColor.Set(color.oGet(0), color.oGet(1), color.oGet(2), alpha.value); + player.playerView.Fade(fadeColor, (int) SEC2MS(time.value)); } } - private void Event_SetShaderParm(int parmnum, float value) { + private static void Event_SetShaderParm(idThread t, idEventArg parmnumA, idEventArg value) { + int parmnum = parmnumA.value; + if ((parmnum < 0) || (parmnum >= MAX_GLOBAL_SHADER_PARMS)) { - Error("shader parm index (%d) out of range", parmnum); + t.Error("shader parm index (%d) out of range", parmnum); } - gameLocal.globalShaderParms[ parmnum] = value; + gameLocal.globalShaderParms[parmnum] = value.value; } - private void Event_StartMusic(final String text) { - gameSoundWorld.PlayShaderDirectly(text); + private static void Event_StartMusic(idThread t, final idEventArg text) { + gameSoundWorld.PlayShaderDirectly(text.value); } - private void Event_Warning(final String text) { - Warning("%s", text); + private static void Event_Warning(idThread t, final idEventArg text) { + t.Warning("%s", text.value); } - private void Event_Error(final String text) { - Error("%s", text); + private static void Event_Error(idThread t, final idEventArg text) { + t.Error("%s", text.value); } - private void Event_StrLen(final String string) { + private static void Event_StrLen(idThread t, final idEventArg string) { int len; - len = string.length(); + len = string.value.length(); idThread.ReturnInt(len); } - private void Event_StrLeft(final String string, int num) { + private static void Event_StrLeft(idThread t, final idEventArg stringA, idEventArg numA) { int len; + String string = stringA.value; + int num = numA.value; if (num < 0) { idThread.ReturnString(""); @@ -635,8 +760,10 @@ private void Event_StrLeft(final String string, int num) { idThread.ReturnString(result); } - private void Event_StrRight(final String string, int num) { + private static void Event_StrRight(idThread t, final idEventArg stringA, idEventArg numA) { int len; + String string = stringA.value; + int num = numA.value; if (num < 0) { idThread.ReturnString(""); @@ -652,8 +779,10 @@ private void Event_StrRight(final String string, int num) { idThread.ReturnString(string + (len - num)); } - private void Event_StrSkip(final String string, int num) { + private static void Event_StrSkip(idThread t, final idEventArg stringA, idEventArg numA) { int len; + String string = stringA.value; + int num = numA.value; if (num < 0) { idThread.ReturnString(string); @@ -669,8 +798,11 @@ private void Event_StrSkip(final String string, int num) { idThread.ReturnString(string + num); } - private void Event_StrMid(final String string, int start, int num) { + private static void Event_StrMid(idThread t, final idEventArg stringA, idEventArg startA, idEventArg numA) { int len; + String string = stringA.value; + int start = startA.value; + int num = numA.value; if (num < 0) { idThread.ReturnString(""); @@ -693,58 +825,64 @@ private void Event_StrMid(final String string, int start, int num) { idThread.ReturnString(result); } - private void Event_StrToFloat(final String string) { + private static void Event_StrToFloat(idThread t, final idEventArg string) { float result; - result = Float.parseFloat(string); + result = Float.parseFloat(string.value); idThread.ReturnFloat(result); } - private void Event_RadiusDamage(final idVec3 origin, idEntity inflictor, idEntity attacker, idEntity ignore, final String damageDefName, float dmgPower) { - gameLocal.RadiusDamage(origin, inflictor, attacker, ignore, ignore, damageDefName, dmgPower); + private static void Event_RadiusDamage(idThread t, final idEventArg origin, idEventArg inflictor, idEventArg attacker, + idEventArg ignore, final idEventArg damageDefName, idEventArg dmgPower) { + gameLocal.RadiusDamage(origin.value, inflictor.value, attacker.value, ignore.value, ignore.value, damageDefName.value, dmgPower.value); } - private void Event_IsClient() { + private static void Event_IsClient(idThread t) { idThread.ReturnFloat(btoi(gameLocal.isClient)); } - private void Event_IsMultiplayer() { + private static void Event_IsMultiplayer(idThread t) { idThread.ReturnFloat(btoi(gameLocal.isMultiplayer)); } - private void Event_GetFrameTime() { + private static void Event_GetFrameTime(idThread t) { idThread.ReturnFloat(MS2SEC(gameLocal.msec)); } - private void Event_GetTicsPerSecond() { + private static void Event_GetTicsPerSecond(idThread t) { idThread.ReturnFloat(USERCMD_HZ); } - private void Event_CacheSoundShader(final String soundName) { - declManager.FindSound(soundName); + private static void Event_CacheSoundShader(idThread t, final idEventArg soundName) { + declManager.FindSound(soundName.value); } - private void Event_DebugLine(final idVec3 color, final idVec3 start, final idVec3 end, final float lifetime) { - gameRenderWorld.DebugLine(new idVec4(color.x, color.y, color.z, 0.0f), start, end, (int) SEC2MS(lifetime)); + private static void Event_DebugLine(idThread t, final idEventArg colorA, final idEventArg start, final idEventArg end, final idEventArg lifetime) { + idVec3 color = colorA.value; + gameRenderWorld.DebugLine(new idVec4(color.x, color.y, color.z, 0.0f), start.value, end.value, (int) SEC2MS(lifetime.value)); } - private void Event_DebugArrow(final idVec3 color, final idVec3 start, final idVec3 end, final int size, final float lifetime) { - gameRenderWorld.DebugArrow(new idVec4(color.x, color.y, color.z, 0.0f), start, end, size, (int) SEC2MS(lifetime)); + private static void Event_DebugArrow(idThread t, final idEventArg colorA, final idEventArg start, final idEventArg end, final idEventArg size, final idEventArg lifetime) { + idVec3 color = colorA.value; + gameRenderWorld.DebugArrow(new idVec4(color.x, color.y, color.z, 0.0f), start.value, end.value, size.value, (int) SEC2MS(lifetime.value)); } - private void Event_DebugCircle(final idVec3 color, final idVec3 origin, final idVec3 dir, final float radius, final int numSteps, final float lifetime) { - gameRenderWorld.DebugCircle(new idVec4(color.x, color.y, color.z, 0.0f), origin, dir, radius, numSteps, (int) SEC2MS(lifetime)); + private static void Event_DebugCircle(idThread t, final idEventArg colorA, final idEventArg origin, final idEventArg dir, final idEventArg radius, final idEventArg numSteps, final idEventArg lifetime) { + idVec3 color = colorA.value; + gameRenderWorld.DebugCircle(new idVec4(color.x, color.y, color.z, 0.0f), origin.value, dir.value, radius.value, numSteps.value, (int) SEC2MS(lifetime.value)); } - private void Event_DebugBounds(final idVec3 color, final idVec3 mins, final idVec3 maxs, final float lifetime) { - gameRenderWorld.DebugBounds(new idVec4(color.x, color.y, color.z, 0.0f), new idBounds(mins, maxs), getVec3_origin(), (int) SEC2MS(lifetime)); + private static void Event_DebugBounds(idThread t, final idEventArg colorA, final idEventArg mins, final idEventArg maxs, final idEventArg lifetime) { + idVec3 color = colorA.value; + gameRenderWorld.DebugBounds(new idVec4(color.x, color.y, color.z, 0.0f), new idBounds(mins.value, maxs.value), getVec3_origin(), (int) SEC2MS(lifetime.value)); } - private void Event_DrawText(final String text, final idVec3 origin, float scale, final idVec3 color, final int align, final float lifetime) { - gameRenderWorld.DrawText(text, origin, scale, new idVec4(color.x, color.y, color.z, 0.0f), gameLocal.GetLocalPlayer().viewAngles.ToMat3(), align, (int) SEC2MS(lifetime)); + private static void Event_DrawText(idThread t, final idEventArg text, final idEventArg origin, idEventArg scale, final idEventArg colorA, final idEventArg align, final idEventArg lifetime) { + idVec3 color = colorA.value; + gameRenderWorld.DrawText(text.value, origin.value, scale.value, new idVec4(color.x, color.y, color.z, 0.0f), gameLocal.GetLocalPlayer().viewAngles.ToMat3(), align.value, (int) SEC2MS(lifetime.value)); } - private void Event_InfluenceActive() { + private static void Event_InfluenceActive(idThread t) { idPlayer player; player = gameLocal.GetLocalPlayer(); @@ -964,6 +1102,11 @@ public idClass CreateInstance() { return getClass(); } + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } + @Override public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. From 0d2bc5e4f2309a77e5eef68f1c556a190de37085 Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Thu, 5 May 2016 12:21:18 +0200 Subject: [PATCH 06/17] -disabled and refactored some of the event handlers for the callbacks --- src/main/java/neo/Game/GameSys/Class.java | 70 +++++++++---------- src/main/java/neo/Game/GameSys/Event.java | 48 +++---------- .../neo/Game/Script/Script_Interpreter.java | 58 +++++++-------- src/misc/bug_report_04.txt | 2 + 4 files changed, 77 insertions(+), 101 deletions(-) diff --git a/src/main/java/neo/Game/GameSys/Class.java b/src/main/java/neo/Game/GameSys/Class.java index 76cdcace..7a48559b 100644 --- a/src/main/java/neo/Game/GameSys/Class.java +++ b/src/main/java/neo/Game/GameSys/Class.java @@ -444,8 +444,7 @@ public boolean ProcessEvent(final idEventDef ev, Object arg1, Object arg2, Objec return ProcessEventArgs(ev, 8, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4), toEvent(arg5), toEvent(arg6), toEvent(arg7), toEvent(arg8)); } - public boolean ProcessEventArgPtr(final idEventDef ev, int[] data) { - idTypeInfo c; + public boolean ProcessEventArgPtr(final idEventDef ev, idEventArg[] data) { int num; eventCallback_t callback; @@ -453,24 +452,22 @@ public boolean ProcessEventArgPtr(final idEventDef ev, int[] data) { assert (idEvent.initialized); if (g_debugTriggers.GetBool() && (ev == EV_Activate) && IsType(idEntity.class)) { - idEntity ent = new idEntity(); - ByteBuffer entityBuffer = ent.AllocBuffer(); - entityBuffer.asIntBuffer().put(data); - ent.Read(entityBuffer); -// final idEntity ent = reinterpret_cast < idEntity > (data); - gameLocal.Printf("%d: '%s' activated by '%s'\n", gameLocal.framenum, ((idEntity) this).GetName(), ent != null ? ent.GetName() : "NULL"); + final String name; + if (data[0] != null && ((idClass) data[0].value).IsType(idEntity.class)) + name = ((idEntity) data[0].value).GetName(); + else + name = "NULL"; + gameLocal.Printf("%d: '%s' activated by '%s'\n", gameLocal.framenum, ((idEntity) this).GetName(), name); } -/////////TODO: this is TEMPORARILY disabled -// c = GetType(); -// num = ev.GetEventNum(); -// if (NOT(c.eventMap[num])) { -// // we don't respond to this event, so ignore it -// return false; -// } -// -// callback = c.eventMap[num]; -// + num = ev.GetEventNum(); + callback = this.getEventCallBack(ev);//callback = c.eventMap[num]; + if (callback == null) { + // we don't respond to this event, so ignore it + return false; + } + +//// //// #if !CPU_EASYARGS //// /* //// on ppc architecture, floats are passed in a seperate set of registers @@ -488,64 +485,65 @@ public boolean ProcessEventArgPtr(final idEventDef ev, int[] data) { // // break; // // } //// #else -// assert (D_EVENT_MAXARGS == 8); -// -// switch (ev.GetNumArgs()) { -// case 0: + assert (D_EVENT_MAXARGS == 8); + + switch (ev.GetNumArgs()) { + case 0: // callback.run(); // break; // -// case 1: + case 1: //// typedef void ( idClass.*eventCallback_1_t )( const int ); //// ( this.*( eventCallback_1_t )callback )( data[ 0 ] ); // callback.run(data[0]); // break; // -// case 2: + case 2: //// typedef void ( idClass.*eventCallback_2_t )( const int, const int ); //// ( this.*( eventCallback_2_t )callback )( data[ 0 ], data[ 1 ] ); // callback.run(data[0], data[1]); // break; // -// case 3: + case 3: //// typedef void ( idClass.*eventCallback_3_t )( const int, const int, const int ); //// ( this.*( eventCallback_3_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ] ); // callback.run(data[0], data[1], data[2]); // break; // -// case 4: + case 4: //// typedef void ( idClass.*eventCallback_4_t )( const int, const int, const int, const int ); //// ( this.*( eventCallback_4_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ] ); // callback.run(data[0], data[1], data[2], data[3]); // break; // -// case 5: + case 5: //// typedef void ( idClass.*eventCallback_5_t )( const int, const int, const int, const int, const int ); //// ( this.*( eventCallback_5_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ] ); // callback.run(data[0], data[1], data[2], data[3], data[4]); // break; // -// case 6: + case 6: //// typedef void ( idClass.*eventCallback_6_t )( const int, const int, const int, const int, const int, const int ); //// ( this.*( eventCallback_6_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] ); // break; // -// case 7: + case 7: //// typedef void ( idClass.*eventCallback_7_t )( const int, const int, const int, const int, const int, const int, const int ); //// ( this.*( eventCallback_7_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ] ); // callback.run(data[0], data[1], data[2], data[3], data[4], data[5], data[6]); // break; // -// case 8: + case 8: //// typedef void ( idClass.*eventCallback_8_t )( const int, const int, const int, const int, const int, const int, const int, const int ); //// ( this.*( eventCallback_8_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ] ); // callback.run(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); -// break; + callback.accept(this, data); + break; // -// default: -// gameLocal.Warning("Invalid formatspec on event '%s'", ev.GetName()); -// break; -// } + default: + gameLocal.Warning("Invalid formatspec on event '%s'", ev.GetName()); + break; + } // #endif return true; @@ -829,7 +827,7 @@ private boolean PostEventArgs(final idEventDef ev, int time, int numargs, idEven private boolean ProcessEventArgs(final idEventDef ev, int numargs, idEventArg... args) { idTypeInfo c; int num; - int[] data = new int[D_EVENT_MAXARGS]; + idEventArg[] data = new idEventArg[D_EVENT_MAXARGS]; // va_list args; assert (ev != null); diff --git a/src/main/java/neo/Game/GameSys/Event.java b/src/main/java/neo/Game/GameSys/Event.java index c397dc47..6ace3bf2 100644 --- a/src/main/java/neo/Game/GameSys/Event.java +++ b/src/main/java/neo/Game/GameSys/Event.java @@ -422,10 +422,9 @@ public static idEvent Alloc(final idEventDef evdef, int numargs, idEventArg... a return ev; } - public static void CopyArgs(final idEventDef evdef, int numargs, idEventArg[] args, int[] data/*[ D_EVENT_MAXARGS ]*/) { + public static void CopyArgs(final idEventDef evdef, int numargs, idEventArg[] args, idEventArg[] data/*[ D_EVENT_MAXARGS ]*/) { int i; String format; -// idEventArg arg; format = evdef.GetArgFormat(); if (numargs != evdef.GetNumArgs()) { @@ -441,7 +440,7 @@ public static void CopyArgs(final idEventDef evdef, int numargs, idEventArg[] ar } } - data[i] = (int) arg.value; + data[i] = arg; } } } @@ -531,7 +530,7 @@ public static void ClearEventList() { public static void ServiceEvents() { idEvent event; int num; - int[] args = new int[D_EVENT_MAXARGS]; + idEventArg[] args = new idEventArg[D_EVENT_MAXARGS]; int offset; int i; int numargs; @@ -555,47 +554,22 @@ public static void ServiceEvents() { formatspec = ev.GetArgFormat(); numargs = ev.GetNumArgs(); for (i = 0; i < numargs; i++) { - offset = ev.GetArgOffset(i); - data = event.data; switch (formatspec.charAt(i)) { - case D_EVENT_FLOAT: case D_EVENT_INTEGER: - args[i] = (int) data[offset]; + case D_EVENT_FLOAT: + case D_EVENT_VECTOR: + case D_EVENT_STRING: + case D_EVENT_ENTITY: + case D_EVENT_ENTITY_NULL: + case D_EVENT_TRACE: + args[i] = event.data[i]; break; - -// case D_EVENT_VECTOR : -// *reinterpret_cast( &args[ i ] ) = reinterpret_cast( &data[ offset ] ); -// break; -// -// case D_EVENT_STRING : -// *reinterpret_cast( &args[ i ] ) = reinterpret_cast( &data[ offset ] ); -// break; -// -// case D_EVENT_ENTITY : -// case D_EVENT_ENTITY_NULL : -// *reinterpret_cast( &args[ i ] ) = reinterpret_cast< idEntityPtr * >( &data[ offset ] ).GetEntity(); -// break; -// -// case D_EVENT_TRACE : -// tracePtr = reinterpret_cast( &args[ i ] ); -// if ( *reinterpret_cast( &data[ offset ] ) ) { -// *tracePtr = reinterpret_cast( &data[ offset + sizeof( bool ) ] ); -// -// if ( ( *tracePtr ).c.material != NULL ) { -// // look up the material name to get the material pointer -// materialName = reinterpret_cast( &data[ offset + sizeof( bool ) + sizeof( trace_t ) ] ); -// ( *tracePtr ).c.material = declManager.FindMaterial( materialName, true ); -// } -// } else { -// *tracePtr = NULL; -// } -// break; - default: gameLocal.Error("idEvent::ServiceEvents : Invalid arg format '%s' string for '%s' event.", formatspec, ev.GetName()); }//TODO:S ^^^^^^^^^^^^^^^^^^^^^ } + // the event is removed from its list so that if then object // is deleted, the event won't be freed twice event.eventNode.Remove(); diff --git a/src/main/java/neo/Game/Script/Script_Interpreter.java b/src/main/java/neo/Game/Script/Script_Interpreter.java index 0294c41d..8b95fb2a 100644 --- a/src/main/java/neo/Game/Script/Script_Interpreter.java +++ b/src/main/java/neo/Game/Script/Script_Interpreter.java @@ -492,17 +492,18 @@ private void CallEvent(final function_t func, int argsize) { } popParms = argsize; - eventEntity.ProcessEventArgPtr(evdef, btoia(data)); - - if (null == multiFrameEvent) { - if (popParms != 0) { - PopParms(popParms); - } - eventEntity = null; - } else { - doneProcessing = true; - } - popParms = 0; + throw new TODO_Exception(); +// eventEntity.ProcessEventArgPtr(evdef, btoia(data)); +// +// if (null == multiFrameEvent) { +// if (popParms != 0) { +// PopParms(popParms); +// } +// eventEntity = null; +// } else { +// doneProcessing = true; +// } +// popParms = 0; } private void CallSysEvent(final function_t func, int argsize) { @@ -583,23 +584,24 @@ private void CallSysEvent(final function_t func, int argsize) { pos += func.parmSize.oGet(j++); } - popParms = argsize; - thread.ProcessEventArgPtr(evdef, data); - if (popParms != 0) { - PopParms(popParms); - } - popParms = 0; - } - - public idInterpreter() { - localstackUsed = 0; - terminateOnExit = true; - debug = false; -// memset( localstack, 0, sizeof( localstack ) ); -// Arrays.fill(localstack, 0); -// memset( callStack, 0, sizeof( callStack ) ); -// Arrays.fill(callStack, 0); - Reset(); + throw new TODO_Exception(); +// popParms = argsize; +// thread.ProcessEventArgPtr(evdef, data); +// if (popParms != 0) { +// PopParms(popParms); +// } +// popParms = 0; +// } +// +// public idInterpreter() { +// localstackUsed = 0; +// terminateOnExit = true; +// debug = false; +//// memset( localstack, 0, sizeof( localstack ) ); +//// Arrays.fill(localstack, 0); +//// memset( callStack, 0, sizeof( callStack ) ); +//// Arrays.fill(callStack, 0); +// Reset(); } // save games diff --git a/src/misc/bug_report_04.txt b/src/misc/bug_report_04.txt index ca6d2507..beb49f02 100644 --- a/src/misc/bug_report_04.txt +++ b/src/misc/bug_report_04.txt @@ -56,6 +56,8 @@ blanco ingame, go: give object as param - ServiceEvents varargs object - ProcessEventArgPtr varargs[0] is object - ProcessEventArgPtr + -took some effort to fix this(417 from 419 now), moving on + -let's centering all the debug drawrings From 3b54f6cbfa2e7b09999d4e6ca3a998bd5579a1a6 Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Fri, 6 May 2016 20:34:12 +0200 Subject: [PATCH 07/17] -linchpin --- src/main/java/neo/Game/Physics/Clip.java | 3 ++- src/main/java/neo/Game/Physics/Physics.java | 2 ++ .../java/neo/Game/Physics/Physics_RigidBody.java | 9 +++++++-- src/main/java/neo/Game/Physics/Push.java | 2 +- src/main/java/neo/Renderer/tr_light.java | 2 +- src/main/java/neo/TempDump.java | 4 ++++ src/main/java/neo/idlib/Dict_h.java | 6 ++++-- src/misc/bug_report_04.txt | 14 ++++++++++++++ 8 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/main/java/neo/Game/Physics/Clip.java b/src/main/java/neo/Game/Physics/Clip.java index b7c3ef43..bbff8844 100644 --- a/src/main/java/neo/Game/Physics/Clip.java +++ b/src/main/java/neo/Game/Physics/Clip.java @@ -289,8 +289,9 @@ public void Restore(idRestoreGame savefile) { } } + private static int DBG_Link = 0; public void Link(idClip clp) { // must have been linked with an entity and id before - + DBG_Link++; assert (this.entity != null); if (null == this.entity) { return; diff --git a/src/main/java/neo/Game/Physics/Physics.java b/src/main/java/neo/Game/Physics/Physics.java index 73dd55d0..ace36c9b 100644 --- a/src/main/java/neo/Game/Physics/Physics.java +++ b/src/main/java/neo/Game/Physics/Physics.java @@ -69,6 +69,8 @@ void clear() { public static abstract class idPhysics extends idClass { // ABSTRACT_PROTOTYPE( idPhysics ); + private static int DBG_counter = 0; + protected final int DBG_count = DBG_counter++; // virtual ~idPhysics(); public static int SnapTimeToPhysicsFrame(int t) { diff --git a/src/main/java/neo/Game/Physics/Physics_RigidBody.java b/src/main/java/neo/Game/Physics/Physics_RigidBody.java index 622466b5..5248117e 100644 --- a/src/main/java/neo/Game/Physics/Physics_RigidBody.java +++ b/src/main/java/neo/Game/Physics/Physics_RigidBody.java @@ -1277,11 +1277,15 @@ private void ContactFriction(float deltaTime) { Drops the object straight down to the floor and verifies if the object is at rest on the floor. ================ - */ - private void DropToFloorAndRest() { + */ private static int DBG_DropToFloorAndRest = 0; + private void DropToFloorAndRest() { DBG_DropToFloorAndRest++; idVec3 down; trace_s[] tr = {null}; + if(this.DBG_count==8209){ + int bla = 1; + } + if (testSolid) { testSolid = false; @@ -1295,6 +1299,7 @@ private void DropToFloorAndRest() { } } + // put the body on the floor down = current.i.position.oPlus(gravityNormal.oMultiply(128.0f)); gameLocal.clip.Translation(tr, current.i.position, down, clipModel, current.i.orientation, clipMask, self); diff --git a/src/main/java/neo/Game/Physics/Push.java b/src/main/java/neo/Game/Physics/Push.java index 72a5bd45..40c347c4 100644 --- a/src/main/java/neo/Game/Physics/Push.java +++ b/src/main/java/neo/Game/Physics/Push.java @@ -248,7 +248,7 @@ public float ClipRotationalPush(trace_s[] results, idEntity pusher, final int fl idBounds bounds, pushBounds = new idBounds(); idRotation clipRotation; idMat3 clipAxis, oldAxis; - trace_s[] pushResults = {null}; + trace_s[] pushResults = {new trace_s()}; boolean wasEnabled; float totalMass; idClipModel clipModel; diff --git a/src/main/java/neo/Renderer/tr_light.java b/src/main/java/neo/Renderer/tr_light.java index 67fc7396..2f90e8fb 100644 --- a/src/main/java/neo/Renderer/tr_light.java +++ b/src/main/java/neo/Renderer/tr_light.java @@ -638,7 +638,7 @@ public static idScreenRect R_ClippedLightScissorRectangle(viewLight_s vLight) { continue; } - w = (idFixedWinding) ow; + w = new idFixedWinding(ow); // now check the winding against each of the frustum planes for (j = 0; j < 5; j++) { diff --git a/src/main/java/neo/TempDump.java b/src/main/java/neo/TempDump.java index 6a976abe..6923c75c 100644 --- a/src/main/java/neo/TempDump.java +++ b/src/main/java/neo/TempDump.java @@ -296,6 +296,10 @@ public static int atoi(String ascii) { } } + public static boolean atob(String ascii) { + return itob(atoi(ascii)); + } + public static int atoi(idStr ascii) { return atoi(ascii.toString()); } diff --git a/src/main/java/neo/idlib/Dict_h.java b/src/main/java/neo/idlib/Dict_h.java index c243a4b0..5c54744d 100644 --- a/src/main/java/neo/idlib/Dict_h.java +++ b/src/main/java/neo/idlib/Dict_h.java @@ -1,6 +1,8 @@ package neo.idlib; import java.util.Objects; + +import static neo.TempDump.atob; import static neo.TempDump.atof; import static neo.TempDump.atoi; import static neo.TempDump.btoi; @@ -446,7 +448,7 @@ public boolean GetBool(final String key) throws idException { } public boolean GetBool(final String key, final String defaultString) throws idException { - return Boolean.parseBoolean(GetString(key, defaultString)); + return atob(GetString(key, defaultString)); } public idVec3 GetVector(final String key, final String defaultString) throws idException { @@ -546,7 +548,7 @@ public boolean GetBool(final String key, final String defaultString, boolean[] o boolean found; found = GetString(key, defaultString, s); - out[0] = Boolean.parseBoolean(s[0]); + out[0] = atob(s[0]); return found; } diff --git a/src/misc/bug_report_04.txt b/src/misc/bug_report_04.txt index beb49f02..13e80ca5 100644 --- a/src/misc/bug_report_04.txt +++ b/src/misc/bug_report_04.txt @@ -57,6 +57,20 @@ blanco ingame, go: varargs object - ProcessEventArgPtr varargs[0] is object - ProcessEventArgPtr -took some effort to fix this(417 from 419 now), moving on + -back to checking idClipModel.absBounds + -clipmodel.DBG_count==11 + -which is set in idClipModel::Link() #44 + -which is set in idPhysics_RigidBody::DropToFloorAndRest()...didn't see that one coming + -neither tr.endpos or current.i.orientation match + -we should begin with current.i.position though + -idPhysics_RigidBody::SetOrigin() + -seems like we're comparing oranges and potatoes + -we were comparing #97 & #98 in idGameLocal::RunFrame() + -it seems #97 moveable_fireext_1, has one too many flags + -idEntity::BecomeInactive() isn't hit in our version + -plus our version is setting more flags, albe they the same + + From e0e40de44bdfd5aa892e62b0153ef03f1d68789a Mon Sep 17 00:00:00 2001 From: blackbeard Date: Sun, 8 May 2016 23:13:11 +0200 Subject: [PATCH 08/17] idRenderModelStatic::ConvertASEToModelSurfaces(): -added forgotten matchVert_s hashcode override, which helps with all the extra verts -'textureSin' typo idTraceModel::VolumeIntegrals() -added some double's for more accuracy(experimental) --- .../java/neo/CM/CollisionModel_local.java | 4 +- src/main/java/neo/Game/Physics/Push.java | 2 +- src/main/java/neo/Renderer/ModelManager.java | 9 ++++ src/main/java/neo/Renderer/Model_local.java | 54 +++++++++++++------ .../java/neo/idlib/geometry/TraceModel.java | 41 ++++++++------ src/misc/bug_report_04.txt | 18 +++++++ 6 files changed, 93 insertions(+), 35 deletions(-) diff --git a/src/main/java/neo/CM/CollisionModel_local.java b/src/main/java/neo/CM/CollisionModel_local.java index b30d51fa..76b02a92 100644 --- a/src/main/java/neo/CM/CollisionModel_local.java +++ b/src/main/java/neo/CM/CollisionModel_local.java @@ -7016,7 +7016,7 @@ private boolean TrmFromModel(final cm_model_s model, idTraceModel trm) { if (!TrmFromModel_r(trm, model.node)) { common.Printf("idCollisionModelManagerLocal::TrmFromModel: model %s has too many polygons.\n", model.name); PrintModelInfo(model); - return false; + return false;//HACKME::9 } // copy vertices @@ -7045,7 +7045,7 @@ private boolean TrmFromModel(final cm_model_s model, idTraceModel trm) { if (numEdgeUsers[i] != 2) { common.Printf("idCollisionModelManagerLocal::TrmFromModel: model %s has dangling edges, the model has to be an enclosed hull.\n", model.name); PrintModelInfo(model); - return false; + return false;//HACKME::9 } } diff --git a/src/main/java/neo/Game/Physics/Push.java b/src/main/java/neo/Game/Physics/Push.java index 40c347c4..3d324dbb 100644 --- a/src/main/java/neo/Game/Physics/Push.java +++ b/src/main/java/neo/Game/Physics/Push.java @@ -68,7 +68,7 @@ public float ClipTranslationalPush(trace_s[] results, idEntity pusher, final int idEntity[] entityList = new idEntity[MAX_GENTITIES]; idBounds bounds, pushBounds = new idBounds(); idVec3 clipMove, clipOrigin, oldOrigin, dir, impulse = new idVec3(); - trace_s[] pushResults = {null}; + trace_s[] pushResults = {new trace_s()}; boolean wasEnabled; float totalMass; idClipModel clipModel; diff --git a/src/main/java/neo/Renderer/ModelManager.java b/src/main/java/neo/Renderer/ModelManager.java index 578e0fc4..1963cb26 100644 --- a/src/main/java/neo/Renderer/ModelManager.java +++ b/src/main/java/neo/Renderer/ModelManager.java @@ -2,6 +2,7 @@ import static neo.Renderer.Model.MD5_MESH_EXT; import neo.Renderer.Model.idRenderModel; +import neo.Renderer.Model.modelSurface_s; import neo.Renderer.Model_beam.idRenderModelBeam; import neo.Renderer.Model_liquid.idRenderModelLiquid; import neo.Renderer.Model_local.idRenderModelStatic; @@ -466,6 +467,14 @@ private idRenderModel GetModel(final String modelName, boolean createIfNotFound) if ((extension.Icmp("ase") == 0) || (extension.Icmp("lwo") == 0) || (extension.Icmp("flt") == 0)) { model = new idRenderModelStatic(); model.InitFromFile(modelName); + + //HACKME::9 + idRenderModelStatic m = (idRenderModelStatic) model; +// for (modelSurface_s mimi : m.surfaces.Ptr(modelSurface_s[].class)) { +// for (int i = 0; i < mimi.geometry.numVerts; i++) { +// mimi.geometry.verts[i].xyz.oMinSet(0, 999); +// } +// } } else if (extension.Icmp("ma") == 0) { model = new idRenderModelStatic(); model.InitFromFile(modelName); diff --git a/src/main/java/neo/Renderer/Model_local.java b/src/main/java/neo/Renderer/Model_local.java index e60e05e2..09de412a 100644 --- a/src/main/java/neo/Renderer/Model_local.java +++ b/src/main/java/neo/Renderer/Model_local.java @@ -1013,7 +1013,7 @@ static class matchVert_s { matchVert_s next; int v, tv; short[] color = new short[4]; - idVec3 normal; + idVec3 normal = new idVec3(); public matchVert_s() { } @@ -1029,10 +1029,30 @@ public matchVert_s() { // // return i; // } - + + + @Override + public int hashCode() { + int result = v; + result = 31 * result + tv; + return result; + } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + final matchVert_s that = (matchVert_s) o; + + if (v != that.v) return false; + return tv == that.tv; + + } + static matchVert_s[] generateArray(final int length) { return Stream. - generate(() -> new matchVert_s()). + generate(matchVert_s::new). limit(length). toArray(matchVert_s[]::new); } @@ -1192,10 +1212,10 @@ public boolean ConvertASEToModelSurfaces(final aseModel_s ase) { // we need to find out how many unique vertex / texcoord combinations // there are, because ASE tracks them separately but we need them unified // the maximum possible number of combined vertexes is the number of indexes - mvTable = matchVert_s.generateArray(mesh.numFaces * 3); + mvTable = new matchVert_s[mesh.numFaces * 3]; // we will have a hash chain based on the xyz values - mvHash = matchVert_s.generateArray(mesh.numVertexes); + mvHash = new matchVert_s[mesh.numVertexes]; // allocate triangle surface tri = R_AllocStaticTriSurf(); @@ -1250,7 +1270,7 @@ public boolean ConvertASEToModelSurfaces(final aseModel_s ase) { if (mv.tv != tv) { continue; } - if (mv.color != color) { + if (!Arrays.equals(mv.color, color)) { continue; } if (!normalsParsed) { @@ -1264,11 +1284,11 @@ public boolean ConvertASEToModelSurfaces(final aseModel_s ase) { } if (null == mv) { // allocate a new match vert and link to hash chain - mv = mvTable[ tri.numVerts]; + mv = mvTable[tri.numVerts] = new matchVert_s(); mv.v = v; mv.tv = tv; - mv.normal = normal; - mv.color = color; + mv.normal.oSet(normal); + System.arraycopy(color, 0, mv.color, 0, color.length); mv.next = null; if (lastmv != null) { lastmv.next = mv; @@ -1320,7 +1340,7 @@ public boolean ConvertASEToModelSurfaces(final aseModel_s ase) { float u = tv2.x * uTiling + uOffset; float V = tv2.y * vTiling + vOffset; tri.verts[ j].st.oSet(0, u * textureCos + V * textureSin); - tri.verts[ j].st.oSet(1, u * -textureCos + V * textureCos); + tri.verts[ j].st.oSet(1, u * -textureSin + V * textureCos); } } // @@ -1536,7 +1556,7 @@ public boolean ConvertASEToModelSurfaces(final aseModel_s ase) { // we need to find out how many unique vertex / texcoord combinations there are // the maximum possible number of combined vertexes is the number of indexes - mvTable = matchVert_s.generateArray(layer.polygon.count * 3); + mvTable = new matchVert_s[layer.polygon.count * 3]; // we will have a hash chain based on the xyz values mvHash = new matchVert_s[layer.point.count];// R_ClearedStaticAlloc(layer.point.count, matchVert_s.class/* sizeof( mvHash[0] ) */); @@ -1634,11 +1654,11 @@ public boolean ConvertASEToModelSurfaces(final aseModel_s ase) { } if (null == mv) { // allocate a new match vert and link to hash chain - mv = mvTable[ tri.numVerts]; + mv = mvTable[tri.numVerts] = new matchVert_s(); mv.v = v; mv.tv = tv; - mv.normal = new idVec3(normal); - mv.color = color; + mv.normal.oSet(normal); + System.arraycopy(color, 0, mv.color, 0, color.length); mv.next = null; if (lastmv != null) { lastmv.next = mv; @@ -1935,11 +1955,11 @@ public boolean ConvertMAToModelSurfaces(final maModel_s ma) { } if (null == mv) { // allocate a new match vert and link to hash chain - mv = mvTable[ tri.numVerts]; + mv = mvTable[tri.numVerts] = new matchVert_s(); mv.v = v; mv.tv = tv; - mv.normal = normal; - mv.color = color; + mv.normal.oSet(normal); + System.arraycopy(color, 0, mv.color, 0, color.length); mv.next = null; if (lastmv != null) { lastmv.next = mv; diff --git a/src/main/java/neo/idlib/geometry/TraceModel.java b/src/main/java/neo/idlib/geometry/TraceModel.java index 030132e1..2beb6ef0 100644 --- a/src/main/java/neo/idlib/geometry/TraceModel.java +++ b/src/main/java/neo/idlib/geometry/TraceModel.java @@ -1524,7 +1524,11 @@ private void VolumeIntegrals(volumeIntegrals_t integrals) { traceModelPoly_t poly; polygonIntegrals_t pi = new polygonIntegrals_t(); int i, a, b, c; - float nx, ny, nz; + double nx, ny, nz; + double T0 = 0; + double[] T1 = new double[3]; + double[] T2 = new double[3]; + double[] TP = new double[3]; // memset( &integrals, 0, sizeof(volumeIntegrals_t) ); for (i = 0; i < numPolys; i++) { @@ -1543,22 +1547,29 @@ private void VolumeIntegrals(volumeIntegrals_t integrals) { PolygonIntegrals(i, a, b, c, pi); - integrals.T0 += poly.normal.oGet(0) * ((a == 0) ? pi.Fa : ((b == 0) ? pi.Fb : pi.Fc)); - - integrals.T1.oPluSet(a, poly.normal.oGet(a) * pi.Faa); - integrals.T1.oPluSet(b, poly.normal.oGet(b) * pi.Fbb); - integrals.T1.oPluSet(c, poly.normal.oGet(c) * pi.Fcc); - integrals.T2.oPluSet(a, poly.normal.oGet(a) * pi.Faaa); - integrals.T2.oPluSet(b, poly.normal.oGet(b) * pi.Fbbb); - integrals.T2.oPluSet(c, poly.normal.oGet(c) * pi.Fccc); - integrals.TP.oPluSet(a, poly.normal.oGet(a) * pi.Faab); - integrals.TP.oPluSet(b, poly.normal.oGet(b) * pi.Fbbc); - integrals.TP.oPluSet(c, poly.normal.oGet(c) * pi.Fcca); + T0 += poly.normal.oGet(0) * ((a == 0) ? pi.Fa : ((b == 0) ? pi.Fb : pi.Fc)); + + T1[a] += poly.normal.oGet(a) * pi.Faa; + T1[b] += poly.normal.oGet(b) * pi.Fbb; + T1[c] += poly.normal.oGet(c) * pi.Fcc; + T2[a] += poly.normal.oGet(a) * pi.Faaa; + T2[b] += poly.normal.oGet(b) * pi.Fbbb; + T2[c] += poly.normal.oGet(c) * pi.Fccc; + TP[a] += poly.normal.oGet(a) * pi.Faab; + TP[b] += poly.normal.oGet(b) * pi.Fbbc; + TP[c] += poly.normal.oGet(c) * pi.Fcca; } - integrals.T1.oMulSet(0.5f); - integrals.T2.oMulSet(1.0f / 3.0f); - integrals.TP.oMulSet(0.5f); + integrals.T0 = (float) T0; + integrals.T1.oSet(0, (float) (T1[0] * 0.5f)); + integrals.T1.oSet(1, (float) (T1[1] * 0.5f)); + integrals.T1.oSet(2, (float) (T1[2] * 0.5f)); + integrals.T2.oSet(0, (float) (T2[0] * 1.0f / 3.0f)); + integrals.T2.oSet(1, (float) (T2[1] * 1.0f / 3.0f)); + integrals.T2.oSet(2, (float) (T2[2] * 1.0f / 3.0f)); + integrals.TP.oSet(0, (float) (TP[0] * 0.5f)); + integrals.TP.oSet(1, (float) (TP[1] * 0.5f)); + integrals.TP.oSet(2, (float) (TP[2] * 0.5f)); } private void VolumeFromPolygon(idTraceModel trm, float thickness) { diff --git a/src/misc/bug_report_04.txt b/src/misc/bug_report_04.txt index 13e80ca5..5c1a2353 100644 --- a/src/misc/bug_report_04.txt +++ b/src/misc/bug_report_04.txt @@ -69,6 +69,24 @@ blanco ingame, go: -it seems #97 moveable_fireext_1, has one too many flags -idEntity::BecomeInactive() isn't hit in our version -plus our version is setting more flags, albe they the same + -same flags + -idMoveable::Spawn(), physicsObj.centerOfMass has different values + -idClipModel::GetMassProperties() + -idTraceModel::GetMassProperties() + -idTraceModel::VolumeIntegrals() + -we've been down this road before, and concluded that the doubel precision isn't the cause of our problem here, so let's ignore it for now + -idRenderModelManagerLocal::GetModel() + -idRenderModelStatic::ConvertASEToModelSurfaces() + -"models/mapobjects/filler/binder1.ase" + -tri.numVerts don't match 348!=212 + -mesh->faces[j].vertexNormals[k].x 1!=0 + -((*(((ase)->objects).list))->mesh).faces.vertexNormals + -mesh->faces[j].faceNormal too + -((*(((ase)->objects).list))->mesh).faces.faceNormal + -mesh->faces[j].vertexColors as well + -((*(((ase)->objects).list))->mesh).transform + + From dffae71dbfee8d3227e2ed4077652394e7eae398 Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Tue, 10 May 2016 13:48:54 +0200 Subject: [PATCH 09/17] -refactored no param functions/EVENTS --- .../java/neo/CM/CollisionModel_local.java | 8 +- src/main/java/neo/Game/Actor.java | 2 +- src/main/java/neo/Game/Entity.java | 139 +++++++++-------- src/main/java/neo/Game/GameSys/SysCmds.java | 4 +- src/main/java/neo/Game/Player.java | 142 +++++++----------- .../java/neo/Game/Script/Script_Thread.java | 40 ++--- src/main/java/neo/Renderer/Model.java | 2 +- src/main/java/neo/Renderer/ModelManager.java | 5 +- src/main/java/neo/Renderer/Model_ase.java | 2 + src/main/java/neo/Renderer/Model_local.java | 42 +++--- .../java/neo/Renderer/RenderSystem_init.java | 6 +- src/main/java/neo/Renderer/draw_common.java | 2 +- src/main/java/neo/Renderer/qgl.java | 4 +- .../java/neo/Renderer/tr_rendertools.java | 4 +- src/main/java/neo/framework/UsercmdGen.java | 2 +- src/misc/bug_report_04.txt | 37 ++++- 16 files changed, 226 insertions(+), 215 deletions(-) diff --git a/src/main/java/neo/CM/CollisionModel_local.java b/src/main/java/neo/CM/CollisionModel_local.java index 76b02a92..d2dbc3d2 100644 --- a/src/main/java/neo/CM/CollisionModel_local.java +++ b/src/main/java/neo/CM/CollisionModel_local.java @@ -6632,14 +6632,14 @@ private void OptimizeArrays(cm_model_s model) { // realloc vertices oldVertices = model.vertices; - if (oldVertices != null) { + if (oldVertices != null && oldVertices.length != 0) { model.vertices = cm_vertex_s.generateArray(model.numVertices); System.arraycopy(oldVertices, 0, model.vertices, 0, Math.min(oldVertices.length, model.numVertices)); } // realloc edges oldEdges = model.edges; - if (oldEdges != null) { + if (oldEdges != null && oldEdges.length != 0) { model.edges = cm_edge_s.generateArray(model.numEdges); System.arraycopy(oldEdges, 0, model.edges, 0, Math.min(oldEdges.length, model.numEdges)); } @@ -7016,7 +7016,7 @@ private boolean TrmFromModel(final cm_model_s model, idTraceModel trm) { if (!TrmFromModel_r(trm, model.node)) { common.Printf("idCollisionModelManagerLocal::TrmFromModel: model %s has too many polygons.\n", model.name); PrintModelInfo(model); - return false;//HACKME::9 +// return false;//HACKME::9 } // copy vertices @@ -7045,7 +7045,7 @@ private boolean TrmFromModel(final cm_model_s model, idTraceModel trm) { if (numEdgeUsers[i] != 2) { common.Printf("idCollisionModelManagerLocal::TrmFromModel: model %s has dangling edges, the model has to be an enclosed hull.\n", model.name); PrintModelInfo(model); - return false;//HACKME::9 +// return false;//HACKME::9 } } diff --git a/src/main/java/neo/Game/Actor.java b/src/main/java/neo/Game/Actor.java index b2ee4c9b..755bfc4d 100644 --- a/src/main/java/neo/Game/Actor.java +++ b/src/main/java/neo/Game/Actor.java @@ -351,7 +351,7 @@ public static class idActor extends idAFEntity_Gibbable { // // public static idClass CreateInstance(); // public idTypeInfo GetType(); - public static idEventFunc[] eventCallbacks; +// public static idEventFunc[] eventCallbacks; // public int team; public int rank; // monsters don't fight back if the attacker's rank is higher diff --git a/src/main/java/neo/Game/Entity.java b/src/main/java/neo/Game/Entity.java index c638858a..9d2cce12 100644 --- a/src/main/java/neo/Game/Entity.java +++ b/src/main/java/neo/Game/Entity.java @@ -27,7 +27,6 @@ import neo.Game.GameSys.Class.eventCallback_t3; import neo.Game.GameSys.Class.eventCallback_t4; import neo.Game.GameSys.Class.idEventArg; -import neo.Game.GameSys.Event; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -382,7 +381,7 @@ public Class.idClass CreateInstance() { } @Override - public eventCallback_t getEventCallBack(idEventDef event) { + public final eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } @@ -3655,16 +3654,16 @@ private void UpdatePVSAreas() { ***********************************************************************/ // events - private static void Event_GetName(idEntity e) { - idThread.ReturnString(e.name.toString()); + private void Event_GetName() { + idThread.ReturnString(name.toString()); } private static void Event_SetName(idEntity e, final idEventArg newName) { e.SetName(newName.value); } - private static void Event_FindTargets(idEntity e) { - e.FindTargets(); + private void Event_FindTargets() { + FindTargets(); } /* @@ -3679,8 +3678,8 @@ private static void Event_ActivateTargets(idEntity e, idEventArg activ e.ActivateTargets(activator.value); } - private static void Event_NumTargets(idEntity e) { - idThread.ReturnFloat(e.targets.Num()); + private void Event_NumTargets() { + idThread.ReturnFloat(targets.Num()); } private static void Event_GetTarget(idEntity e, idEventArg index) { @@ -3743,15 +3742,15 @@ private static void Event_BindToJoint(idEntity e, idEventArg master, f e.BindToJoint(master.value, jointname.value, (orientated.value != 0)); } - private static void Event_Unbind(idEntity e) { - e.Unbind(); + private void Event_Unbind() { + Unbind(); } - private static void Event_RemoveBinds(idEntity e) { - e.RemoveBinds(); + private void Event_RemoveBinds() { + RemoveBinds(); } - private static void Event_SpawnBind(idEntity e) { + private void Event_SpawnBind() { idEntity parent; String[] bind = new String[1], joint = new String[1], bindanim = new String[1]; int/*jointHandle_t*/ bindJoint; @@ -3761,35 +3760,35 @@ private static void Event_SpawnBind(idEntity e) { int animNum; idAnimator parentAnimator; - if (e.spawnArgs.GetString("bind", "", bind)) { + if (spawnArgs.GetString("bind", "", bind)) { if (idStr.Icmp(bind[0], "worldspawn") == 0) { //FIXME: Completely unneccessary since the worldspawn is called "world" parent = gameLocal.world; } else { parent = gameLocal.FindEntity(bind[0]); } - bindOrientated = e.spawnArgs.GetBool("bindOrientated", "1"); + bindOrientated = spawnArgs.GetBool("bindOrientated", "1"); if (parent != null) { // bind to a joint of the skeletal model of the parent - if (e.spawnArgs.GetString("bindToJoint", "", joint) && joint[0] != null) {//TODO:check if java actually compiles them in the right order. + if (spawnArgs.GetString("bindToJoint", "", joint) && joint[0] != null) {//TODO:check if java actually compiles them in the right order. parentAnimator = parent.GetAnimator(); if (NOT(parentAnimator)) { - gameLocal.Error("Cannot bind to joint '%s' on '%s'. Entity does not support skeletal models.", joint[0], e.name); + gameLocal.Error("Cannot bind to joint '%s' on '%s'. Entity does not support skeletal models.", joint[0], name); } bindJoint = parentAnimator.GetJointHandle(joint[0]); if (bindJoint == INVALID_JOINT) { - gameLocal.Error("Joint '%s' not found for bind on '%s'", joint[0], e.name); + gameLocal.Error("Joint '%s' not found for bind on '%s'", joint[0], name); } // bind it relative to a specific anim if ((parent.spawnArgs.GetString("bindanim", "", bindanim) || parent.spawnArgs.GetString("anim", "", bindanim)) && bindanim[0] != null) { animNum = parentAnimator.GetAnim(bindanim[0]); if (0 == animNum) { - gameLocal.Error("Anim '%s' not found for bind on '%s'", bindanim[0], e.name); + gameLocal.Error("Anim '%s' not found for bind on '%s'", bindanim[0], name); } anim = parentAnimator.GetAnim(animNum); if (NOT(anim)) { - gameLocal.Error("Anim '%s' not found for bind on '%s'", bindanim[0], e.name); + gameLocal.Error("Anim '%s' not found for bind on '%s'", bindanim[0], name); } // make sure parent's render origin has been set @@ -3799,17 +3798,17 @@ private static void Event_SpawnBind(idEntity e) { parentAnimator.CreateFrame(gameLocal.time, true); idJointMat[] frame = parent.renderEntity.joints; GameEdit.gameEdit.ANIM_CreateAnimFrame(parentAnimator.ModelHandle(), anim.MD5Anim(0), parent.renderEntity.numJoints, frame, 0, parentAnimator.ModelDef().GetVisualOffset(), parentAnimator.RemoveOrigin()); - e.BindToJoint(parent, joint[0], bindOrientated); + BindToJoint(parent, joint[0], bindOrientated); parentAnimator.ForceUpdate(); } else { - e.BindToJoint(parent, joint[0], bindOrientated); + BindToJoint(parent, joint[0], bindOrientated); } } // bind to a body of the physics object of the parent - else if (e.spawnArgs.GetInt("bindToBody", "0", id)) { - e.BindToBody(parent, id[0], bindOrientated); + else if (spawnArgs.GetInt("bindToBody", "0", id)) { + BindToBody(parent, id[0], bindOrientated); } // bind to the parent else { - e.Bind(parent, bindOrientated); + Bind(parent, bindOrientated); } } } @@ -3857,23 +3856,23 @@ private static void Event_SetColor(idEntity e, idEventArg red, idEventArg e.SetColor(red.value, green.value, blue.value); } - private static void Event_GetColor(idEntity e) { + private void Event_GetColor() { idVec3 out = new idVec3(); - e.GetColor(out); + GetColor(out); idThread.ReturnVector(out); } - private static void Event_IsHidden(idEntity e) { - idThread.ReturnInt(e.fl.hidden); + private void Event_IsHidden() { + idThread.ReturnInt(fl.hidden); } - private static void Event_Hide(idEntity e) { - e.Hide(); + private void Event_Hide() { + Hide(); } - private static void Event_Show(idEntity e) { - e.Show(); + private void Event_Show() { + Show(); } private static void Event_CacheSoundShader(idEntity e, final idEventArg soundName) { @@ -3904,8 +3903,8 @@ private static void Event_FadeSound(idEntity e, idEventArg channel, idE } } - private static void Event_GetWorldOrigin(idEntity e) { - idThread.ReturnVector(e.GetPhysics().GetOrigin()); + private void Event_GetWorldOrigin() { + idThread.ReturnVector(GetPhysics().GetOrigin()); } private static void Event_SetWorldOrigin(idEntity e, final idEventArg org) { @@ -3913,16 +3912,16 @@ private static void Event_SetWorldOrigin(idEntity e, final idEventArg or e.SetOrigin(neworg); } - private static void Event_GetOrigin(idEntity e) { - idThread.ReturnVector(e.GetLocalCoordinates(e.GetPhysics().GetOrigin())); + private void Event_GetOrigin() { + idThread.ReturnVector(GetLocalCoordinates(GetPhysics().GetOrigin())); } private static void Event_SetOrigin(idEntity e, final idEventArg org) { e.SetOrigin(org.value); } - private static void Event_GetAngles(idEntity e) { - idAngles ang = e.GetPhysics().GetAxis().ToAngles(); + private void Event_GetAngles() { + idAngles ang = GetPhysics().GetAxis().ToAngles(); idThread.ReturnVector(new idVec3(ang.oGet(0), ang.oGet(1), ang.oGet(2))); } @@ -3934,35 +3933,35 @@ private static void Event_SetLinearVelocity(idEntity e, final idEventArg e.GetPhysics().SetLinearVelocity(velocity.value); } - private static void Event_GetLinearVelocity(idEntity e) { - idThread.ReturnVector(e.GetPhysics().GetLinearVelocity()); + private void Event_GetLinearVelocity() { + idThread.ReturnVector(GetPhysics().GetLinearVelocity()); } private static void Event_SetAngularVelocity(idEntity e, final idEventArg velocity) { e.GetPhysics().SetAngularVelocity(velocity.value); } - private static void Event_GetAngularVelocity(idEntity e) { - idThread.ReturnVector(e.GetPhysics().GetAngularVelocity()); + private void Event_GetAngularVelocity() { + idThread.ReturnVector(GetPhysics().GetAngularVelocity()); } private static void Event_SetSize(idEntity e, final idEventArg mins, final idEventArg maxs) { e.GetPhysics().SetClipBox(new idBounds(mins.value, maxs.value), 1.0f); } - private static void Event_GetSize(idEntity e) { + private void Event_GetSize() { idBounds bounds; - bounds = e.GetPhysics().GetBounds(); + bounds = GetPhysics().GetBounds(); idThread.ReturnVector(bounds.oGet(1).oMinus(bounds.oGet(0))); } - private static void Event_GetMins(idEntity e) { - idThread.ReturnVector(e.GetPhysics().GetBounds().oGet(0)); + private void Event_GetMins() { + idThread.ReturnVector(GetPhysics().GetBounds().oGet(0)); } - private static void Event_GetMaxs(idEntity e) { - idThread.ReturnVector(e.GetPhysics().GetBounds().oGet(1)); + private void Event_GetMaxs() { + idThread.ReturnVector(GetPhysics().GetBounds().oGet(1)); } private static void Event_Touches(idEntity e, idEventArg ent) { @@ -4069,63 +4068,63 @@ private static void Event_GetEntityKey(idEntity e, final idEventArg key) idThread.ReturnEntity(ent); } - private static void Event_RestorePosition(idEntity e) { + private void Event_RestorePosition() { idVec3 org = new idVec3(); idAngles angles = new idAngles(); idMat3 axis = new idMat3(); idEntity part; - e.spawnArgs.GetVector("origin", "0 0 0", org); + spawnArgs.GetVector("origin", "0 0 0", org); // get the rotation matrix in either full form, or single angle form - if (e.spawnArgs.GetMatrix("rotation", "1 0 0 0 1 0 0 0 1", axis)) { + if (spawnArgs.GetMatrix("rotation", "1 0 0 0 1 0 0 0 1", axis)) { angles = axis.ToAngles(); } else { angles.oSet(0, 0); - angles.oSet(1, e.spawnArgs.GetFloat("angle")); + angles.oSet(1, spawnArgs.GetFloat("angle")); angles.oSet(2, 0); } - e.Teleport(org, angles, null); + Teleport(org, angles, null); - for (part = e.teamChain; part != null; part = part.teamChain) { - if (part.bindMaster != e) { + for (part = teamChain; part != null; part = part.teamChain) { + if (part.bindMaster != this) { continue; } if (part.GetPhysics().IsType(idPhysics_Parametric.class)) { if (((idPhysics_Parametric) part.GetPhysics()).IsPusher()) { - gameLocal.Warning("teleported '%s' which has the pushing mover '%s' bound to it\n", e.GetName(), part.GetName()); + gameLocal.Warning("teleported '%s' which has the pushing mover '%s' bound to it\n", GetName(), part.GetName()); } } else if (part.GetPhysics().IsType(idPhysics_AF.class)) { - gameLocal.Warning("teleported '%s' which has the articulated figure '%s' bound to it\n", e.GetName(), part.GetName()); + gameLocal.Warning("teleported '%s' which has the articulated figure '%s' bound to it\n", GetName(), part.GetName()); } } } - private static void Event_UpdateCameraTarget(idEntity e) { + private void Event_UpdateCameraTarget() { final String target; idKeyValue kv; idVec3 dir; - target = e.spawnArgs.GetString("cameraTarget"); + target = spawnArgs.GetString("cameraTarget"); - e.cameraTarget = gameLocal.FindEntity(target); + cameraTarget = gameLocal.FindEntity(target); - if (e.cameraTarget != null) { - kv = e.cameraTarget.spawnArgs.MatchPrefix("target", null); + if (cameraTarget != null) { + kv = cameraTarget.spawnArgs.MatchPrefix("target", null); while (kv != null) { idEntity ent = gameLocal.FindEntity(kv.GetValue()); if (ent != null && idStr.Icmp(ent.GetEntityDefName(), "target_null") == 0) { - dir = ent.GetPhysics().GetOrigin().oMinus(e.cameraTarget.GetPhysics().GetOrigin()); + dir = ent.GetPhysics().GetOrigin().oMinus(cameraTarget.GetPhysics().GetOrigin()); dir.Normalize(); - e.cameraTarget.SetAxis(dir.ToMat3()); - e.SetAxis(dir.ToMat3()); + cameraTarget.SetAxis(dir.ToMat3()); + SetAxis(dir.ToMat3()); break; } - kv = e.cameraTarget.spawnArgs.MatchPrefix("target", kv); + kv = cameraTarget.spawnArgs.MatchPrefix("target", kv); } } - e.UpdateVisuals(); + UpdateVisuals(); } private static void Event_DistanceTo(idEntity e, idEventArg ent) { @@ -4631,8 +4630,8 @@ private static void Event_GetJointHandle(idAnimatedEntity e, final idEventArg eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Player_GetButtons, (eventCallback_t0) idPlayer::Event_GetButtons); + eventCallbacks.put(EV_Player_GetMove, (eventCallback_t0) idPlayer::Event_GetMove); + eventCallbacks.put(EV_Player_GetViewAngles, (eventCallback_t0) idPlayer::Event_GetViewAngles); + eventCallbacks.put(EV_Player_StopFxFov, (eventCallback_t0) idPlayer::Event_StopFxFov); + eventCallbacks.put(EV_Player_EnableWeapon, (eventCallback_t0) idPlayer::Event_EnableWeapon); + eventCallbacks.put(EV_Player_DisableWeapon, (eventCallback_t0) idPlayer::Event_DisableWeapon); + eventCallbacks.put(EV_Player_GetCurrentWeapon, (eventCallback_t0) idPlayer::Event_GetCurrentWeapon); + eventCallbacks.put(EV_Player_GetPreviousWeapon, (eventCallback_t0) idPlayer::Event_GetPreviousWeapon); + eventCallbacks.put(EV_Player_SelectWeapon, (eventCallback_t1) idPlayer::Event_SelectWeapon); + eventCallbacks.put(EV_Player_GetWeaponEntity, (eventCallback_t0) idPlayer::Event_GetWeaponEntity); + eventCallbacks.put(EV_Player_OpenPDA, (eventCallback_t0) idPlayer::Event_OpenPDA); + eventCallbacks.put(EV_Player_InPDA, (eventCallback_t0) idPlayer::Event_InPDA); + eventCallbacks.put(EV_Player_ExitTeleporter, (eventCallback_t0) idPlayer::Event_ExitTeleporter); + eventCallbacks.put(EV_Player_StopAudioLog, (eventCallback_t0) idPlayer::Event_StopAudioLog); + eventCallbacks.put(EV_Player_HideTip, (eventCallback_t0) idPlayer::Event_HideTip); + eventCallbacks.put(EV_Player_LevelTrigger, (eventCallback_t0) idPlayer::Event_LevelTrigger); + eventCallbacks.put(EV_Gibbed, (eventCallback_t0) idPlayer::Event_Gibbed); + eventCallbacks.put(EV_Player_GetIdealWeapon, (eventCallback_t0) idPlayer::Event_GetIdealWeapon); + } // enum { public static final int EVENT_IMPULSE = idEntity.EVENT_MAXEVENTS; @@ -3888,84 +3912,32 @@ public void CalculateRenderView() { // called every tic by player code } /* - ================== - idPlayer::CalculateRenderView - - create the renderView for the current tic - ================== - */ + =============== + idPlayer::CalculateFirstPersonView + =============== + */ public void CalculateFirstPersonView() { - int i; - float range; + if ((pm_modelView.GetInteger() == 1) || ((pm_modelView.GetInteger() == 2) && (health <= 0))) { + // Displays the view from the point of view of the "camera" joint in the player model - if (NOT(renderView)) { - renderView = new renderView_s(); - } - renderView = new renderView_s(); -// memset( renderView, 0, sizeof( *renderView ) ); - - // copy global shader parms - for (i = 0; i < MAX_GLOBAL_SHADER_PARMS; i++) { - renderView.shaderParms[i] = gameLocal.globalShaderParms[i]; - } - renderView.globalMaterial = gameLocal.GetGlobalMaterial(); - renderView.time = gameLocal.time; + idMat3 axis = new idMat3(); + idVec3 origin = new idVec3(); + idAngles ang; - // calculate size of 3D view - renderView.x = 0; - renderView.y = 0; - renderView.width = SCREEN_WIDTH; - renderView.height = SCREEN_HEIGHT; - renderView.viewID = 0; + ang = viewBobAngles.oPlus(playerView.AngleOffset()); + ang.yaw += viewAxis.oGet(0).ToYaw(); - // check if we should be drawing from a camera's POV - if (!noclip && (gameLocal.GetCamera() != null || privateCameraView != null)) { - // get origin, axis, and fov - if (privateCameraView != null) { - privateCameraView.GetViewParms(renderView); - } else { - gameLocal.GetCamera().GetViewParms(renderView); - } + int joint = animator.GetJointHandle("camera"); + animator.GetJointTransform(joint, gameLocal.time, origin, axis); + firstPersonViewOrigin = (origin.oPlus(modelOffset)).oMultiply(viewAxis.oMultiply(physicsObj.GetGravityAxis())).oPlus(physicsObj.GetOrigin()).oPlus(viewBob); + firstPersonViewAxis = axis.oMultiply(ang.ToMat3()).oMultiply(physicsObj.GetGravityAxis()); } else { - if (g_stopTime.GetBool()) { - renderView.vieworg = new idVec3(firstPersonViewOrigin); - renderView.viewaxis = new idMat3(firstPersonViewAxis); - - if (!pm_thirdPerson.GetBool()) { - // set the viewID to the clientNum + 1, so we can suppress the right player bodies and - // allow the right player view weapons - renderView.viewID = entityNumber + 1; - } - } else if (pm_thirdPerson.GetBool()) { - OffsetThirdPersonView(pm_thirdPersonAngle.GetFloat(), pm_thirdPersonRange.GetFloat(), pm_thirdPersonHeight.GetFloat(), pm_thirdPersonClip.GetBool()); - } else if (pm_thirdPersonDeath.GetBool()) { - range = gameLocal.time < minRespawnTime ? (gameLocal.time + RAGDOLL_DEATH_TIME - minRespawnTime) * (120 / RAGDOLL_DEATH_TIME) : 120; - OffsetThirdPersonView(0, 20 + range, 0, false); - } else { - renderView.vieworg = new idVec3(firstPersonViewOrigin); - renderView.viewaxis = new idMat3(firstPersonViewAxis); - - // set the viewID to the clientNum + 1, so we can suppress the right player bodies and - // allow the right player view weapons - renderView.viewID = entityNumber + 1; + // offset for local bobbing and kicks + GetViewPos(firstPersonViewOrigin, firstPersonViewAxis); + if (false) { + // shakefrom sound stuff only happens in first person + firstPersonViewAxis = firstPersonViewAxis.oMultiply(playerView.ShakeAxis()); } - - // field of view - { - float[] fov_x = {renderView.fov_x}; - float[] fov_y = {renderView.fov_y}; - gameLocal.CalcFov(CalcFov(true), fov_x, fov_y); - renderView.fov_x = fov_x[0]; - renderView.fov_y = fov_y[0]; - } - } - - if (renderView.fov_y == 0) { - common.Error("renderView.fov_y == 0"); - } - - if (g_showviewpos.GetBool()) { - gameLocal.Printf("%s : %s\n", renderView.vieworg.ToString(), renderView.viewaxis.ToAngles().ToString()); } } @@ -8316,7 +8288,7 @@ private void Event_GetPreviousWeapon() { } } - private void Event_SelectWeapon(final String weaponName) { + private static void Event_SelectWeapon(idPlayer p, final idEventArg weaponName) { int i; int weaponNum; @@ -8325,17 +8297,17 @@ private void Event_SelectWeapon(final String weaponName) { return; } - if (hiddenWeapon && gameLocal.world.spawnArgs.GetBool("no_Weapons")) { - idealWeapon = weapon_fists; - weapon.GetEntity().HideWeapon(); + if (p.hiddenWeapon && gameLocal.world.spawnArgs.GetBool("no_Weapons")) { + p.idealWeapon = p.weapon_fists; + p.weapon.GetEntity().HideWeapon(); return; } weaponNum = -1; for (i = 0; i < MAX_WEAPONS; i++) { - if ((inventory.weapons & (1 << i)) != 0) { - final String weap = spawnArgs.GetString(va("def_weapon%d", i)); - if (NOT(idStr.Cmp(weap, weaponName))) { + if ((p.inventory.weapons & (1 << i)) != 0) { + final String weap = p.spawnArgs.GetString(va("def_weapon%d", i)); + if (NOT(idStr.Cmp(weap, weaponName.value))) { weaponNum = i; break; } @@ -8343,14 +8315,14 @@ private void Event_SelectWeapon(final String weaponName) { } if (weaponNum < 0) { - gameLocal.Warning("%s is not carrying weapon '%s'", name, weaponName); + gameLocal.Warning("%s is not carrying weapon '%s'", p.name, weaponName.value); return; } - hiddenWeapon = false; - idealWeapon = weaponNum; + p.hiddenWeapon = false; + p.idealWeapon = weaponNum; - UpdateHudWeapon(); + p.UpdateHudWeapon(); } private void Event_GetWeaponEntity() { diff --git a/src/main/java/neo/Game/Script/Script_Thread.java b/src/main/java/neo/Game/Script/Script_Thread.java index 5cc4cda2..4f386bbf 100644 --- a/src/main/java/neo/Game/Script/Script_Thread.java +++ b/src/main/java/neo/Game/Script/Script_Thread.java @@ -286,8 +286,8 @@ private void Pause() { interpreter.doneProcessing = true; } - private static void Event_Execute(idThread t) { - t.Execute(); + private void Event_Execute() { + Execute(); } private static void Event_SetThreadName(idThread t, final idEventArg name) { @@ -304,16 +304,16 @@ private static void Event_TerminateThread(idThread t, idEventArg num) { t.KillThread(num.value); } - private static void Event_Pause(idThread t) { - t.Pause(); + private void Event_Pause() { + Pause(); } private static void Event_Wait(idThread t, idEventArg time) { t.WaitSec(time.value); } - private static void Event_WaitFrame(idThread t) { - t.WaitFrame(); + private void Event_WaitFrame() { + WaitFrame(); } private static void Event_WaitFor(idThread t, idEventArg e) { @@ -382,7 +382,7 @@ private static void Event_Random(idThread t, idEventArg range) { ReturnFloat(range.value * result); } - private static void Event_GetTime(idThread t) { + private void Event_GetTime() { ReturnFloat(MS2SEC(gameLocal.realClientTime)); } @@ -448,7 +448,7 @@ private static void Event_SpawnVector(idThread t, final idEventArg key, ReturnVector(result); } - private static void Event_ClearPersistantArgs(idThread t) { + private void Event_ClearPersistantArgs() { gameLocal.persistentLevelInfo.Clear(); } @@ -587,7 +587,7 @@ private static void Event_SetCamera(idThread t, idEventArg e) { gameLocal.SetCamera((idCamera) ent); } - private static void Event_FirstPerson(idThread t) { + private void Event_FirstPerson() { gameLocal.SetCamera(null); } @@ -625,15 +625,15 @@ private static void Event_TracePoint(idThread t, final idEventArg startA ReturnFloat(trace.fraction); } - private static void Event_GetTraceFraction(idThread t) { + private void Event_GetTraceFraction() { ReturnFloat(trace.fraction); } - private static void Event_GetTraceEndPos(idThread t) { + private void Event_GetTraceEndPos() { ReturnVector(trace.endpos); } - private static void Event_GetTraceNormal(idThread t) { + private void Event_GetTraceNormal() { if (trace.fraction < 1.0f) { ReturnVector(trace.c.normal); } else { @@ -641,7 +641,7 @@ private static void Event_GetTraceNormal(idThread t) { } } - private static void Event_GetTraceEntity(idThread t) { + private void Event_GetTraceEntity() { if (trace.fraction < 1.0f) { ReturnEntity(gameLocal.entities[ trace.c.entityNum]); } else { @@ -649,7 +649,7 @@ private static void Event_GetTraceEntity(idThread t) { } } - private static void Event_GetTraceJoint(idThread t) { + private void Event_GetTraceJoint() { if (trace.fraction < 1.0f && trace.c.id < 0) { idAFEntity_Base af = (idAFEntity_Base) gameLocal.entities[trace.c.entityNum]; if (af != null && af.IsType(idAFEntity_Base.class) && af.IsActiveAF()) { @@ -660,7 +660,7 @@ private static void Event_GetTraceJoint(idThread t) { ReturnString(""); } - private static void Event_GetTraceBody(idThread t) { + private void Event_GetTraceBody() { if (trace.fraction < 1.0f && trace.c.id < 0) { idAFEntity_Base af = (idAFEntity_Base) gameLocal.entities[ trace.c.entityNum]; if (af != null && af.IsType(idAFEntity_Base.class) && af.IsActiveAF()) { @@ -837,19 +837,19 @@ private static void Event_RadiusDamage(idThread t, final idEventArg orig gameLocal.RadiusDamage(origin.value, inflictor.value, attacker.value, ignore.value, ignore.value, damageDefName.value, dmgPower.value); } - private static void Event_IsClient(idThread t) { + private void Event_IsClient() { idThread.ReturnFloat(btoi(gameLocal.isClient)); } - private static void Event_IsMultiplayer(idThread t) { + private void Event_IsMultiplayer() { idThread.ReturnFloat(btoi(gameLocal.isMultiplayer)); } - private static void Event_GetFrameTime(idThread t) { + private void Event_GetFrameTime() { idThread.ReturnFloat(MS2SEC(gameLocal.msec)); } - private static void Event_GetTicsPerSecond(idThread t) { + private void Event_GetTicsPerSecond() { idThread.ReturnFloat(USERCMD_HZ); } @@ -882,7 +882,7 @@ private static void Event_DrawText(idThread t, final idEventArg text, fi gameRenderWorld.DrawText(text.value, origin.value, scale.value, new idVec4(color.x, color.y, color.z, 0.0f), gameLocal.GetLocalPlayer().viewAngles.ToMat3(), align.value, (int) SEC2MS(lifetime.value)); } - private static void Event_InfluenceActive(idThread t) { + private void Event_InfluenceActive() { idPlayer player; player = gameLocal.GetLocalPlayer(); diff --git a/src/main/java/neo/Renderer/Model.java b/src/main/java/neo/Renderer/Model.java index 88687bea..18e3d671 100644 --- a/src/main/java/neo/Renderer/Model.java +++ b/src/main/java/neo/Renderer/Model.java @@ -101,7 +101,7 @@ public static ByteBuffer toByteBuffer(lightingCache_s[] cache) { public static class shadowCache_s { - private static final int BYTES = idVec4.BYTES; + public static final int BYTES = idVec4.BYTES; public idVec4 xyz; // we use homogenous coordinate tricks diff --git a/src/main/java/neo/Renderer/ModelManager.java b/src/main/java/neo/Renderer/ModelManager.java index 1963cb26..0050ab68 100644 --- a/src/main/java/neo/Renderer/ModelManager.java +++ b/src/main/java/neo/Renderer/ModelManager.java @@ -469,10 +469,11 @@ private idRenderModel GetModel(final String modelName, boolean createIfNotFound) model.InitFromFile(modelName); //HACKME::9 - idRenderModelStatic m = (idRenderModelStatic) model; +// idRenderModelStatic m = (idRenderModelStatic) model; // for (modelSurface_s mimi : m.surfaces.Ptr(modelSurface_s[].class)) { // for (int i = 0; i < mimi.geometry.numVerts; i++) { -// mimi.geometry.verts[i].xyz.oMinSet(0, 999); +// final Vector.idVec3 xyz = mimi.geometry.verts[i].xyz; +// xyz.oSet(xyz.oPlus(-50)); // } // } } else if (extension.Icmp("ma") == 0) { diff --git a/src/main/java/neo/Renderer/Model_ase.java b/src/main/java/neo/Renderer/Model_ase.java index 19bb0c85..66af253d 100644 --- a/src/main/java/neo/Renderer/Model_ase.java +++ b/src/main/java/neo/Renderer/Model_ase.java @@ -1018,7 +1018,9 @@ public void run(final String token) { // ignore regular meshes that aren't part of animation case "*MESH": + idVec3[] transform = ase.currentObject.mesh.transform;//copied from the bfg sources ase.currentMesh = ase.currentObject.mesh = new aseMesh_t(); + System.arraycopy(transform, 0, ase.currentMesh.transform, 0, transform.length); ASE_ParseBracedBlock(ASE_KeyMESH.getInstance()); break; diff --git a/src/main/java/neo/Renderer/Model_local.java b/src/main/java/neo/Renderer/Model_local.java index 09de412a..ba532125 100644 --- a/src/main/java/neo/Renderer/Model_local.java +++ b/src/main/java/neo/Renderer/Model_local.java @@ -55,7 +55,6 @@ import static neo.Renderer.tr_trisurf.R_TriSurfMemory; import static neo.TempDump.NOT; import static neo.TempDump.ctos; -import static neo.TempDump.indexOf; import static neo.TempDump.sizeof; import static neo.framework.CVarSystem.CVAR_BOOL; import static neo.framework.CVarSystem.CVAR_RENDERER; @@ -1015,7 +1014,10 @@ static class matchVert_s { short[] color = new short[4]; idVec3 normal = new idVec3(); - public matchVert_s() { + final int index; + + public matchVert_s(int numVerts) { + this.index = numVerts; } // static int getPosition(matchVert_s v1, matchVert_s[] vList) { @@ -1050,15 +1052,15 @@ public boolean equals(final Object o) { } - static matchVert_s[] generateArray(final int length) { - return Stream. - generate(matchVert_s::new). - limit(length). - toArray(matchVert_s[]::new); - } +// static matchVert_s[] generateArray(final int length) { +// return Stream. +// generate(matchVert_s::new). +// limit(length). +// toArray(matchVert_s[]::new); +// } }; static final short[] identityColor/*[4]*/ = {255, 255, 255, 255}; - + private static int DBG_ConvertASEToModelSurfaces = 0; public boolean ConvertASEToModelSurfaces(final aseModel_s ase) { aseObject_t object; aseMesh_t mesh; @@ -1284,7 +1286,7 @@ public boolean ConvertASEToModelSurfaces(final aseModel_s ase) { } if (null == mv) { // allocate a new match vert and link to hash chain - mv = mvTable[tri.numVerts] = new matchVert_s(); + mv = mvTable[tri.numVerts] = new matchVert_s(tri.numVerts); mv.v = v; mv.tv = tv; mv.normal.oSet(normal); @@ -1298,7 +1300,7 @@ public boolean ConvertASEToModelSurfaces(final aseModel_s ase) { tri.numVerts++; } - tri.indexes[tri.numIndexes] = indexOf(mv, mvTable); + tri.indexes[tri.numIndexes] = mv.index; tri.numIndexes++; } } @@ -1332,9 +1334,9 @@ public boolean ConvertASEToModelSurfaces(final aseModel_s ase) { for (j = 0; j < tri.numVerts; j++) { mv = mvTable[j]; tri.verts[ j].Clear(); - tri.verts[ j].xyz = mesh.vertexes[ mv.v]; - tri.verts[ j].normal = mv.normal; - tri.verts[j].color = mv.color; + tri.verts[ j].xyz.oSet(mesh.vertexes[ mv.v]); + tri.verts[ j].normal.oSet(mv.normal); + System.arraycopy(mv.color, 0, tri.verts[j].color = mv.color, 0, mv.color.length); if (mesh.numTVFaces == mesh.numFaces && mesh.numTVertexes != 0) { final idVec2 tv2 = mesh.tvertexes[ mv.tv]; float u = tv2.x * uTiling + uOffset; @@ -1640,7 +1642,7 @@ public boolean ConvertASEToModelSurfaces(final aseModel_s ase) { if (mv.tv != tv) { continue; } - if (mv.color != color) { + if (!Arrays.equals(mv.color, color)) { continue; } if (!normalsParsed) { @@ -1654,7 +1656,7 @@ public boolean ConvertASEToModelSurfaces(final aseModel_s ase) { } if (null == mv) { // allocate a new match vert and link to hash chain - mv = mvTable[tri.numVerts] = new matchVert_s(); + mv = mvTable[tri.numVerts] = new matchVert_s(tri.numVerts); mv.v = v; mv.tv = tv; mv.normal.oSet(normal); @@ -1668,7 +1670,7 @@ public boolean ConvertASEToModelSurfaces(final aseModel_s ase) { tri.numVerts++; } - tri.indexes[tri.numIndexes] = indexOf(mv, mvTable); + tri.indexes[tri.numIndexes] = mv.index; tri.numIndexes++; } } @@ -1941,7 +1943,7 @@ public boolean ConvertMAToModelSurfaces(final maModel_s ma) { if (mv.tv != tv) { continue; } - if (mv.color != color) { + if (!Arrays.equals(mv.color, color)) { continue; } if (!normalsParsed) { @@ -1955,7 +1957,7 @@ public boolean ConvertMAToModelSurfaces(final maModel_s ma) { } if (null == mv) { // allocate a new match vert and link to hash chain - mv = mvTable[tri.numVerts] = new matchVert_s(); + mv = mvTable[tri.numVerts] = new matchVert_s(tri.numVerts); mv.v = v; mv.tv = tv; mv.normal.oSet(normal); @@ -1969,7 +1971,7 @@ public boolean ConvertMAToModelSurfaces(final maModel_s ma) { tri.numVerts++; } - tri.indexes[tri.numIndexes] = indexOf(mv, mvTable); + tri.indexes[tri.numIndexes] = mv.index; tri.numIndexes++; } } diff --git a/src/main/java/neo/Renderer/RenderSystem_init.java b/src/main/java/neo/Renderer/RenderSystem_init.java index e0ad7ca1..f453114b 100644 --- a/src/main/java/neo/Renderer/RenderSystem_init.java +++ b/src/main/java/neo/Renderer/RenderSystem_init.java @@ -453,7 +453,7 @@ public class RenderSystem_init { r_showIntensity = new idCVar("r_showIntensity", "0", CVAR_RENDERER | CVAR_BOOL, "draw the screen colors based on intensity, red = 0, green = 128, blue = 255"); r_showImages = new idCVar("r_showImages", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = show all images instead of rendering, 2 = show in proportional size", 0, 2, new idCmdSystem.ArgCompletion_Integer(0, 2)); r_showSmp = new idCVar("r_showSmp", "0", CVAR_RENDERER | CVAR_BOOL, "show which end =new idCVar(front or back) is blocking"); - r_showLights = new idCVar("r_showLights", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = just print volumes numbers, highlighting ones covering the view, 2 = also draw planes of each volume, 3 = also draw edges of each volume", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); + r_showLights = new idCVar("r_showLights", "2", CVAR_RENDERER | CVAR_INTEGER, "1 = just print volumes numbers, highlighting ones covering the view, 2 = also draw planes of each volume, 3 = also draw edges of each volume", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); r_showShadows = new idCVar("r_showShadows", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = visualize the stencil shadow volumes, 2 = draw filled in", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); r_showShadowCount = new idCVar("r_showShadowCount", "0", CVAR_RENDERER | CVAR_INTEGER, "colors screen based on shadow volume depth complexity, >= 2 = print overdraw count based on stencil index values, 3 = only show turboshadows, 4 = only show static shadows", 0, 4, new idCmdSystem.ArgCompletion_Integer(0, 4)); r_showLightScissors = new idCVar("r_showLightScissors", "0", CVAR_RENDERER | CVAR_BOOL, "show light scissor rectangles"); @@ -461,8 +461,8 @@ public class RenderSystem_init { r_showInteractionFrustums = new idCVar("r_showInteractionFrustums", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = show a frustum for each interaction, 2 = also draw lines to light origin, 3 = also draw entity bbox", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); r_showInteractionScissors = new idCVar("r_showInteractionScissors", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = show screen rectangle which contains the interaction frustum, 2 = also draw construction lines", 0, 2, new idCmdSystem.ArgCompletion_Integer(0, 2)); r_showLightCount = new idCVar("r_showLightCount", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = colors surfaces based on light count, 2 = also count everything through walls, 3 = also print overdraw", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); - r_showViewEntitys = new idCVar("r_showViewEntitys", "1", CVAR_RENDERER | CVAR_INTEGER, "1 = displays the bounding boxes of all view models, 2 = print index numbers"); - r_showTris = new idCVar("r_showTris", "3", CVAR_RENDERER | CVAR_INTEGER, "enables wireframe rendering of the world, 1 = only draw visible ones, 2 = draw all front facing, 3 = draw all", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); + r_showViewEntitys = new idCVar("r_showViewEntitys", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = displays the bounding boxes of all view models, 2 = print index numbers"); + r_showTris = new idCVar("r_showTris", "1", CVAR_RENDERER | CVAR_INTEGER, "enables wireframe rendering of the world, 1 = only draw visible ones, 2 = draw all front facing, 3 = draw all", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); r_showSurfaceInfo = new idCVar("r_showSurfaceInfo", "0", CVAR_RENDERER | CVAR_BOOL, "show surface material name under crosshair"); r_showNormals = new idCVar("r_showNormals", "0", CVAR_RENDERER | CVAR_FLOAT, "draws wireframe normals"); r_showMemory = new idCVar("r_showMemory", "0", CVAR_RENDERER | CVAR_BOOL, "print frame memory utilization"); diff --git a/src/main/java/neo/Renderer/draw_common.java b/src/main/java/neo/Renderer/draw_common.java index 61121926..6f7ea641 100644 --- a/src/main/java/neo/Renderer/draw_common.java +++ b/src/main/java/neo/Renderer/draw_common.java @@ -1278,7 +1278,7 @@ void run(final drawSurf_s surf) { return; } - qglVertexPointer(4, GL_FLOAT, 0/*sizeof(shadowCache_s)*/, vertexCache.Position(tri.shadowCache).getInt()); + qglVertexPointer(4, GL_FLOAT, shadowCache_s.BYTES, vertexCache.Position(tri.shadowCache).getInt()); // we always draw the sil planes, but we may not need to draw the front or rear caps int numIndexes; diff --git a/src/main/java/neo/Renderer/qgl.java b/src/main/java/neo/Renderer/qgl.java index d0e31603..1ee769eb 100644 --- a/src/main/java/neo/Renderer/qgl.java +++ b/src/main/java/neo/Renderer/qgl.java @@ -6,6 +6,7 @@ import java.nio.IntBuffer; import neo.TempDump; import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.ARBBufferObject; import org.lwjgl.opengl.ARBImaging; import org.lwjgl.opengl.ARBProgram; import org.lwjgl.opengl.ARBTextureCompression; @@ -55,7 +56,8 @@ public class qgl { //extern PFNGLISBUFFERARBPROC qglIsBufferARB; public static void qglBufferDataARB(int target, int size, ByteBuffer data, int usage) {DEBUG_printName("glBufferDataARB"); - GL15.glBufferData(target, data, usage);//TODO:!!!!!!!!!!!!!!!!!!!!!!!!! +// GL15.glBufferData(target, data, usage);//TODO:!!!!!!!!!!!!!!!!!!!!!!!!! + ARBBufferObject.glBufferDataARB(target, data, usage); } public static /*PFNGLBUFFERSUBDATAARBPROC*/void qglBufferSubDataARB(int target, long offset, long size, ByteBuffer data) {DEBUG_printName("glBufferSubDataARB"); diff --git a/src/main/java/neo/Renderer/tr_rendertools.java b/src/main/java/neo/Renderer/tr_rendertools.java index daec8e08..592cecd0 100644 --- a/src/main/java/neo/Renderer/tr_rendertools.java +++ b/src/main/java/neo/Renderer/tr_rendertools.java @@ -668,7 +668,7 @@ public static void RB_ShowLightCount() { } final idDrawVert ac = new idDrawVert(vertexCache.Position(surf.geo.ambientCache));//TODO:figure out how to work these damn casts. - qglVertexPointer(3, GL_FLOAT, 0/*sizeof(idDrawVert)*/, ac.xyzOffset()); + qglVertexPointer(3, GL_FLOAT, idDrawVert.BYTES, ac.xyzOffset()); RB_DrawElementsWithCounters(surf.geo); } } @@ -733,7 +733,7 @@ public static void RB_ShowSilhouette() { final srfTriangles_s tri = surf.geo; for (vertCache_s shadow : tri.shadowCache) { - qglVertexPointer(3, GL_FLOAT, 0/*sizeof(shadowCache_s)*/, vertexCache.Position(shadow).getInt()); + qglVertexPointer(3, GL_FLOAT, shadowCache_s.BYTES, vertexCache.Position(shadow).getInt()); } qglBegin(GL_LINES); diff --git a/src/main/java/neo/framework/UsercmdGen.java b/src/main/java/neo/framework/UsercmdGen.java index c532a112..73ab3db8 100644 --- a/src/main/java/neo/framework/UsercmdGen.java +++ b/src/main/java/neo/framework/UsercmdGen.java @@ -883,7 +883,7 @@ private void MakeCurrent() { idVec3 oldAngles; int i; - oldAngles = viewangles; + oldAngles = new idVec3(viewangles); if (!Inhibited()) { // update toggled key states diff --git a/src/misc/bug_report_04.txt b/src/misc/bug_report_04.txt index 5c1a2353..5d8a5640 100644 --- a/src/misc/bug_report_04.txt +++ b/src/misc/bug_report_04.txt @@ -85,7 +85,33 @@ blanco ingame, go: -((*(((ase)->objects).list))->mesh).faces.faceNormal -mesh->faces[j].vertexColors as well -((*(((ase)->objects).list))->mesh).transform - + -ASE_KeyMESH() + -ASE_KeyMESH_NORMALS() + -ASE_KeyNODE_TM() + -GEOMOBJECT() + -::DeriveUnsmoothedTangents(), verts match, but dominantTris don't + -our version is printing out a shitload more xyz, almost tenfold + -we were printing the wrong function, it's still 25% more though. + -just had an idea to disable ConvertLWOToModelSurfaces(), and naturally the planet disappears, but also some of the ingame wireframes. + Most surprising, is the fact that some of the wireframes seem to be moving now. + but we STILL can't move, meaning something is wrong with our input. + -however, the cpp version is crashing...why isn't ours crashing? + -let's try isolating the spinning wireframe, and see if we can move it + -qglVertexPointer() + -RB_STD_T_RenderShaderPasses() + !@#$WE^Y%*&(^)&%^$E&URKYGF Date: Wed, 11 May 2016 16:32:18 +0200 Subject: [PATCH 10/17] events, part1: -Misc.cpp -Refactored some of the idEntity/idPlayer events --- src/main/java/neo/Game/Entity.java | 11 +- src/main/java/neo/Game/GameSys/Class.java | 55 ++- src/main/java/neo/Game/Misc.java | 431 +++++++++++++++++----- src/main/java/neo/Game/Player.java | 31 +- 4 files changed, 399 insertions(+), 129 deletions(-) diff --git a/src/main/java/neo/Game/Entity.java b/src/main/java/neo/Game/Entity.java index 9d2cce12..8868a498 100644 --- a/src/main/java/neo/Game/Entity.java +++ b/src/main/java/neo/Game/Entity.java @@ -275,7 +275,7 @@ public static class signalList_t { public static class idEntity extends neo.Game.GameSys.Class.idClass implements neo.TempDump.NiLLABLE, neo.TempDump.SERiAL { // ABSTRACT_PROTOTYPE( idEntity ); - protected static Map eventCallbacks = new HashMap<>(); + private static Map eventCallbacks = new HashMap<>(); static { eventCallbacks.put(EV_GetName, (eventCallback_t0) idEntity::Event_GetName); eventCallbacks.put(EV_SetName, (eventCallback_t1) idEntity::Event_SetName); @@ -381,7 +381,7 @@ public Class.idClass CreateInstance() { } @Override - public final eventCallback_t getEventCallBack(idEventDef event) { + public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } @@ -4236,7 +4236,7 @@ public static class damageEffect_s { =============================================================================== */ public static class idAnimatedEntity extends idEntity { - + private static Map eventCallbacks = new HashMap<>(); static { eventCallbacks.put(EV_GetJointHandle, (eventCallback_t1) idAnimatedEntity::Event_GetJointHandle); eventCallbacks.put(EV_ClearAllJoints, (eventCallback_t0) idAnimatedEntity::Event_ClearAllJoints); @@ -4751,6 +4751,11 @@ public final void idEntity_ProjectOverlay(final idVec3 origin, final idVec3 dir, public final boolean idEntity_ServerReceiveEvent(int event, int time, final idBitMsg msg) { return super.ServerReceiveEvent(event, time, msg); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } } /* diff --git a/src/main/java/neo/Game/GameSys/Class.java b/src/main/java/neo/Game/GameSys/Class.java index 7a48559b..fb51a1ab 100644 --- a/src/main/java/neo/Game/GameSys/Class.java +++ b/src/main/java/neo/Game/GameSys/Class.java @@ -1,10 +1,9 @@ package neo.Game.GameSys; -import java.nio.ByteBuffer; import neo.CM.CollisionModel.trace_s; import static neo.Game.Entity.EV_Activate; import neo.Game.Entity.idEntity; -import static neo.Game.GameSys.Class.idEventArg.toEvent; +import static neo.Game.GameSys.Class.idEventArg.toArg; import static neo.Game.GameSys.Event.D_EVENT_ENTITY; import static neo.Game.GameSys.Event.D_EVENT_FLOAT; import static neo.Game.GameSys.Event.D_EVENT_INTEGER; @@ -163,8 +162,8 @@ public idEventArg(T data) { else type = D_EVENT_VOID; value = data; } - - static idEventArg toEvent(Object data) { + + public static idEventArg toArg(T data) { return new idEventArg(data); } }; @@ -341,35 +340,35 @@ public boolean PostEventMS(final idEventDef ev, int time) { } public boolean PostEventMS(final idEventDef ev, float time, Object arg1) { - return PostEventArgs(ev, (int) time, 1, toEvent(arg1)); + return PostEventArgs(ev, (int) time, 1, toArg(arg1)); } public boolean PostEventMS(final idEventDef ev, int time, Object arg1, Object arg2) { - return PostEventArgs(ev, time, 2, toEvent(arg1), toEvent(arg1)); + return PostEventArgs(ev, time, 2, toArg(arg1), toArg(arg1)); } public boolean PostEventMS(final idEventDef ev, int time, Object arg1, Object arg2, Object arg3) { - return PostEventArgs(ev, time, 3, toEvent(arg1), toEvent(arg2), toEvent(arg3)); + return PostEventArgs(ev, time, 3, toArg(arg1), toArg(arg2), toArg(arg3)); } public boolean PostEventMS(final idEventDef ev, int time, Object arg1, Object arg2, Object arg3, Object arg4) { - return PostEventArgs(ev, time, 4, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4)); + return PostEventArgs(ev, time, 4, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4)); } public boolean PostEventMS(final idEventDef ev, int time, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) { - return PostEventArgs(ev, time, 5, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4), toEvent(arg5)); + return PostEventArgs(ev, time, 5, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4), toArg(arg5)); } public boolean PostEventMS(final idEventDef ev, int time, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) { - return PostEventArgs(ev, time, 6, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4), toEvent(arg5), toEvent(arg6)); + return PostEventArgs(ev, time, 6, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4), toArg(arg5), toArg(arg6)); } public boolean PostEventMS(final idEventDef ev, int time, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) { - return PostEventArgs(ev, time, 7, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4), toEvent(arg5), toEvent(arg6), toEvent(arg7)); + return PostEventArgs(ev, time, 7, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4), toArg(arg5), toArg(arg6), toArg(arg7)); } public boolean PostEventMS(final idEventDef ev, int time, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8) { - return PostEventArgs(ev, time, 8, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4), toEvent(arg5), toEvent(arg6), toEvent(arg7), toEvent(arg8)); + return PostEventArgs(ev, time, 8, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4), toArg(arg5), toArg(arg6), toArg(arg7), toArg(arg8)); } public boolean PostEventSec(final idEventDef ev, float time) { @@ -377,35 +376,35 @@ public boolean PostEventSec(final idEventDef ev, float time) { } public boolean PostEventSec(final idEventDef ev, float time, Object arg1) { - return PostEventArgs(ev, (int) SEC2MS(time), 1, toEvent(arg1)); + return PostEventArgs(ev, (int) SEC2MS(time), 1, toArg(arg1)); } public boolean PostEventSec(final idEventDef ev, float time, Object arg1, Object arg2) { - return PostEventArgs(ev, (int) SEC2MS(time), 2, toEvent(arg1), toEvent(arg2)); + return PostEventArgs(ev, (int) SEC2MS(time), 2, toArg(arg1), toArg(arg2)); } public boolean PostEventSec(final idEventDef ev, float time, Object arg1, Object arg2, Object arg3) { - return PostEventArgs(ev, (int) SEC2MS(time), 3, toEvent(arg1), toEvent(arg2), toEvent(arg3)); + return PostEventArgs(ev, (int) SEC2MS(time), 3, toArg(arg1), toArg(arg2), toArg(arg3)); } public boolean PostEventSec(final idEventDef ev, float time, Object arg1, Object arg2, Object arg3, Object arg4) { - return PostEventArgs(ev, (int) SEC2MS(time), 4, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4)); + return PostEventArgs(ev, (int) SEC2MS(time), 4, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4)); } public boolean PostEventSec(final idEventDef ev, float time, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) { - return PostEventArgs(ev, (int) SEC2MS(time), 5, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4), toEvent(arg5)); + return PostEventArgs(ev, (int) SEC2MS(time), 5, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4), toArg(arg5)); } public boolean PostEventSec(final idEventDef ev, float time, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) { - return PostEventArgs(ev, (int) SEC2MS(time), 6, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4), toEvent(arg5), toEvent(arg6)); + return PostEventArgs(ev, (int) SEC2MS(time), 6, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4), toArg(arg5), toArg(arg6)); } public boolean PostEventSec(final idEventDef ev, float time, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) { - return PostEventArgs(ev, (int) SEC2MS(time), 7, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4), toEvent(arg5), toEvent(arg6), toEvent(arg7)); + return PostEventArgs(ev, (int) SEC2MS(time), 7, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4), toArg(arg5), toArg(arg6), toArg(arg7)); } public boolean PostEventSec(final idEventDef ev, float time, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8) { - return PostEventArgs(ev, (int) SEC2MS(time), 8, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4), toEvent(arg5), toEvent(arg6), toEvent(arg7), toEvent(arg8)); + return PostEventArgs(ev, (int) SEC2MS(time), 8, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4), toArg(arg5), toArg(arg6), toArg(arg7), toArg(arg8)); } public boolean ProcessEvent(final idEventDef ev) { @@ -413,35 +412,35 @@ public boolean ProcessEvent(final idEventDef ev) { } public boolean ProcessEvent(final idEventDef ev, Object arg1) { - return ProcessEventArgs(ev, 1, toEvent(arg1)); + return ProcessEventArgs(ev, 1, toArg(arg1)); } public boolean ProcessEvent(final idEventDef ev, Object arg1, Object arg2) { - return ProcessEventArgs(ev, 2, toEvent(arg1), toEvent(arg2)); + return ProcessEventArgs(ev, 2, toArg(arg1), toArg(arg2)); } public boolean ProcessEvent(final idEventDef ev, Object arg1, Object arg2, Object arg3) { - return ProcessEventArgs(ev, 3, toEvent(arg1), toEvent(arg2), toEvent(arg3)); + return ProcessEventArgs(ev, 3, toArg(arg1), toArg(arg2), toArg(arg3)); } public boolean ProcessEvent(final idEventDef ev, Object arg1, Object arg2, Object arg3, Object arg4) { - return ProcessEventArgs(ev, 4, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4)); + return ProcessEventArgs(ev, 4, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4)); } public boolean ProcessEvent(final idEventDef ev, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) { - return ProcessEventArgs(ev, 5, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4), toEvent(arg5)); + return ProcessEventArgs(ev, 5, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4), toArg(arg5)); } public boolean ProcessEvent(final idEventDef ev, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) { - return ProcessEventArgs(ev, 6, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4), toEvent(arg5), toEvent(arg6)); + return ProcessEventArgs(ev, 6, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4), toArg(arg5), toArg(arg6)); } public boolean ProcessEvent(final idEventDef ev, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) { - return ProcessEventArgs(ev, 7, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4), toEvent(arg5), toEvent(arg6), toEvent(arg7)); + return ProcessEventArgs(ev, 7, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4), toArg(arg5), toArg(arg6), toArg(arg7)); } public boolean ProcessEvent(final idEventDef ev, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8) { - return ProcessEventArgs(ev, 8, toEvent(arg1), toEvent(arg2), toEvent(arg3), toEvent(arg4), toEvent(arg5), toEvent(arg6), toEvent(arg7), toEvent(arg8)); + return ProcessEventArgs(ev, 8, toArg(arg1), toArg(arg2), toArg(arg3), toArg(arg4), toArg(arg5), toArg(arg6), toArg(arg7), toArg(arg8)); } public boolean ProcessEventArgPtr(final idEventDef ev, idEventArg[] data) { diff --git a/src/main/java/neo/Game/Misc.java b/src/main/java/neo/Game/Misc.java index 45284739..004e22c7 100644 --- a/src/main/java/neo/Game/Misc.java +++ b/src/main/java/neo/Game/Misc.java @@ -1,16 +1,26 @@ package neo.Game; import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; + import neo.CM.CollisionModel.trace_s; import neo.Game.AFEntity.idAFEntity_Gibbable; import neo.Game.AI.AI.idAI; import neo.Game.Actor.idActor; + +import static neo.Game.AI.AI_Events.AI_RandomPath; +import static neo.Game.Actor.EV_Footstep; +import static neo.Game.Actor.EV_FootstepLeft; +import static neo.Game.Actor.EV_FootstepRight; import static neo.Game.Animation.Anim.ANIMCHANNEL_ALL; import static neo.Game.Animation.Anim.FRAME2MS; import neo.Game.Animation.Anim_Blend.idAnim; import neo.Game.Camera.idCamera; import static neo.Game.Entity.EV_Activate; +import static neo.Game.Entity.EV_FindTargets; import static neo.Game.Entity.EV_PostSpawn; +import static neo.Game.Entity.EV_Touch; import static neo.Game.Entity.TH_ALL; import static neo.Game.Entity.TH_THINK; import static neo.Game.Entity.TH_UPDATEPARTICLES; @@ -18,6 +28,15 @@ import neo.Game.Entity.idEntity; import neo.Game.GameSys.Class; import static neo.Game.GameSys.Class.EV_Remove; + +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.eventCallback_t2; +import neo.Game.GameSys.Class.eventCallback_t4; +import neo.Game.GameSys.Class.eventCallback_t6; +import neo.Game.GameSys.Class.idEventArg; +import neo.Game.GameSys.Event; import neo.Game.GameSys.Event.idEventDef; import static neo.Game.GameSys.SaveGame.INITIAL_RELEASE_BUILD_NUMBER; import neo.Game.GameSys.SaveGame.idRestoreGame; @@ -40,7 +59,6 @@ import static neo.Game.Game_local.gameSoundChannel_t.SND_CHANNEL_WEAPON; import static neo.Game.Game_local.gameSoundWorld; import neo.Game.Game_local.idEntityPtr; -import neo.Game.Misc.idPathCorner; import neo.Game.Moveable.idMoveable; import neo.Game.Physics.Clip.idClipModel; import static neo.Game.Physics.Force_Field.forceFieldApplyType.FORCEFIELD_APPLY_FORCE; @@ -167,6 +185,12 @@ public Class.idClass CreateInstance() { */ public static class idPlayerStart extends idEntity { // public CLASS_PROTOTYPE( idPlayerStart ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idPlayerStart::Event_TeleportPlayer); + eventCallbacks.put(EV_TeleportStage, (eventCallback_t1) idPlayerStart::Event_TeleportStage); + } // enum { public static final int EVENT_TELEPORTPLAYER = idEntity.EVENT_MAXEVENTS; @@ -222,18 +246,22 @@ public boolean ClientReceiveEvent(int event, int time, final idBitMsg msg) { } private void Event_TeleportPlayer(idEntity activator) { + Event_TeleportPlayer(this, idEventArg.toArg(activator)); + } + + private static void Event_TeleportPlayer(idPlayerStart p, idEventArg activator) { idPlayer player; - if (activator.IsType(idPlayer.class)) { - player = (idPlayer) activator; + if (activator.value.IsType(idPlayer.class)) { + player = (idPlayer) activator.value; } else { player = gameLocal.GetLocalPlayer(); } if (player != null) { - if (spawnArgs.GetBool("visualFx")) { + if (p.spawnArgs.GetBool("visualFx")) { - teleportStage = 0; - Event_TeleportStage(player); + p.teleportStage = 0; + p.Event_TeleportStage(player); } else { @@ -244,14 +272,18 @@ private void Event_TeleportPlayer(idEntity activator) { msg.Init(msgBuf, MAX_EVENT_PARAM_SIZE); msg.BeginWriting(); msg.WriteBits(player.entityNumber, GENTITYNUM_BITS); - ServerSendEvent(EVENT_TELEPORTPLAYER, msg, false, -1); + p.ServerSendEvent(EVENT_TELEPORTPLAYER, msg, false, -1); } - TeleportPlayer(player); + p.TeleportPlayer(player); } } } + private void Event_TeleportStage(idEntity _player) { + Event_TeleportStage(this, idEventArg.toArg(_player)); + } + /* =============== idPlayerStart::Event_TeleportStage @@ -259,35 +291,35 @@ private void Event_TeleportPlayer(idEntity activator) { FIXME: add functionality to fx system ( could be done with player scripting too ) ================ */ - private void Event_TeleportStage(idEntity _player) { + private static void Event_TeleportStage(idPlayerStart p, idEventArg _player) { idPlayer player; - if (!_player.IsType(idPlayer.class)) { + if (!_player.value.IsType(idPlayer.class)) { common.Warning("idPlayerStart::Event_TeleportStage: entity is not an idPlayer\n"); return; } - player = (idPlayer) _player; - float teleportDelay = spawnArgs.GetFloat("teleportDelay"); - switch (teleportStage) { + player = (idPlayer) _player.value; + float teleportDelay = p.spawnArgs.GetFloat("teleportDelay"); + switch (p.teleportStage) { case 0: player.playerView.Flash(colorWhite, 125); player.SetInfluenceLevel(INFLUENCE_LEVEL3); - player.SetInfluenceView(spawnArgs.GetString("mtr_teleportFx"), null, 0.0f, null); + player.SetInfluenceView(p.spawnArgs.GetString("mtr_teleportFx"), null, 0.0f, null); gameSoundWorld.FadeSoundClasses(0, -20.0f, teleportDelay); player.StartSound("snd_teleport_start", SND_CHANNEL_BODY2, 0, false, null); - teleportStage++; - PostEventSec(EV_TeleportStage, teleportDelay, player); + p.teleportStage++; + p.PostEventSec(EV_TeleportStage, teleportDelay, player); break; case 1: gameSoundWorld.FadeSoundClasses(0, 0.0f, 0.25f); - teleportStage++; - PostEventSec(EV_TeleportStage, 0.25f, player); + p.teleportStage++; + p.PostEventSec(EV_TeleportStage, 0.25f, player); break; case 2: player.SetInfluenceView(null, null, 0.0f, null); - TeleportPlayer(player); + p.TeleportPlayer(player); player.StopSound(etoi(SND_CHANNEL_BODY2), false); player.SetInfluenceLevel(INFLUENCE_NONE); - teleportStage = 0; + p.teleportStage = 0; break; default: break; @@ -330,6 +362,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -344,6 +381,11 @@ public Class.idClass CreateInstance() { */ public static class idActivator extends idEntity { // public CLASS_PROTOTYPE( idActivator ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idActivator::Event_Activate); + } private final boolean[] stay_on = new boolean[1]; // @@ -391,11 +433,11 @@ public void Think() { Present(); } - private void Event_Activate(idEntity activator) { - if ((thinkFlags & TH_THINK) != 0) { - BecomeInactive(TH_THINK); + private static void Event_Activate(idActivator a, idEventArg activator) { + if ((a.thinkFlags & TH_THINK) != 0) { + a.BecomeInactive(TH_THINK); } else { - BecomeActive(TH_THINK); + a.BecomeActive(TH_THINK); } } @@ -408,6 +450,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -426,6 +473,10 @@ public Class.idClass CreateInstance() { */ public static class idPathCorner extends idEntity { // public CLASS_PROTOTYPE( idPathCorner ); + private static Map eventCallbacks = new HashMap<>(); + static{ + eventCallbacks.put(AI_RandomPath, (eventCallback_t0) idPathCorner::Event_RandomPath); + } public static void DrawDebugInfo() { idEntity ent; @@ -483,6 +534,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -503,6 +559,12 @@ public Class.idClass CreateInstance() { public static class idDamagable extends idEntity { // CLASS_PROTOTYPE( idDamagable ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idDamagable::Event_BecomeBroken); + eventCallbacks.put(EV_RestoreDamagable, (eventCallback_t0) idDamagable::Event_RestoreDamagable); + } private final int[] count = {0}; private final int[] nextTriggerTime = {0}; @@ -612,8 +674,8 @@ private void BecomeBroken(idEntity activator) { } } - private void Event_BecomeBroken(idEntity activator) { - BecomeBroken(activator); + private static void Event_BecomeBroken(idDamagable d, idEventArg activator) { + d.BecomeBroken(activator.value); } private void Event_RestoreDamagable() { @@ -630,6 +692,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -648,33 +715,37 @@ public Class.idClass CreateInstance() { */ public static class idExplodable extends idEntity { // CLASS_PROTOTYPE( idExplodable ); + private static Map eventCallbacks = new HashMap<>(); + static{ + eventCallbacks.put(EV_Activate, (eventCallback_t1) idExplodable::Event_Explode); + } @Override public void Spawn() { Hide(); } - private void Event_Explode(idEntity activator) { + private static void Event_Explode(idExplodable e, idEventArg activator) { String[] temp = {null}; - if (spawnArgs.GetString("def_damage", "damage_explosion", temp)) { - gameLocal.RadiusDamage(GetPhysics().GetOrigin(), activator, activator, this, this, temp[0]); + if (e.spawnArgs.GetString("def_damage", "damage_explosion", temp)) { + gameLocal.RadiusDamage(e.GetPhysics().GetOrigin(), activator.value, activator.value, e, e, temp[0]); } - StartSound("snd_explode", SND_CHANNEL_ANY, 0, false, null); + e.StartSound("snd_explode", SND_CHANNEL_ANY, 0, false, null); // Show() calls UpdateVisuals, so we don't need to call it ourselves after setting the shaderParms - renderEntity.shaderParms[SHADERPARM_RED] = 1.0f; - renderEntity.shaderParms[SHADERPARM_GREEN] = 1.0f; - renderEntity.shaderParms[SHADERPARM_BLUE] = 1.0f; - renderEntity.shaderParms[SHADERPARM_ALPHA] = 1.0f; - renderEntity.shaderParms[SHADERPARM_TIMEOFFSET] = -MS2SEC(gameLocal.time); - renderEntity.shaderParms[SHADERPARM_DIVERSITY] = 0.0f; - Show(); + e.renderEntity.shaderParms[SHADERPARM_RED] = 1.0f; + e.renderEntity.shaderParms[SHADERPARM_GREEN] = 1.0f; + e.renderEntity.shaderParms[SHADERPARM_BLUE] = 1.0f; + e.renderEntity.shaderParms[SHADERPARM_ALPHA] = 1.0f; + e.renderEntity.shaderParms[SHADERPARM_TIMEOFFSET] = -MS2SEC(gameLocal.time); + e.renderEntity.shaderParms[SHADERPARM_DIVERSITY] = 0.0f; + e.Show(); - PostEventMS(EV_Remove, 2000); + e.PostEventMS(EV_Remove, 2000); - ActivateTargets(activator); + e.ActivateTargets(activator.value); } @Override @@ -686,6 +757,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -697,6 +773,11 @@ public Class.idClass CreateInstance() { */ public static class idSpring extends idEntity { // CLASS_PROTOTYPE( idSpring ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_PostSpawn, (eventCallback_t0) idSpring::Event_LinkSpring); + } private idEntity ent1; private idEntity ent2; @@ -795,6 +876,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -808,6 +894,13 @@ public Class.idClass CreateInstance() { public static class idForceField extends idEntity { // CLASS_PROTOTYPE( idForceField ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idForceField::Event_Activate); + eventCallbacks.put(EV_Toggle, (eventCallback_t0) idForceField::Event_Toggle); + eventCallbacks.put(EV_FindTargets, (eventCallback_t0) idForceField::Event_FindTargets ); + } private idForce_Field forceField; // @@ -879,7 +972,7 @@ private void Toggle() { } } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { float[] wait = new float[1]; Toggle(); @@ -909,6 +1002,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* =============================================================================== @@ -925,6 +1023,19 @@ public Class.idClass CreateInstance() { public static class idAnimated extends idAFEntity_Gibbable { // CLASS_PROTOTYPE( idAnimated ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idAnimated::Event_Activate); + eventCallbacks.put(EV_Animated_Start, (eventCallback_t0) idAnimated::Event_Start); + eventCallbacks.put(EV_StartRagdoll, (eventCallback_t0) idAnimated::Event_StartRagdoll); + eventCallbacks.put(EV_AnimDone, (eventCallback_t1) idAnimated::Event_AnimDone); + eventCallbacks.put(EV_Footstep, (eventCallback_t0) idAnimated::Event_Footstep); + eventCallbacks.put(EV_FootstepLeft, (eventCallback_t0) idAnimated::Event_Footstep); + eventCallbacks.put(EV_FootstepRight, (eventCallback_t0) idAnimated::Event_Footstep); + eventCallbacks.put(EV_LaunchMissiles, (eventCallback_t6) idAnimated::Event_LaunchMissiles); + eventCallbacks.put(EV_LaunchMissilesUpdate, (eventCallback_t4) idAnimated::Event_LaunchMissilesUpdate); + } private int num_anims; private int current_anim_index; @@ -1150,10 +1261,10 @@ private void PlayNextAnim() { Present(); } - private void Event_Activate(idEntity _activator) { + private void Event_Activate(idEventArg _activator) { if (num_anims != 0) { PlayNextAnim(); - activator.oSet(_activator); + activator.oSet(_activator.value); return; } @@ -1163,7 +1274,7 @@ private void Event_Activate(idEntity _activator) { } activated = true; - activator.oSet(_activator); + activator.oSet(_activator.value); ProcessEvent(EV_Animated_Start); } @@ -1206,13 +1317,13 @@ private void Event_StartRagdoll() { StartRagdoll(); } - private void Event_AnimDone(int animIndex) { + private void Event_AnimDone(idEventArg animIndex) { if (g_debugCinematic.GetBool()) { final idAnim animPtr = animator.GetAnim(anim); gameLocal.Printf("%d: '%s' end anim '%s'\n", gameLocal.framenum, GetName(), animPtr != null ? animPtr.Name() : ""); } - if ((animIndex >= num_anims) && spawnArgs.GetBool("remove")) { + if ((animIndex.value >= num_anims) && spawnArgs.GetBool("remove")) { Hide(); PostEventMS(EV_Remove, 0); } else if (spawnArgs.GetBool("auto_advance")) { @@ -1228,36 +1339,37 @@ private void Event_Footstep() { StartSound("snd_footstep", SND_CHANNEL_BODY, 0, false, null); } - private void Event_LaunchMissiles(final String projectilename, final String sound, final String launchjoint, final String targetjoint, int numshots, int framedelay) { + private void Event_LaunchMissiles(final idEventArg projectilename, final idEventArg sound, final idEventArg launchjoint, + final idEventArg targetjoint, idEventArg numshots, idEventArg framedelay) { idDict projectileDef; int/*jointHandle_t*/ launch; int/*jointHandle_t*/ target; - projectileDef = gameLocal.FindEntityDefDict(projectilename, false); + projectileDef = gameLocal.FindEntityDefDict(projectilename.value, false); if (null == projectileDef) { - gameLocal.Warning("idAnimated '%s' at (%s): unknown projectile '%s'", name, GetPhysics().GetOrigin().ToString(0), projectilename); + gameLocal.Warning("idAnimated '%s' at (%s): unknown projectile '%s'", name, GetPhysics().GetOrigin().ToString(0), projectilename.value); return; } - launch = animator.GetJointHandle(launchjoint); + launch = animator.GetJointHandle(launchjoint.value); if (launch == INVALID_JOINT) { - gameLocal.Warning("idAnimated '%s' at (%s): unknown launch joint '%s'", name, GetPhysics().GetOrigin().ToString(0), launchjoint); - gameLocal.Error("Unknown joint '%s'", launchjoint); + gameLocal.Warning("idAnimated '%s' at (%s): unknown launch joint '%s'", name, GetPhysics().GetOrigin().ToString(0), launchjoint.value); + gameLocal.Error("Unknown joint '%s'", launchjoint.value); } - target = animator.GetJointHandle(targetjoint); + target = animator.GetJointHandle(targetjoint.value); if (target == INVALID_JOINT) { - gameLocal.Warning("idAnimated '%s' at (%s): unknown target joint '%s'", name, GetPhysics().GetOrigin().ToString(0), targetjoint); + gameLocal.Warning("idAnimated '%s' at (%s): unknown target joint '%s'", name, GetPhysics().GetOrigin().ToString(0), targetjoint.value); } - spawnArgs.Set("projectilename", projectilename); - spawnArgs.Set("missilesound", sound); + spawnArgs.Set("projectilename", projectilename.value); + spawnArgs.Set("missilesound", sound.value); CancelEvents(EV_LaunchMissilesUpdate); - ProcessEvent(EV_LaunchMissilesUpdate, launch, target, numshots - 1, framedelay); + ProcessEvent(EV_LaunchMissilesUpdate, launch, target, numshots.value - 1, framedelay.value); } - private void Event_LaunchMissilesUpdate(int launchjoint, int targetjoint, int numshots, int framedelay) { + private void Event_LaunchMissilesUpdate(idEventArg launchjoint, idEventArg targetjoint, idEventArg numshots, idEventArg framedelay) { idVec3 launchPos = new idVec3(); idVec3 targetPos = new idVec3(); idMat3 axis = new idMat3(); @@ -1276,10 +1388,10 @@ private void Event_LaunchMissilesUpdate(int launchjoint, int targetjoint, int nu StartSound("snd_missile", SND_CHANNEL_WEAPON, 0, false, null); - animator.GetJointTransform(launchjoint, gameLocal.time, launchPos, axis); + animator.GetJointTransform(launchjoint.value, gameLocal.time, launchPos, axis); launchPos = renderEntity.origin.oPlus(launchPos.oMultiply(renderEntity.axis)); - animator.GetJointTransform(targetjoint, gameLocal.time, targetPos, axis); + animator.GetJointTransform(targetjoint.value, gameLocal.time, targetPos, axis); targetPos = renderEntity.origin.oPlus(targetPos.oMultiply(renderEntity.axis)); dir = targetPos.oMinus(launchPos); @@ -1293,10 +1405,15 @@ private void Event_LaunchMissilesUpdate(int launchjoint, int targetjoint, int nu projectile.Create(this, launchPos, dir); projectile.Launch(launchPos, dir, getVec3_origin()); - if (numshots > 0) { - PostEventMS(EV_LaunchMissilesUpdate, FRAME2MS(framedelay), launchjoint, targetjoint, numshots - 1, framedelay); + if (numshots.value > 0) { + PostEventMS(EV_LaunchMissilesUpdate, FRAME2MS(framedelay.value), launchjoint.value, targetjoint.value, numshots.value - 1, framedelay.value); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1310,6 +1427,11 @@ private void Event_LaunchMissilesUpdate(int launchjoint, int targetjoint, int nu */ public static class idStaticEntity extends idEntity { // CLASS_PROTOTYPE( idStaticEntity ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idStaticEntity::Event_Activate); + } private int spawnTime; private boolean active; @@ -1494,7 +1616,7 @@ public void ReadFromSnapshot(final idBitMsgDelta msg) { } } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { idStr activateGui; spawnTime = gameLocal.time; @@ -1527,6 +1649,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1538,6 +1665,11 @@ public Class.idClass CreateInstance() { */ public static class idFuncEmitter extends idStaticEntity { // CLASS_PROTOTYPE( idFuncEmitter ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idFuncEmitter::Event_Activate); + } private final boolean[] hidden = {false}; // @@ -1570,7 +1702,7 @@ public void Spawn() { } } - public void Event_Activate(idEntity activator) { + public void Event_Activate(idEventArg activator) { if (hidden[0] || spawnArgs.GetBool("cycleTrigger")) { renderEntity.shaderParms[SHADERPARM_PARTICLE_STOPTIME] = 0; renderEntity.shaderParms[SHADERPARM_TIMEOFFSET] = -MS2SEC(gameLocal.time); @@ -1598,6 +1730,11 @@ public void ReadFromSnapshot(final idBitMsgDelta msg) { UpdateVisuals(); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1609,6 +1746,11 @@ public void ReadFromSnapshot(final idBitMsgDelta msg) { */ public static class idFuncSmoke extends idEntity { // CLASS_PROTOTYPE( idFuncSmoke ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idFuncSmoke::Event_Activate); + } private int smokeTime; private idDeclParticle smoke; @@ -1682,7 +1824,7 @@ public void Think() { } - public void Event_Activate(idEntity activator) { + public void Event_Activate(idEventArg activator) { if ((thinkFlags & TH_UPDATEPARTICLES) != 0) { restart = false; // return; @@ -1702,6 +1844,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1715,6 +1862,12 @@ public Class.idClass CreateInstance() { public static class idFuncSplat extends idFuncEmitter { // CLASS_PROTOTYPE( idFuncSplat ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idFuncSplat::Event_Activate); + eventCallbacks.put(EV_Splat, (eventCallback_t0) idFuncSplat::Event_Splat); + } public idFuncSplat() { } @@ -1724,7 +1877,7 @@ public void Spawn() { } @Override - public void Event_Activate(idEntity activator) { + public void Event_Activate(idEventArg activator) { super.Event_Activate(activator); PostEventSec(EV_Splat, spawnArgs.GetFloat("splatDelay", "0.25")); StartSound("snd_spurt", SND_CHANNEL_ANY, 0, false, null); @@ -1744,6 +1897,11 @@ private void Event_Splat() { } StartSound("snd_splat", SND_CHANNEL_ANY, 0, false, null); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1897,6 +2055,11 @@ Can be triggered to let vacuum through a portal (blown out window) */ public static class idVacuumSeparatorEntity extends idEntity { // CLASS_PROTOTYPE( idVacuumSeparatorEntity ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idVacuumSeparatorEntity::Event_Activate); + } public idVacuumSeparatorEntity() { portal = 0; @@ -1932,7 +2095,7 @@ public void Restore(idRestoreGame savefile) { gameLocal.SetPortalState(portal[0], state[0]); } - public void Event_Activate(idEntity activator) { + public void Event_Activate(idEventArg activator) { if (0 == portal) { return; } @@ -1951,6 +2114,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1998,6 +2166,12 @@ public Class.idClass CreateInstance() { */ public static class idBeam extends idEntity { // CLASS_PROTOTYPE( idBeam ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_PostSpawn, (eventCallback_t0) idBeam::Event_MatchTarget); + eventCallbacks.put(EV_Activate, (eventCallback_t1) idBeam::Event_Activate); + } private idEntityPtr target; private idEntityPtr master; @@ -2131,7 +2305,7 @@ private void Event_MatchTarget() { } } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { if (IsHidden()) { Show(); } else { @@ -2160,6 +2334,11 @@ public Class.idClass CreateInstance() { @Deprecated public static class idLiquid extends idEntity { // CLASS_PROTOTYPE( idLiquid ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Touch, (eventCallback_t2) idLiquid::Event_Touch); + } private idRenderModelLiquid model; // @@ -2188,7 +2367,7 @@ public void Restore(idRestoreGame savefile) { Spawn(); } - private void Event_Touch(idEntity other, trace_s trace) { + private void Event_Touch(idEventArg other, idEventArg trace) { // FIXME: for QuakeCon /* idVec3 pos; @@ -2207,6 +2386,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -2218,6 +2402,11 @@ public Class.idClass CreateInstance() { */ public static class idShaking extends idEntity { // CLASS_PROTOTYPE( idShaking ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idShaking::Event_Activate); + } private idPhysics_Parametric physicsObj; private boolean active; @@ -2272,7 +2461,7 @@ private void BeginShaking() { physicsObj.SetAngularExtrapolation((EXTRAPOLATION_DECELSINE | EXTRAPOLATION_NOSTOP), phase, (int) (period * 0.25f), GetPhysics().GetAxis().ToAngles(), shake, getAng_zero()); } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { if (!active) { BeginShaking(); } else { @@ -2290,6 +2479,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -2301,6 +2495,11 @@ public Class.idClass CreateInstance() { */ public static class idEarthQuake extends idEntity { // CLASS_PROTOTYPE( idEarthQuake ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idEarthQuake::Event_Activate); + } private int nextTriggerTime; private int shakeStopTime; @@ -2386,7 +2585,8 @@ public void Restore(idRestoreGame savefile) { public void Think() { } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg _activator) { + idEntity activator = _activator.value; if (nextTriggerTime > gameLocal.time) { return; @@ -2447,6 +2647,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -2459,6 +2664,11 @@ public Class.idClass CreateInstance() { */ public static class idFuncPortal extends idEntity { // CLASS_PROTOTYPE( idFuncPortal ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idFuncPortal::Event_Activate); + } private final int[]/*qhandle_t*/ portal = {0}; private final boolean[] state = {false}; @@ -2492,7 +2702,7 @@ public void Restore(idRestoreGame savefile) { gameLocal.SetPortalState(portal[0], (state[0] ? PS_BLOCK_ALL : PS_BLOCK_NONE).ordinal()); } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { if (portal[0] > 0) { state[0] = !state[0]; gameLocal.SetPortalState(portal[0], (state[0] ? PS_BLOCK_ALL : PS_BLOCK_NONE).ordinal()); @@ -2508,6 +2718,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -2519,6 +2734,11 @@ public Class.idClass CreateInstance() { */ public static class idFuncAASPortal extends idEntity { // CLASS_PROTOTYPE( idFuncAASPortal ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idFuncAASPortal::Event_Activate); + } private boolean state; // @@ -2546,7 +2766,7 @@ public void Restore(idRestoreGame savefile) { gameLocal.SetAASAreaState(GetPhysics().GetAbsBounds(), AREACONTENTS_CLUSTERPORTAL, this.state = state[0]); } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { state ^= true;//1; gameLocal.SetAASAreaState(GetPhysics().GetAbsBounds(), AREACONTENTS_CLUSTERPORTAL, state); } @@ -2560,6 +2780,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -2571,6 +2796,11 @@ public Class.idClass CreateInstance() { */ public static class idFuncAASObstacle extends idEntity { // CLASS_PROTOTYPE( idFuncAASObstacle ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idFuncAASObstacle::Event_Activate); + } private boolean[] state = {false}; // @@ -2597,7 +2827,7 @@ public void Restore(idRestoreGame savefile) { gameLocal.SetAASAreaState(GetPhysics().GetAbsBounds(), AREACONTENTS_OBSTACLE, state[0]); } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { state[0] ^= true;//1; gameLocal.SetAASAreaState(GetPhysics().GetAbsBounds(), AREACONTENTS_OBSTACLE, state[0]); } @@ -2611,6 +2841,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* =============================================================================== @@ -2623,6 +2858,12 @@ public Class.idClass CreateInstance() { public static class idFuncRadioChatter extends idEntity { // CLASS_PROTOTYPE( idFuncRadioChatter ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idFuncRadioChatter::Event_Activate); + eventCallbacks.put(EV_ResetRadioHud, (eventCallback_t1) idFuncRadioChatter::Event_ResetRadioHud); + } private int end_time; private float throw_time; @@ -2662,14 +2903,14 @@ public void Restore(idRestoreGame savefile) { this.time = time[0]; } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { idPlayer player; final String sound; idSoundShader shader; int[] length = {0}; - if (activator.IsType(idPlayer.class)) { - player = (idPlayer) activator; + if (activator.value.IsType(idPlayer.class)) { + player = (idPlayer) activator.value; } else { player = gameLocal.GetLocalPlayer(); } @@ -2688,7 +2929,8 @@ private void Event_Activate(idEntity activator) { } - private void Event_ResetRadioHud(idEntity activator) { + private void Event_ResetRadioHud(idEventArg _activator) { + idEntity activator = _activator.value; idPlayer player = (activator.IsType(idPlayer.class)) ? (idPlayer) activator : gameLocal.GetLocalPlayer(); player.hud.HandleNamedEvent("radioChatterDown"); ActivateTargets(activator); @@ -2703,6 +2945,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -2715,17 +2962,22 @@ public Class.idClass CreateInstance() { */ public static class idPhantomObjects extends idEntity { // CLASS_PROTOTYPE( idPhantomObjects ); + private static Map eventCallbacks = new HashMap<>(); - private int end_time; - private float throw_time; - private float shake_time; - private idVec3 shake_ang; - private float speed; - private int min_wait; - private int max_wait; + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idPhantomObjects::Event_Activate); + } + + private int end_time; + private float throw_time; + private float shake_time; + private idVec3 shake_ang; + private float speed; + private int min_wait; + private int max_wait; private idEntityPtr target; - private idList targetTime; - private idList lastTargetPos; + private idList targetTime; + private idList lastTargetPos; // // @@ -2904,7 +3156,8 @@ public void Think() { } } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg _activator) { + idEntity activator = _activator.value; int i; float time; float frac; @@ -2966,5 +3219,9 @@ public Class.idClass CreateInstance() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/Player.java b/src/main/java/neo/Game/Player.java index 6ba40ecd..ce1127cc 100644 --- a/src/main/java/neo/Game/Player.java +++ b/src/main/java/neo/Game/Player.java @@ -6,6 +6,8 @@ import static java.lang.Math.sin; import java.nio.ByteBuffer; import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; import java.util.stream.Stream; import static neo.CM.CollisionModel.CM_BOX_EPSILON; import static neo.CM.CollisionModel.CM_CLIP_EPSILON; @@ -32,6 +34,8 @@ import neo.Game.FX.idEntityFx; import neo.Game.GameEdit.idDragEntity; import static neo.Game.GameSys.Class.EV_Remove; + +import neo.Game.GameSys.Class.eventCallback_t; import neo.Game.GameSys.Class.eventCallback_t0; import neo.Game.GameSys.Class.eventCallback_t1; import neo.Game.GameSys.Class.idEventArg; @@ -1196,7 +1200,7 @@ public static class aasLocation_t { }; public static class idPlayer extends idActor { -// protected static Map eventCallbacks = new HashMap<>(); + private static Map eventCallbacks = new HashMap<>(); static { eventCallbacks.put(EV_Player_GetButtons, (eventCallback_t0) idPlayer::Event_GetButtons); @@ -8288,7 +8292,7 @@ private void Event_GetPreviousWeapon() { } } - private static void Event_SelectWeapon(idPlayer p, final idEventArg weaponName) { + private void Event_SelectWeapon(final idEventArg weaponName) { int i; int weaponNum; @@ -8297,16 +8301,16 @@ private static void Event_SelectWeapon(idPlayer p, final idEventArg weap return; } - if (p.hiddenWeapon && gameLocal.world.spawnArgs.GetBool("no_Weapons")) { - p.idealWeapon = p.weapon_fists; - p.weapon.GetEntity().HideWeapon(); + if (hiddenWeapon && gameLocal.world.spawnArgs.GetBool("no_Weapons")) { + idealWeapon = weapon_fists; + weapon.GetEntity().HideWeapon(); return; } weaponNum = -1; for (i = 0; i < MAX_WEAPONS; i++) { - if ((p.inventory.weapons & (1 << i)) != 0) { - final String weap = p.spawnArgs.GetString(va("def_weapon%d", i)); + if ((inventory.weapons & (1 << i)) != 0) { + final String weap = spawnArgs.GetString(va("def_weapon%d", i)); if (NOT(idStr.Cmp(weap, weaponName.value))) { weaponNum = i; break; @@ -8315,14 +8319,14 @@ private static void Event_SelectWeapon(idPlayer p, final idEventArg weap } if (weaponNum < 0) { - gameLocal.Warning("%s is not carrying weapon '%s'", p.name, weaponName.value); + gameLocal.Warning("%s is not carrying weapon '%s'", name, weaponName.value); return; } - p.hiddenWeapon = false; - p.idealWeapon = weaponNum; + hiddenWeapon = false; + idealWeapon = weaponNum; - p.UpdateHudWeapon(); + UpdateHudWeapon(); } private void Event_GetWeaponEntity() { @@ -8417,5 +8421,10 @@ private void Event_GetIdealWeapon() { idThread.ReturnString(""); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } From bdb9492031b83bbf3a560187704d3fbe2f122d31 Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Mon, 16 May 2016 17:37:18 +0200 Subject: [PATCH 11/17] events, part2: 620/622 --- src/main/java/neo/Game/AFEntity.java | 85 ++- src/main/java/neo/Game/AI/AI.java | 707 +++++++++++++----- src/main/java/neo/Game/AI/AI_Vagary.java | 49 +- src/main/java/neo/Game/Actor.java | 194 +++-- .../neo/Game/Animation/Anim_Testmodel.java | 22 + src/main/java/neo/Game/BrittleFracture.java | 32 +- src/main/java/neo/Game/Camera.java | 39 +- src/main/java/neo/Game/Entity.java | 40 +- src/main/java/neo/Game/FX.java | 41 +- src/main/java/neo/Game/GameSys/Class.java | 2 +- src/main/java/neo/Game/GameSys/Event.java | 19 +- src/main/java/neo/Game/Item.java | 99 ++- src/main/java/neo/Game/Light.java | 74 +- src/main/java/neo/Game/Moveable.java | 74 +- src/main/java/neo/Game/Mover.java | 472 ++++++++---- src/main/java/neo/Game/Projectile.java | 62 +- .../java/neo/Game/Script/Script_Thread.java | 2 +- src/main/java/neo/Game/SecurityCamera.java | 19 + src/main/java/neo/Game/Sound.java | 23 +- src/main/java/neo/Game/Target.java | 379 ++++++++-- src/main/java/neo/Game/Trigger.java | 182 ++++- src/main/java/neo/Game/Weapon.java | 140 +++- src/main/java/neo/Game/WorldSpawn.java | 25 +- src/misc/bug_report_04.txt | 4 + 24 files changed, 2130 insertions(+), 655 deletions(-) diff --git a/src/main/java/neo/Game/AFEntity.java b/src/main/java/neo/Game/AFEntity.java index af0caa3d..ec67a7b4 100644 --- a/src/main/java/neo/Game/AFEntity.java +++ b/src/main/java/neo/Game/AFEntity.java @@ -1,6 +1,9 @@ package neo.Game; import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + import neo.CM.CollisionModel.trace_s; import neo.Game.AF.idAF; import neo.Game.AFEntity.jointTransformData_t; @@ -8,6 +11,8 @@ import static neo.Game.Animation.Anim.jointModTransform_t.JOINTMOD_WORLD; import static neo.Game.Animation.Anim.jointModTransform_t.JOINTMOD_WORLD_OVERRIDE; import neo.Game.Animation.Anim_Blend.idDeclModelDef; + +import static neo.Game.Entity.EV_Activate; import static neo.Game.Entity.EV_SetAngularVelocity; import static neo.Game.Entity.EV_SetLinearVelocity; import static neo.Game.Entity.TH_PHYSICS; @@ -17,7 +22,14 @@ import neo.Game.Entity.idAnimatedEntity; import neo.Game.Entity.idEntity; import static neo.Game.GameSys.Class.EV_Remove; + +import neo.Game.GameSys.Class; +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.eventCallback_t2; import neo.Game.GameSys.Class.idClass; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -490,6 +502,11 @@ public void UnlinkCombat() { public static class idAFEntity_Base extends idAnimatedEntity { // public CLASS_PROTOTYPE( idAFEntity_Base ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_SetConstraintPosition, (eventCallback_t2) idAFEntity_Base::Event_SetConstraintPosition); + } protected idAF af; // articulated figure protected idClipModel combatModel; // render model for hit detection @@ -790,8 +807,13 @@ public static void DropAFs(idEntity ent, final String type, idList lis } } - protected void Event_SetConstraintPosition(final String name, final idVec3 pos) { - af.SetConstraintPosition(name, pos); + protected void Event_SetConstraintPosition(final idEventArg name, final idEventArg pos) { + af.SetConstraintPosition(name.value, pos.value); + } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); } }; /* @@ -804,6 +826,12 @@ protected void Event_SetConstraintPosition(final String name, final idVec3 pos) public static class idAFEntity_Gibbable extends idAFEntity_Base { // CLASS_PROTOTYPE( idAFEntity_Gibbable ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Gib, (eventCallback_t1) idAFEntity_Gibbable::Event_Gib); + eventCallbacks.put(EV_Gibbed, (eventCallback_t0) idAFEntity_Base::Event_Remove); + } protected idRenderModel skeletonModel; protected int skeletonModelDefHandle; @@ -995,8 +1023,8 @@ protected void InitSkeletonModel() { } } - protected void Event_Gib(final String damageDefName) { - Gib(new idVec3(0, 0, 1), damageDefName); + protected void Event_Gib(final idEventArg damageDefName) { + Gib(new idVec3(0, 0, 1), damageDefName.value); } /** @@ -1021,6 +1049,11 @@ public final void idAFEntity_Base_Show() { public final boolean idAFEntity_Base_UpdateAnimationControllers() { return super.UpdateAnimationControllers(); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1032,6 +1065,11 @@ public final boolean idAFEntity_Base_UpdateAnimationControllers() { */ public static class idAFEntity_Generic extends idAFEntity_Gibbable { // CLASS_PROTOTYPE( idAFEntity_Generic ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idAFEntity_Generic::Event_Activate); + } private final boolean[] keepRunningPhysics = {false}; // @@ -1085,7 +1123,7 @@ public void KeepRunningPhysics() { keepRunningPhysics[0] = true; } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { float delay; idVec3 init_velocity = new idVec3(), init_avelocity = new idVec3(); @@ -1111,6 +1149,11 @@ private void Event_Activate(idEntity activator) { PostEventSec(EV_SetAngularVelocity, delay, init_avelocity); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1122,6 +1165,12 @@ private void Event_Activate(idEntity activator) { */ public static class idAFEntity_WithAttachedHead extends idAFEntity_Gibbable { // CLASS_PROTOTYPE( idAFEntity_WithAttachedHead ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_Gib, (eventCallback_t1) idAFEntity_WithAttachedHead::Event_Gib); + eventCallbacks.put(EV_Activate, (eventCallback_t1) idAFEntity_WithAttachedHead::Event_Activate); + } private idEntityPtr head; // @@ -1274,11 +1323,11 @@ protected void Gib(final idVec3 dir, final String damageDefName) { } @Override - protected void Event_Gib(final String damageDefName) { - Gib(new idVec3(0, 0, 1), damageDefName); + protected void Event_Gib(final idEventArg damageDefName) { + Gib(new idVec3(0, 0, 1), damageDefName.value); } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { float delay; idVec3 init_velocity = new idVec3(), init_avelocity = new idVec3(); @@ -1304,6 +1353,11 @@ private void Event_Activate(idEntity activator) { PostEventSec(EV_SetAngularVelocity, delay, init_avelocity); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -2090,6 +2144,12 @@ private void InitSteamRenderEntity() { public static class idAFEntity_ClawFourFingers extends idAFEntity_Base { // public: // CLASS_PROTOTYPE( idAFEntity_ClawFourFingers ); + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(EV_SetFingerAngle, (eventCallback_t1) idAFEntity_ClawFourFingers::Event_SetFingerAngle); + eventCallbacks.put(EV_StopFingers, (eventCallback_t0) idAFEntity_ClawFourFingers::Event_StopFingers); + } public idAFEntity_ClawFourFingers() { fingers[0] = null; @@ -2147,11 +2207,11 @@ public void Restore(idRestoreGame savefile) { // // - private void Event_SetFingerAngle(float angle) { + private void Event_SetFingerAngle(idEventArg angle) { int i; for (i = 0; i < 4; i++) { - fingers[i].SetSteerAngle(angle); + fingers[i].SetSteerAngle(angle.value); fingers[i].SetSteerSpeed(0.5f); } af.GetPhysics().Activate(); @@ -2164,6 +2224,11 @@ private void Event_StopFingers() { fingers[i].SetSteerAngle(fingers[i].GetAngle()); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* diff --git a/src/main/java/neo/Game/AI/AI.java b/src/main/java/neo/Game/AI/AI.java index 01887821..26511049 100644 --- a/src/main/java/neo/Game/AI/AI.java +++ b/src/main/java/neo/Game/AI/AI.java @@ -1,7 +1,5 @@ package neo.Game.AI; -import static java.lang.Math.abs; -import static neo.CM.CollisionModel.CM_CLIP_EPSILON; import neo.CM.CollisionModel.trace_s; import neo.Game.AF.afTouch_s; import neo.Game.AFEntity.idAFAttachment; @@ -11,6 +9,67 @@ import neo.Game.AI.AAS.aasPath_s; import neo.Game.AI.AAS.idAAS; import neo.Game.AI.AAS.idAASCallback; +import neo.Game.AI.AI_pathing.ballistics_s; +import neo.Game.AI.AI_pathing.obstacle_s; +import neo.Game.AI.AI_pathing.pathNode_s; +import neo.Game.AI.AI_pathing.pathTrace_s; +import neo.Game.Actor.idActor; +import neo.Game.Animation.Anim.animFlags_t; +import neo.Game.Animation.Anim.frameCommand_t; +import neo.Game.Animation.Anim_Blend.idAnim; +import neo.Game.Animation.Anim_Blend.idAnimator; +import neo.Game.Animation.Anim_Blend.idDeclModelDef; +import neo.Game.Entity.idEntity; +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.eventCallback_t2; +import neo.Game.GameSys.Class.eventCallback_t3; +import neo.Game.GameSys.Class.idClass; +import neo.Game.GameSys.Class.idEventArg; +import neo.Game.GameSys.Event.idEventDef; +import neo.Game.GameSys.SaveGame.idRestoreGame; +import neo.Game.GameSys.SaveGame.idSaveGame; +import neo.Game.Game_local.idEntityPtr; +import neo.Game.Misc.idPathCorner; +import neo.Game.Moveable.idMoveable; +import neo.Game.Physics.Clip.idClipModel; +import neo.Game.Physics.Physics.idPhysics; +import neo.Game.Physics.Physics_Monster.idPhysics_Monster; +import neo.Game.Physics.Physics_Monster.monsterMoveResult_t; +import neo.Game.Player.idPlayer; +import neo.Game.Projectile.idProjectile; +import neo.Game.Projectile.idSoulCubeMissile; +import neo.Game.Pvs.pvsHandle_t; +import neo.Game.Script.Script_Program.idScriptBool; +import neo.Game.Script.Script_Program.idScriptFloat; +import neo.Game.Script.Script_Thread.idThread; +import neo.Renderer.RenderWorld.renderLight_s; +import neo.Sound.snd_shader.idSoundShader; +import neo.Tools.Compilers.AAS.AASFile.idAASSettings; +import neo.Tools.Compilers.AAS.AASFile.idReachability; +import neo.framework.CmdSystem.cmdFunction_t; +import neo.framework.DeclParticle.idDeclParticle; +import neo.idlib.BV.Bounds.idBounds; +import neo.idlib.CmdArgs.idCmdArgs; +import neo.idlib.Dict_h.idDict; +import neo.idlib.Dict_h.idKeyValue; +import neo.idlib.Text.Str.idStr; +import neo.idlib.containers.List.idList; +import neo.idlib.geometry.TraceModel.idTraceModel; +import neo.idlib.math.Angles.idAngles; +import neo.idlib.math.Math_h.idMath; +import neo.idlib.math.Matrix.idMat3; +import neo.idlib.math.Quat.idQuat; +import neo.idlib.math.Vector.idVec2; +import neo.idlib.math.Vector.idVec3; +import neo.idlib.math.Vector.idVec4; + +import java.util.HashMap; +import java.util.Map; + +import static java.lang.Math.abs; +import static neo.CM.CollisionModel.CM_CLIP_EPSILON; import static neo.Game.AI.AI.moveCommand_t.MOVE_FACE_ENEMY; import static neo.Game.AI.AI.moveCommand_t.MOVE_FACE_ENTITY; import static neo.Game.AI.AI.moveCommand_t.MOVE_NONE; @@ -45,10 +104,129 @@ import static neo.Game.AI.AI.talkState_t.TALK_DEAD; import static neo.Game.AI.AI.talkState_t.TALK_NEVER; import static neo.Game.AI.AI.talkState_t.TALK_OK; +import static neo.Game.AI.AI_Events.AI_AllowDamage; +import static neo.Game.AI.AI_Events.AI_AllowHiddenMovement; +import static neo.Game.AI.AI_Events.AI_AllowMovement; +import static neo.Game.AI.AI_Events.AI_AnimTurn; +import static neo.Game.AI.AI_Events.AI_AttackMelee; +import static neo.Game.AI.AI_Events.AI_AttackMissile; +import static neo.Game.AI.AI_Events.AI_BecomeRagdoll; +import static neo.Game.AI.AI_Events.AI_BecomeSolid; +import static neo.Game.AI.AI_Events.AI_BeginAttack; +import static neo.Game.AI.AI_Events.AI_Burn; +import static neo.Game.AI.AI_Events.AI_CanBecomeSolid; +import static neo.Game.AI.AI_Events.AI_CanHitEnemy; +import static neo.Game.AI.AI_Events.AI_CanHitEnemyFromAnim; +import static neo.Game.AI.AI_Events.AI_CanHitEnemyFromJoint; +import static neo.Game.AI.AI_Events.AI_CanReachEnemy; +import static neo.Game.AI.AI_Events.AI_CanReachEntity; +import static neo.Game.AI.AI_Events.AI_CanReachPosition; +import static neo.Game.AI.AI_Events.AI_CanSeeEntity; +import static neo.Game.AI.AI_Events.AI_ChargeAttack; +import static neo.Game.AI.AI_Events.AI_ClearBurn; +import static neo.Game.AI.AI_Events.AI_ClearEnemy; +import static neo.Game.AI.AI_Events.AI_ClearFlyOffset; +import static neo.Game.AI.AI_Events.AI_ClosestReachableEnemyOfEntity; +import static neo.Game.AI.AI_Events.AI_CreateMissile; +import static neo.Game.AI.AI_Events.AI_DirectDamage; +import static neo.Game.AI.AI_Events.AI_DisableAFPush; +import static neo.Game.AI.AI_Events.AI_DisableClip; +import static neo.Game.AI.AI_Events.AI_DisableGravity; +import static neo.Game.AI.AI_Events.AI_EnableAFPush; +import static neo.Game.AI.AI_Events.AI_EnableClip; +import static neo.Game.AI.AI_Events.AI_EnableGravity; +import static neo.Game.AI.AI_Events.AI_EndAttack; +import static neo.Game.AI.AI_Events.AI_EnemyInCombatCone; +import static neo.Game.AI.AI_Events.AI_EnemyPositionValid; +import static neo.Game.AI.AI_Events.AI_EnemyRange; +import static neo.Game.AI.AI_Events.AI_EnemyRange2D; +import static neo.Game.AI.AI_Events.AI_EntityInAttackCone; +import static neo.Game.AI.AI_Events.AI_FaceEnemy; +import static neo.Game.AI.AI_Events.AI_FaceEntity; +import static neo.Game.AI.AI_Events.AI_FacingIdeal; +import static neo.Game.AI.AI_Events.AI_FindActorsInBounds; +import static neo.Game.AI.AI_Events.AI_FindEnemy; +import static neo.Game.AI.AI_Events.AI_FindEnemyAI; +import static neo.Game.AI.AI_Events.AI_FindEnemyInCombatNodes; +import static neo.Game.AI.AI_Events.AI_FireMissileAtTarget; +import static neo.Game.AI.AI_Events.AI_GetClosestHiddenTarget; +import static neo.Game.AI.AI_Events.AI_GetCombatNode; +import static neo.Game.AI.AI_Events.AI_GetCurrentYaw; +import static neo.Game.AI.AI_Events.AI_GetEnemy; +import static neo.Game.AI.AI_Events.AI_GetEnemyEyePos; +import static neo.Game.AI.AI_Events.AI_GetEnemyPos; +import static neo.Game.AI.AI_Events.AI_GetHealth; +import static neo.Game.AI.AI_Events.AI_GetJumpVelocity; +import static neo.Game.AI.AI_Events.AI_GetMoveType; +import static neo.Game.AI.AI_Events.AI_GetObstacle; +import static neo.Game.AI.AI_Events.AI_GetRandomTarget; +import static neo.Game.AI.AI_Events.AI_GetReachableEntityPosition; +import static neo.Game.AI.AI_Events.AI_GetTalkTarget; +import static neo.Game.AI.AI_Events.AI_GetTurnDelta; +import static neo.Game.AI.AI_Events.AI_GetTurnRate; +import static neo.Game.AI.AI_Events.AI_HeardSound; +import static neo.Game.AI.AI_Events.AI_IgnoreDamage; +import static neo.Game.AI.AI_Events.AI_JumpFrame; +import static neo.Game.AI.AI_Events.AI_KickObstacles; +import static neo.Game.AI.AI_Events.AI_Kill; +import static neo.Game.AI.AI_Events.AI_LaunchMissile; +import static neo.Game.AI.AI_Events.AI_LocateEnemy; +import static neo.Game.AI.AI_Events.AI_LookAtEnemy; +import static neo.Game.AI.AI_Events.AI_LookAtEntity; +import static neo.Game.AI.AI_Events.AI_MeleeAttackToJoint; +import static neo.Game.AI.AI_Events.AI_MoveOutOfRange; +import static neo.Game.AI.AI_Events.AI_MoveStatus; +import static neo.Game.AI.AI_Events.AI_MoveToAttackPosition; +import static neo.Game.AI.AI_Events.AI_MoveToCover; +import static neo.Game.AI.AI_Events.AI_MoveToEnemy; +import static neo.Game.AI.AI_Events.AI_MoveToEnemyHeight; +import static neo.Game.AI.AI_Events.AI_MoveToEntity; +import static neo.Game.AI.AI_Events.AI_MoveToPosition; +import static neo.Game.AI.AI_Events.AI_MuzzleFlash; +import static neo.Game.AI.AI_Events.AI_NumSmokeEmitters; +import static neo.Game.AI.AI_Events.AI_PreBurn; +import static neo.Game.AI.AI_Events.AI_PredictEnemyPos; +import static neo.Game.AI.AI_Events.AI_PushPointIntoAAS; +import static neo.Game.AI.AI_Events.AI_RadiusDamageFromJoint; +import static neo.Game.AI.AI_Events.AI_RandomPath; import static neo.Game.AI.AI_Events.AI_RealKill; +import static neo.Game.AI.AI_Events.AI_RestoreMove; +import static neo.Game.AI.AI_Events.AI_SaveMove; +import static neo.Game.AI.AI_Events.AI_SetEnemy; +import static neo.Game.AI.AI_Events.AI_SetFlyOffset; +import static neo.Game.AI.AI_Events.AI_SetFlySpeed; +import static neo.Game.AI.AI_Events.AI_SetHealth; +import static neo.Game.AI.AI_Events.AI_SetJointMod; +import static neo.Game.AI.AI_Events.AI_SetMoveType; +import static neo.Game.AI.AI_Events.AI_SetSmokeVisibility; +import static neo.Game.AI.AI_Events.AI_SetTalkState; +import static neo.Game.AI.AI_Events.AI_SetTalkTarget; +import static neo.Game.AI.AI_Events.AI_SetTurnRate; import static neo.Game.AI.AI_Events.AI_Shrivel; +import static neo.Game.AI.AI_Events.AI_SlideTo; +import static neo.Game.AI.AI_Events.AI_StopMove; +import static neo.Game.AI.AI_Events.AI_StopRagdoll; +import static neo.Game.AI.AI_Events.AI_StopThinking; +import static neo.Game.AI.AI_Events.AI_TestAnimAttack; +import static neo.Game.AI.AI_Events.AI_TestAnimMove; +import static neo.Game.AI.AI_Events.AI_TestAnimMoveTowardEnemy; +import static neo.Game.AI.AI_Events.AI_TestChargeAttack; +import static neo.Game.AI.AI_Events.AI_TestMeleeAttack; +import static neo.Game.AI.AI_Events.AI_TestMoveToPosition; +import static neo.Game.AI.AI_Events.AI_ThrowAF; +import static neo.Game.AI.AI_Events.AI_ThrowMoveable; +import static neo.Game.AI.AI_Events.AI_TravelDistanceBetweenEntities; +import static neo.Game.AI.AI_Events.AI_TravelDistanceBetweenPoints; +import static neo.Game.AI.AI_Events.AI_TravelDistanceToEntity; +import static neo.Game.AI.AI_Events.AI_TravelDistanceToPoint; +import static neo.Game.AI.AI_Events.AI_TriggerParticles; +import static neo.Game.AI.AI_Events.AI_TurnTo; +import static neo.Game.AI.AI_Events.AI_TurnToEntity; +import static neo.Game.AI.AI_Events.AI_TurnToPos; import static neo.Game.AI.AI_Events.AI_WaitAction; import static neo.Game.AI.AI_Events.AI_WaitMove; +import static neo.Game.AI.AI_Events.AI_WakeOnFlashlight; +import static neo.Game.AI.AI_Events.AI_Wander; import static neo.Game.AI.AI_pathing.Ballistics; import static neo.Game.AI.AI_pathing.BuildPathTree; import static neo.Game.AI.AI_pathing.DrawPathTree; @@ -61,34 +239,23 @@ import static neo.Game.AI.AI_pathing.OVERCLIP; import static neo.Game.AI.AI_pathing.PathTrace; import static neo.Game.AI.AI_pathing.PrunePathTree; -import neo.Game.AI.AI_pathing.ballistics_s; -import neo.Game.AI.AI_pathing.obstacle_s; import static neo.Game.AI.AI_pathing.pathNodeAllocator; -import neo.Game.AI.AI_pathing.pathNode_s; -import neo.Game.AI.AI_pathing.pathTrace_s; import static neo.Game.Actor.AI_PlayAnim; -import neo.Game.Actor.idActor; import static neo.Game.Animation.Anim.ANIMCHANNEL_LEGS; import static neo.Game.Animation.Anim.ANIMCHANNEL_TORSO; import static neo.Game.Animation.Anim.FRAME2MS; -import neo.Game.Animation.Anim.animFlags_t; import static neo.Game.Animation.Anim.frameCommandType_t.FC_LAUNCHMISSILE; -import neo.Game.Animation.Anim.frameCommand_t; import static neo.Game.Animation.Anim.jointModTransform_t.JOINTMOD_WORLD; import static neo.Game.Animation.Anim.jointModTransform_t.JOINTMOD_WORLD_OVERRIDE; -import neo.Game.Animation.Anim_Blend.idAnim; -import neo.Game.Animation.Anim_Blend.idAnimator; -import neo.Game.Animation.Anim_Blend.idDeclModelDef; +import static neo.Game.Entity.EV_Activate; +import static neo.Game.Entity.EV_GetAngles; +import static neo.Game.Entity.EV_SetAngles; import static neo.Game.Entity.EV_SetOwner; +import static neo.Game.Entity.EV_Touch; import static neo.Game.Entity.TH_PHYSICS; import static neo.Game.Entity.TH_THINK; import static neo.Game.Entity.TH_UPDATEPARTICLES; -import neo.Game.Entity.idEntity; import static neo.Game.GameSys.Class.EV_Remove; -import neo.Game.GameSys.Class.idClass; -import neo.Game.GameSys.Event.idEventDef; -import neo.Game.GameSys.SaveGame.idRestoreGame; -import neo.Game.GameSys.SaveGame.idSaveGame; import static neo.Game.GameSys.SysCvar.ai_blockedFailSafe; import static neo.Game.GameSys.SysCvar.ai_debugMove; import static neo.Game.GameSys.SysCvar.ai_debugTrajectory; @@ -111,22 +278,9 @@ import static neo.Game.Game_local.gameSoundChannel_t.SND_CHANNEL_AMBIENT; import static neo.Game.Game_local.gameSoundChannel_t.SND_CHANNEL_DAMAGE; import static neo.Game.Game_local.gameSoundChannel_t.SND_CHANNEL_VOICE; -import neo.Game.Game_local.idEntityPtr; -import neo.Game.Misc.idPathCorner; -import neo.Game.Moveable.idMoveable; -import neo.Game.Physics.Clip.idClipModel; -import neo.Game.Physics.Physics.idPhysics; -import neo.Game.Physics.Physics_Monster.idPhysics_Monster; -import neo.Game.Physics.Physics_Monster.monsterMoveResult_t; +import static neo.Game.Moveable.EV_BecomeNonSolid; import static neo.Game.Physics.Physics_Monster.monsterMoveResult_t.MM_BLOCKED; import static neo.Game.Player.SAVING_THROW_TIME; -import neo.Game.Player.idPlayer; -import neo.Game.Projectile.idProjectile; -import neo.Game.Projectile.idSoulCubeMissile; -import neo.Game.Pvs.pvsHandle_t; -import neo.Game.Script.Script_Program.idScriptBool; -import neo.Game.Script.Script_Program.idScriptFloat; -import neo.Game.Script.Script_Thread.idThread; import static neo.Renderer.Material.CONTENTS_BODY; import static neo.Renderer.Material.CONTENTS_SOLID; import static neo.Renderer.Model.INVALID_JOINT; @@ -139,8 +293,6 @@ import static neo.Renderer.RenderWorld.SHADERPARM_TIMEOFFSET; import static neo.Renderer.RenderWorld.SHADERPARM_TIMESCALE; import static neo.Renderer.RenderWorld.SHADERPARM_TIME_OF_DEATH; -import neo.Renderer.RenderWorld.renderLight_s; -import neo.Sound.snd_shader.idSoundShader; import static neo.TempDump.NOT; import static neo.TempDump.etoi; import static neo.TempDump.isNotNullOrEmpty; @@ -150,16 +302,8 @@ import static neo.Tools.Compilers.AAS.AASFile.TFL_AIR; import static neo.Tools.Compilers.AAS.AASFile.TFL_FLY; import static neo.Tools.Compilers.AAS.AASFile.TFL_WALK; -import neo.Tools.Compilers.AAS.AASFile.idAASSettings; -import neo.Tools.Compilers.AAS.AASFile.idReachability; -import neo.framework.CmdSystem.cmdFunction_t; import static neo.framework.DeclManager.declManager; import static neo.framework.DeclManager.declType_t.DECL_PARTICLE; -import neo.framework.DeclParticle.idDeclParticle; -import neo.idlib.BV.Bounds.idBounds; -import neo.idlib.CmdArgs.idCmdArgs; -import neo.idlib.Dict_h.idDict; -import neo.idlib.Dict_h.idKeyValue; import static neo.idlib.Lib.BIT; import static neo.idlib.Lib.MAX_WORLD_SIZE; import static neo.idlib.Lib.colorBlue; @@ -172,25 +316,15 @@ import static neo.idlib.Lib.colorRed; import static neo.idlib.Lib.colorWhite; import static neo.idlib.Lib.colorYellow; -import neo.idlib.Text.Str.idStr; import static neo.idlib.Text.Str.va; -import neo.idlib.containers.List.idList; -import neo.idlib.geometry.TraceModel.idTraceModel; import static neo.idlib.math.Angles.getAng_zero; -import neo.idlib.math.Angles.idAngles; import static neo.idlib.math.Math_h.DEG2RAD; import static neo.idlib.math.Math_h.MS2SEC; import static neo.idlib.math.Math_h.SEC2MS; import static neo.idlib.math.Math_h.Square; -import neo.idlib.math.Math_h.idMath; -import neo.idlib.math.Matrix.idMat3; import static neo.idlib.math.Matrix.idMat3.getMat3_identity; -import neo.idlib.math.Quat.idQuat; import static neo.idlib.math.Vector.getVec3_origin; import static neo.idlib.math.Vector.getVec3_zero; -import neo.idlib.math.Vector.idVec2; -import neo.idlib.math.Vector.idVec3; -import neo.idlib.math.Vector.idVec4; /** * @@ -569,6 +703,137 @@ public boolean TestArea(final idAAS aas, int areaNum) { public static class idAI extends idActor { // CLASS_PROTOTYPE( idAI ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idAI::Event_Activate); + eventCallbacks.put(EV_Touch, (eventCallback_t2) idAI::Event_Touch); + eventCallbacks.put(AI_FindEnemy, (eventCallback_t1) idAI::Event_FindEnemy); + eventCallbacks.put(AI_FindEnemyAI, (eventCallback_t1) idAI::Event_FindEnemyAI); + eventCallbacks.put(AI_FindEnemyInCombatNodes, (eventCallback_t0) idAI::Event_FindEnemyInCombatNodes); + eventCallbacks.put(AI_ClosestReachableEnemyOfEntity, (eventCallback_t1) idAI::Event_ClosestReachableEnemyOfEntity); + eventCallbacks.put(AI_HeardSound, (eventCallback_t1) idAI::Event_HeardSound); + eventCallbacks.put(AI_SetEnemy, (eventCallback_t1) idAI::Event_SetEnemy); + eventCallbacks.put(AI_ClearEnemy, (eventCallback_t0) idAI::Event_ClearEnemy); + eventCallbacks.put(AI_MuzzleFlash, (eventCallback_t1) idAI::Event_MuzzleFlash); + eventCallbacks.put(AI_CreateMissile, (eventCallback_t1) idAI::Event_CreateMissile); + eventCallbacks.put(AI_AttackMissile, (eventCallback_t1) idAI::Event_AttackMissile); + eventCallbacks.put(AI_FireMissileAtTarget, (eventCallback_t2) idAI::Event_FireMissileAtTarget); + eventCallbacks.put(AI_LaunchMissile, (eventCallback_t2) idAI::Event_LaunchMissile); + eventCallbacks.put(AI_AttackMelee, (eventCallback_t1) idAI::Event_AttackMelee); + eventCallbacks.put(AI_DirectDamage, (eventCallback_t2) idAI::Event_DirectDamage); + eventCallbacks.put(AI_RadiusDamageFromJoint, (eventCallback_t2) idAI::Event_RadiusDamageFromJoint); + eventCallbacks.put(AI_BeginAttack, (eventCallback_t1) idAI::Event_BeginAttack); + eventCallbacks.put(AI_EndAttack, (eventCallback_t0) idAI::Event_EndAttack); + eventCallbacks.put(AI_MeleeAttackToJoint, (eventCallback_t2) idAI::Event_MeleeAttackToJoint); + eventCallbacks.put(AI_RandomPath, (eventCallback_t0) idAI::Event_RandomPath); + eventCallbacks.put(AI_CanBecomeSolid, (eventCallback_t0) idAI::Event_CanBecomeSolid); + eventCallbacks.put(AI_BecomeSolid, (eventCallback_t0) idAI::Event_BecomeSolid); + eventCallbacks.put(EV_BecomeNonSolid, (eventCallback_t0) idAI::Event_BecomeNonSolid); + eventCallbacks.put(AI_BecomeRagdoll, (eventCallback_t0) idAI::Event_BecomeRagdoll); + eventCallbacks.put(AI_StopRagdoll, (eventCallback_t0) idAI::Event_StopRagdoll); + eventCallbacks.put(AI_SetHealth, (eventCallback_t1) idAI::Event_SetHealth); + eventCallbacks.put(AI_GetHealth, (eventCallback_t0) idAI::Event_GetHealth); + eventCallbacks.put(AI_AllowDamage, (eventCallback_t0) idAI::Event_AllowDamage); + eventCallbacks.put(AI_IgnoreDamage, (eventCallback_t0) idAI::Event_IgnoreDamage); + eventCallbacks.put(AI_GetCurrentYaw, (eventCallback_t0) idAI::Event_GetCurrentYaw); + eventCallbacks.put(AI_TurnTo, (eventCallback_t1) idAI::Event_TurnTo); + eventCallbacks.put(AI_TurnToPos, (eventCallback_t1) idAI::Event_TurnToPos); + eventCallbacks.put(AI_TurnToEntity, (eventCallback_t1) idAI::Event_TurnToEntity); + eventCallbacks.put(AI_MoveStatus, (eventCallback_t0) idAI::Event_MoveStatus); + eventCallbacks.put(AI_StopMove, (eventCallback_t0) idAI::Event_StopMove); + eventCallbacks.put(AI_MoveToCover, (eventCallback_t0) idAI::Event_MoveToCover); + eventCallbacks.put(AI_MoveToEnemy, (eventCallback_t0) idAI::Event_MoveToEnemy); + eventCallbacks.put(AI_MoveToEnemyHeight, (eventCallback_t0) idAI::Event_MoveToEnemyHeight); + eventCallbacks.put(AI_MoveOutOfRange, (eventCallback_t2) idAI::Event_MoveOutOfRange); + eventCallbacks.put(AI_MoveToAttackPosition, (eventCallback_t2) idAI::Event_MoveToAttackPosition); + eventCallbacks.put(AI_Wander, (eventCallback_t0) idAI::Event_Wander); + eventCallbacks.put(AI_MoveToEntity, (eventCallback_t1) idAI::Event_MoveToEntity); + eventCallbacks.put(AI_MoveToPosition, (eventCallback_t1) idAI::Event_MoveToPosition); + eventCallbacks.put(AI_SlideTo, (eventCallback_t2) idAI::Event_SlideTo); + eventCallbacks.put(AI_FacingIdeal, (eventCallback_t0) idAI::Event_FacingIdeal); + eventCallbacks.put(AI_FaceEnemy, (eventCallback_t0) idAI::Event_FaceEnemy); + eventCallbacks.put(AI_FaceEntity, (eventCallback_t1) idAI::Event_FaceEntity); + eventCallbacks.put(AI_WaitAction, (eventCallback_t1) idAI::Event_WaitAction); + eventCallbacks.put(AI_GetCombatNode, (eventCallback_t0) idAI::Event_GetCombatNode); + eventCallbacks.put(AI_EnemyInCombatCone, (eventCallback_t2) idAI::Event_EnemyInCombatCone); + eventCallbacks.put(AI_WaitMove, (eventCallback_t0) idAI::Event_WaitMove); + eventCallbacks.put(AI_GetJumpVelocity, (eventCallback_t3) idAI::Event_GetJumpVelocity); + eventCallbacks.put(AI_EntityInAttackCone, (eventCallback_t1) idAI::Event_EntityInAttackCone); + eventCallbacks.put(AI_CanSeeEntity, (eventCallback_t1) idAI::Event_CanSeeEntity); + eventCallbacks.put(AI_SetTalkTarget, (eventCallback_t1) idAI::Event_SetTalkTarget); + eventCallbacks.put(AI_GetTalkTarget, (eventCallback_t0) idAI::Event_GetTalkTarget); + eventCallbacks.put(AI_SetTalkState, (eventCallback_t1) idAI::Event_SetTalkState); + eventCallbacks.put(AI_EnemyRange, (eventCallback_t0) idAI::Event_EnemyRange); + eventCallbacks.put(AI_EnemyRange2D, (eventCallback_t0) idAI::Event_EnemyRange2D); + eventCallbacks.put(AI_GetEnemy, (eventCallback_t0) idAI::Event_GetEnemy); + eventCallbacks.put(AI_GetEnemyPos, (eventCallback_t0) idAI::Event_GetEnemyPos); + eventCallbacks.put(AI_GetEnemyEyePos, (eventCallback_t0) idAI::Event_GetEnemyEyePos); + eventCallbacks.put(AI_PredictEnemyPos, (eventCallback_t1) idAI::Event_PredictEnemyPos); + eventCallbacks.put(AI_CanHitEnemy, (eventCallback_t0) idAI::Event_CanHitEnemy); + eventCallbacks.put(AI_CanHitEnemyFromAnim, (eventCallback_t1) idAI::Event_CanHitEnemyFromAnim); + eventCallbacks.put(AI_CanHitEnemyFromJoint, (eventCallback_t1) idAI::Event_CanHitEnemyFromJoint); + eventCallbacks.put(AI_EnemyPositionValid, (eventCallback_t0) idAI::Event_EnemyPositionValid); + eventCallbacks.put(AI_ChargeAttack, (eventCallback_t1) idAI::Event_ChargeAttack); + eventCallbacks.put(AI_TestChargeAttack, (eventCallback_t0) idAI::Event_TestChargeAttack); + eventCallbacks.put(AI_TestAnimMoveTowardEnemy, (eventCallback_t1) idAI::Event_TestAnimMoveTowardEnemy); + eventCallbacks.put(AI_TestAnimMove, (eventCallback_t1) idAI::Event_TestAnimMove); + eventCallbacks.put(AI_TestMoveToPosition, (eventCallback_t1) idAI::Event_TestMoveToPosition); + eventCallbacks.put(AI_TestMeleeAttack, (eventCallback_t0) idAI::Event_TestMeleeAttack); + eventCallbacks.put(AI_TestAnimAttack, (eventCallback_t1) idAI::Event_TestAnimAttack); + eventCallbacks.put(AI_Shrivel, (eventCallback_t1) idAI::Event_Shrivel); + eventCallbacks.put(AI_Burn, (eventCallback_t0) idAI::Event_Burn); + eventCallbacks.put(AI_PreBurn, (eventCallback_t0) idAI::Event_PreBurn); + eventCallbacks.put(AI_SetSmokeVisibility, (eventCallback_t2) idAI::Event_SetSmokeVisibility); + eventCallbacks.put(AI_NumSmokeEmitters, (eventCallback_t0) idAI::Event_NumSmokeEmitters); + eventCallbacks.put(AI_ClearBurn, (eventCallback_t0) idAI::Event_ClearBurn); + eventCallbacks.put(AI_StopThinking, (eventCallback_t0) idAI::Event_StopThinking); + eventCallbacks.put(AI_GetTurnDelta, (eventCallback_t0) idAI::Event_GetTurnDelta); + eventCallbacks.put(AI_GetMoveType, (eventCallback_t0) idAI::Event_GetMoveType); + eventCallbacks.put(AI_SetMoveType, (eventCallback_t1) idAI::Event_SetMoveType); + eventCallbacks.put(AI_SaveMove, (eventCallback_t0) idAI::Event_SaveMove); + eventCallbacks.put(AI_RestoreMove, (eventCallback_t0) idAI::Event_RestoreMove); + eventCallbacks.put(AI_AllowMovement, (eventCallback_t1) idAI::Event_AllowMovement); + eventCallbacks.put(AI_JumpFrame, (eventCallback_t0) idAI::Event_JumpFrame); + eventCallbacks.put(AI_EnableClip, (eventCallback_t0) idAI::Event_EnableClip); + eventCallbacks.put(AI_DisableClip, (eventCallback_t0) idAI::Event_DisableClip); + eventCallbacks.put(AI_EnableGravity, (eventCallback_t0) idAI::Event_EnableGravity); + eventCallbacks.put(AI_DisableGravity, (eventCallback_t0) idAI::Event_DisableGravity); + eventCallbacks.put(AI_EnableAFPush, (eventCallback_t0) idAI::Event_EnableAFPush); + eventCallbacks.put(AI_DisableAFPush, (eventCallback_t0) idAI::Event_DisableAFPush); + eventCallbacks.put(AI_SetFlySpeed, (eventCallback_t1) idAI::Event_SetFlySpeed); + eventCallbacks.put(AI_SetFlyOffset, (eventCallback_t1) idAI::Event_SetFlyOffset); + eventCallbacks.put(AI_ClearFlyOffset, (eventCallback_t0) idAI::Event_ClearFlyOffset); + eventCallbacks.put(AI_GetClosestHiddenTarget, (eventCallback_t1) idAI::Event_GetClosestHiddenTarget); + eventCallbacks.put(AI_GetRandomTarget, (eventCallback_t1) idAI::Event_GetRandomTarget); + eventCallbacks.put(AI_TravelDistanceToPoint, (eventCallback_t1) idAI::Event_TravelDistanceToPoint); + eventCallbacks.put(AI_TravelDistanceToEntity, (eventCallback_t1) idAI::Event_TravelDistanceToEntity); + eventCallbacks.put(AI_TravelDistanceBetweenPoints, (eventCallback_t2) idAI::Event_TravelDistanceBetweenPoints); + eventCallbacks.put(AI_TravelDistanceBetweenEntities, (eventCallback_t2) idAI::Event_TravelDistanceBetweenEntities); + eventCallbacks.put(AI_LookAtEntity, (eventCallback_t2) idAI::Event_LookAtEntity); + eventCallbacks.put(AI_LookAtEnemy, (eventCallback_t1) idAI::Event_LookAtEnemy); + eventCallbacks.put(AI_SetJointMod, (eventCallback_t1) idAI::Event_SetJointMod); + eventCallbacks.put(AI_ThrowMoveable, (eventCallback_t0) idAI::Event_ThrowMoveable); + eventCallbacks.put(AI_ThrowAF, (eventCallback_t0) idAI::Event_ThrowAF); + eventCallbacks.put(EV_GetAngles, (eventCallback_t0) idAI::Event_GetAngles); + eventCallbacks.put(EV_SetAngles, (eventCallback_t1) idAI::Event_SetAngles); + eventCallbacks.put(AI_RealKill, (eventCallback_t0) idAI::Event_RealKill); + eventCallbacks.put(AI_Kill, (eventCallback_t0) idAI::Event_Kill); + eventCallbacks.put(AI_WakeOnFlashlight, (eventCallback_t1) idAI::Event_WakeOnFlashlight); + eventCallbacks.put(AI_LocateEnemy, (eventCallback_t0) idAI::Event_LocateEnemy); + eventCallbacks.put(AI_KickObstacles, (eventCallback_t2) idAI::Event_KickObstacles); + eventCallbacks.put(AI_GetObstacle, (eventCallback_t0) idAI::Event_GetObstacle); + eventCallbacks.put(AI_PushPointIntoAAS, (eventCallback_t1) idAI::Event_PushPointIntoAAS); + eventCallbacks.put(AI_GetTurnRate, (eventCallback_t0) idAI::Event_GetTurnRate); + eventCallbacks.put(AI_SetTurnRate, (eventCallback_t1) idAI::Event_SetTurnRate); + eventCallbacks.put(AI_AnimTurn, (eventCallback_t1) idAI::Event_AnimTurn); + eventCallbacks.put(AI_AllowHiddenMovement, (eventCallback_t1) idAI::Event_AllowHiddenMovement); + eventCallbacks.put(AI_TriggerParticles, (eventCallback_t1) idAI::Event_TriggerParticles); + eventCallbacks.put(AI_FindActorsInBounds, (eventCallback_t2) idAI::Event_FindActorsInBounds); + eventCallbacks.put(AI_CanReachPosition, (eventCallback_t1) idAI::Event_CanReachPosition); + eventCallbacks.put(AI_CanReachEntity, (eventCallback_t1) idAI::Event_CanReachEntity); + eventCallbacks.put(AI_CanReachEnemy, (eventCallback_t0) idAI::Event_CanReachEnemy); + eventCallbacks.put(AI_GetReachableEntityPosition, (eventCallback_t1) idAI::Event_GetReachableEntityPosition); + } // navigation protected idAAS aas; @@ -5295,18 +5560,19 @@ protected void UpdateAIScript() { // // ai/ai_events.cpp // - protected void Event_Activate(idEntity activator) { - Activate(activator); + protected void Event_Activate(idEventArg activator) { + Activate(activator.value); } - protected void Event_Touch(idEntity other, trace_s trace) { + protected void Event_Touch(idEventArg _other, idEventArg trace) { + idEntity other = _other.value; if (null == enemy.GetEntity() && !other.fl.notarget && (ReactionTo(other) & ATTACK_ON_ACTIVATE) != 0) { Activate(other); } AI_PUSHED._(true); } - protected void Event_FindEnemy(int useFOV) { + protected void Event_FindEnemy(idEventArg useFOV) { int i; idEntity ent; idActor actor; @@ -5324,7 +5590,7 @@ protected void Event_FindEnemy(int useFOV) { continue; } - if (CanSee(actor, useFOV != 0)) { + if (CanSee(actor, useFOV.value != 0)) { idThread.ReturnEntity(actor); return; } @@ -5334,7 +5600,7 @@ protected void Event_FindEnemy(int useFOV) { idThread.ReturnEntity(null); } - protected void Event_FindEnemyAI(int useFOV) { + protected void Event_FindEnemyAI(idEventArg useFOV) { idEntity ent; idActor actor; idActor bestEnemy; @@ -5363,7 +5629,7 @@ protected void Event_FindEnemyAI(int useFOV) { delta = physicsObj.GetOrigin().oMinus(actor.GetPhysics().GetOrigin()); dist = delta.LengthSqr(); - if ((dist < bestDist) && CanSee(actor, useFOV != 0)) { + if ((dist < bestDist) && CanSee(actor, useFOV.value != 0)) { bestDist = dist; bestEnemy = actor; } @@ -5415,7 +5681,8 @@ protected void Event_FindEnemyInCombatNodes() { idThread.ReturnEntity(null); } - protected void Event_ClosestReachableEnemyOfEntity(idEntity team_mate) { + protected void Event_ClosestReachableEnemyOfEntity(idEventArg _team_mate) { + idEntity team_mate = _team_mate.value; idActor actor; idActor ent; idActor bestEnt; @@ -5456,10 +5723,10 @@ protected void Event_ClosestReachableEnemyOfEntity(idEntity team_mate) { idThread.ReturnEntity(bestEnt); } - protected void Event_HeardSound(int ignore_team) { + protected void Event_HeardSound(idEventArg ignore_team) { // check if we heard any sounds in the last frame idActor actor = gameLocal.GetAlertEntity(); - if (actor != null && (0 == ignore_team || (ReactionTo(actor) & ATTACK_ON_SIGHT) != 0) && gameLocal.InPlayerPVS(this)) { + if (actor != null && (0 == ignore_team.value || (ReactionTo(actor) & ATTACK_ON_SIGHT) != 0) && gameLocal.InPlayerPVS(this)) { idVec3 pos = actor.GetPhysics().GetOrigin(); idVec3 org = physicsObj.GetOrigin(); float dist = (pos.oMinus(org)).LengthSqr(); @@ -5472,7 +5739,8 @@ protected void Event_HeardSound(int ignore_team) { idThread.ReturnEntity(null); } - protected void Event_SetEnemy(idEntity ent) { + protected void Event_SetEnemy(idEventArg _ent) { + idEntity ent = _ent.value; if (null == ent) { ClearEnemy(); } else if (!ent.IsType(idActor.class)) { @@ -5486,15 +5754,16 @@ protected void Event_ClearEnemy() { ClearEnemy(); } - protected void Event_MuzzleFlash(final String jointname) { + protected void Event_MuzzleFlash(final idEventArg jointname) { idVec3 muzzle = new idVec3(); idMat3 axis = new idMat3(); - GetMuzzle(jointname, muzzle, axis); + GetMuzzle(jointname.value, muzzle, axis); TriggerWeaponEffects(muzzle); } - protected void Event_CreateMissile(final String jointname) { + protected void Event_CreateMissile(final idEventArg _jointname) { + String jointname = _jointname.value; idVec3 muzzle = new idVec3(); idMat3 axis = new idMat3(); @@ -5515,27 +5784,29 @@ protected void Event_CreateMissile(final String jointname) { idThread.ReturnEntity(projectile.GetEntity()); } - protected void Event_AttackMissile(final String jointname) { + protected void Event_AttackMissile(final idEventArg jointname) { idProjectile proj; - proj = LaunchProjectile(jointname, enemy.GetEntity(), true); + proj = LaunchProjectile(jointname.value, enemy.GetEntity(), true); idThread.ReturnEntity(proj); } - protected void Event_FireMissileAtTarget(final String jointname, final String targetname) { + protected void Event_FireMissileAtTarget(final idEventArg jointname, final idEventArg targetname) { idEntity aent; idProjectile proj; - aent = gameLocal.FindEntity(targetname); + aent = gameLocal.FindEntity(targetname.value); if (null == aent) { - gameLocal.Warning("Entity '%s' not found for 'fireMissileAtTarget'", targetname); + gameLocal.Warning("Entity '%s' not found for 'fireMissileAtTarget'", targetname.value); } - proj = LaunchProjectile(jointname, aent, false); + proj = LaunchProjectile(jointname.value, aent, false); idThread.ReturnEntity(proj); } - protected void Event_LaunchMissile(final idVec3 muzzle, final idAngles ang) { + protected void Event_LaunchMissile(final idEventArg _muzzle, final idEventArg _ang) { + final idVec3 muzzle = _muzzle.value; + final idAngles ang = _ang.value; idVec3 start; trace_s[] tr = {null}; idBounds projBounds; @@ -5585,44 +5856,44 @@ protected void Event_LaunchMissile(final idVec3 muzzle, final idAngles ang) { lastAttackTime = gameLocal.time; } - protected void Event_AttackMelee(final String meleeDefName) { + protected void Event_AttackMelee(final idEventArg meleeDefName) { int hit; - hit = AttackMelee(meleeDefName) ? 1 : 0; + hit = AttackMelee(meleeDefName.value) ? 1 : 0; idThread.ReturnInt(hit); } - protected void Event_DirectDamage(idEntity damageTarget, final String damageDefName) { - DirectDamage(damageDefName, damageTarget); + protected void Event_DirectDamage(idEventArg damageTarget, final idEventArg damageDefName) { + DirectDamage(damageDefName.value, damageTarget.value); } - protected void Event_RadiusDamageFromJoint(final String jointname, final String damageDefName) { + protected void Event_RadiusDamageFromJoint(final idEventArg jointname, final idEventArg damageDefName) { int/*jointHandle_t*/ joint; idVec3 org = new idVec3(); idMat3 axis = new idMat3(); - if (!isNotNullOrEmpty(jointname)) { + if (!isNotNullOrEmpty(jointname.value)) { org = physicsObj.GetOrigin(); } else { - joint = animator.GetJointHandle(jointname); + joint = animator.GetJointHandle(jointname.value); if (joint == INVALID_JOINT) { - gameLocal.Error("Unknown joint '%s' on %s", jointname, GetEntityDefName()); + gameLocal.Error("Unknown joint '%s' on %s", jointname.value, GetEntityDefName()); } GetJointWorldTransform(joint, gameLocal.time, org, axis); } - gameLocal.RadiusDamage(org, this, this, this, this, damageDefName); + gameLocal.RadiusDamage(org, this, this, this, this, damageDefName.value); } - protected void Event_BeginAttack(final String name) { - BeginAttack(name); + protected void Event_BeginAttack(final idEventArg name) { + BeginAttack(name.value); } protected void Event_EndAttack() { EndAttack(); } - protected void Event_MeleeAttackToJoint(final String jointname, final String meleeDefName) { + protected void Event_MeleeAttackToJoint(final idEventArg jointname, final idEventArg meleeDefName) { int/*jointHandle_t*/ joint; idVec3 start; idVec3 end = new idVec3(); @@ -5630,9 +5901,9 @@ protected void Event_MeleeAttackToJoint(final String jointname, final String mel trace_s trace = new trace_s(); idEntity hitEnt; - joint = animator.GetJointHandle(jointname); + joint = animator.GetJointHandle(jointname.value); if (joint == INVALID_JOINT) { - gameLocal.Error("Unknown joint '%s' on %s", jointname, GetEntityDefName()); + gameLocal.Error("Unknown joint '%s' on %s", jointname.value, GetEntityDefName()); } animator.GetJointTransform(joint, gameLocal.time, end, axis); end = physicsObj.GetOrigin().oPlus((end.oPlus(modelOffset)).oMultiply(viewAxis).oMultiply(physicsObj.GetGravityAxis())); @@ -5646,7 +5917,7 @@ protected void Event_MeleeAttackToJoint(final String jointname, final String mel if (trace.fraction < 1.0f) { hitEnt = gameLocal.GetTraceEntity(trace); if (hitEnt != null && hitEnt.IsType(idActor.class)) { - DirectDamage(meleeDefName, hitEnt); + DirectDamage(meleeDefName.value, hitEnt); idThread.ReturnInt(true); return; } @@ -5725,8 +5996,8 @@ protected void Event_StopRagdoll() { SetPhysics(physicsObj); } - protected void Event_SetHealth(float newHealth) { - health = (int) newHealth; + protected void Event_SetHealth(idEventArg newHealth) { + health = newHealth.value.intValue(); fl.takedamage = true; if (health > 0) { AI_DEAD._(false); @@ -5751,17 +6022,17 @@ protected void Event_GetCurrentYaw() { idThread.ReturnFloat(current_yaw); } - protected void Event_TurnTo(float angle) { - TurnToward(angle); + protected void Event_TurnTo(idEventArg angle) { + TurnToward(angle.value); } - protected void Event_TurnToPos(final idVec3 pos) { - TurnToward(pos); + protected void Event_TurnToPos(final idEventArg pos) { + TurnToward(pos.value); } - protected void Event_TurnToEntity(idEntity ent) { - if (ent != null) { - TurnToward(ent.GetPhysics().GetOrigin()); + protected void Event_TurnToEntity(idEventArg ent) { + if (ent.value != null) { + TurnToward(ent.value.GetPhysics().GetOrigin()); } } @@ -5794,38 +6065,38 @@ protected void Event_MoveToEnemyHeight() { MoveToEnemyHeight(); } - protected void Event_MoveOutOfRange(idEntity entity, float range) { + protected void Event_MoveOutOfRange(idEventArg entity, idEventArg range) { StopMove(MOVE_STATUS_DEST_NOT_FOUND); - MoveOutOfRange(entity, range); + MoveOutOfRange(entity.value, range.value); } - protected void Event_MoveToAttackPosition(idEntity entity, final String attack_anim) { + protected void Event_MoveToAttackPosition(idEventArg entity, final idEventArg attack_anim) { int anim; StopMove(MOVE_STATUS_DEST_NOT_FOUND); - anim = GetAnim(ANIMCHANNEL_LEGS, attack_anim); + anim = GetAnim(ANIMCHANNEL_LEGS, attack_anim.value); if (0 == anim) { - gameLocal.Error("Unknown anim '%s'", attack_anim); + gameLocal.Error("Unknown anim '%s'", attack_anim.value); } - MoveToAttackPosition(entity, anim); + MoveToAttackPosition(entity.value, anim); } - protected void Event_MoveToEntity(idEntity ent) { + protected void Event_MoveToEntity(idEventArg ent) { StopMove(MOVE_STATUS_DEST_NOT_FOUND); - if (ent != null) { - MoveToEntity(ent); + if (ent.value != null) { + MoveToEntity(ent.value); } } - protected void Event_MoveToPosition(final idVec3 pos) { + protected void Event_MoveToPosition(final idEventArg pos) { StopMove(MOVE_STATUS_DONE); - MoveToPosition(pos); + MoveToPosition(pos.value); } - protected void Event_SlideTo(final idVec3 pos, float time) { - SlideToPosition(pos, time); + protected void Event_SlideTo(final idEventArg pos, idEventArg time) { + SlideToPosition(pos.value, time.value); } protected void Event_Wander() { @@ -5841,13 +6112,13 @@ protected void Event_FaceEnemy() { FaceEnemy(); } - protected void Event_FaceEntity(idEntity ent) { - FaceEntity(ent); + protected void Event_FaceEntity(idEventArg ent) { + FaceEntity(ent.value); } - protected void Event_WaitAction(final String waitForState) { + protected void Event_WaitAction(final idEventArg waitForState) { if (idThread.BeginMultiFrameEvent(this, AI_WaitAction)) { - SetWaitState(waitForState); + SetWaitState(waitForState.value); } if (null == WaitState()) { @@ -5901,7 +6172,8 @@ protected void Event_GetCombatNode() { idThread.ReturnEntity(bestNode); } - protected void Event_EnemyInCombatCone(idEntity ent, int use_current_enemy_location) { + protected void Event_EnemyInCombatCone(idEventArg _ent, idEventArg use_current_enemy_location) { + idEntity ent = _ent.value; idCombatNode node; boolean result; idActor enemyEnt = enemy.GetEntity(); @@ -5925,7 +6197,7 @@ protected void Event_EnemyInCombatCone(idEntity ent, int use_current_enemy_locat } node = (idCombatNode) ent; - if (use_current_enemy_location != 0) { + if (use_current_enemy_location.value != 0) { final idVec3 pos = enemyEnt.GetPhysics().GetOrigin(); result = node.EntityInView(enemyEnt, pos); } else { @@ -5943,7 +6215,10 @@ protected void Event_WaitMove() { } } - protected void Event_GetJumpVelocity(final idVec3 pos, float speed, float max_height) { + protected void Event_GetJumpVelocity(final idEventArg _pos, idEventArg _speed, idEventArg _max_height) { + idVec3 pos = _pos.value; + float speed = _speed.value; + float max_height = _max_height.value; idVec3 start; idVec3 end; idVec3 dir; @@ -5977,18 +6252,18 @@ protected void Event_GetJumpVelocity(final idVec3 pos, float speed, float max_he } } - protected void Event_EntityInAttackCone(idEntity ent) { + protected void Event_EntityInAttackCone(idEventArg ent) { float attack_cone; idVec3 delta; float yaw; float relYaw; - if (null == ent) { + if (null == ent.value) { idThread.ReturnInt(false); return; } - delta = ent.GetPhysics().GetOrigin().oMinus(GetEyePosition()); + delta = ent.value.GetPhysics().GetOrigin().oMinus(GetEyePosition()); // get our gravity normal final idVec3 gravityDir = GetPhysics().GetGravityNormal(); @@ -6008,17 +6283,18 @@ protected void Event_EntityInAttackCone(idEntity ent) { } } - protected void Event_CanSeeEntity(idEntity ent) { - if (null == ent) { + protected void Event_CanSeeEntity(idEventArg ent) { + if (null == ent.value) { idThread.ReturnInt(false); return; } - boolean cansee = CanSee(ent, false); + boolean cansee = CanSee(ent.value, false); idThread.ReturnInt(cansee); } - protected void Event_SetTalkTarget(idEntity target) { + protected void Event_SetTalkTarget(idEventArg _target) { + idEntity target = _target.value; if (target != null && !target.IsType(idActor.class)) { gameLocal.Error("Cannot set talk target to '%s'. Not a character or player.", target.GetName()); } @@ -6034,7 +6310,8 @@ protected void Event_GetTalkTarget() { idThread.ReturnEntity(talkTarget.GetEntity()); } - protected void Event_SetTalkState(int state) { + protected void Event_SetTalkState(idEventArg _state) { + int state = _state.value; if ((state < 0) || (state >= etoi(NUM_TALK_STATES))) { gameLocal.Error("Invalid talk state (%d)", state); } @@ -6082,7 +6359,7 @@ protected void Event_GetEnemyEyePos() { idThread.ReturnVector(lastVisibleEnemyPos.oPlus(lastVisibleEnemyEyeOffset)); } - protected void Event_PredictEnemyPos(float time) { + protected void Event_PredictEnemyPos(idEventArg time) { predictedPath_s path = new predictedPath_s(); idActor enemyEnt = enemy.GetEntity(); @@ -6093,7 +6370,8 @@ protected void Event_PredictEnemyPos(float time) { } // predict the enemy movement - idAI.PredictPath(enemyEnt, aas, lastVisibleEnemyPos, enemyEnt.GetPhysics().GetLinearVelocity(), (int) SEC2MS(time), (int) SEC2MS(time), + idAI.PredictPath(enemyEnt, aas, lastVisibleEnemyPos, enemyEnt.GetPhysics().GetLinearVelocity(), + (int) SEC2MS(time.value), (int) SEC2MS(time.value), (move.moveType == MOVETYPE_FLY) ? SE_BLOCKED : (SE_BLOCKED | SE_ENTER_LEDGE_AREA), path); idThread.ReturnVector(path.endPos); @@ -6139,7 +6417,7 @@ protected void Event_CanHitEnemy() { idThread.ReturnInt(lastHitCheckResult); } - protected void Event_CanHitEnemyFromAnim(final String animname) { + protected void Event_CanHitEnemyFromAnim(final idEventArg animname) { int anim; idVec3 dir; idVec3 local_dir = new idVec3(); @@ -6155,7 +6433,7 @@ protected void Event_CanHitEnemyFromAnim(final String animname) { return; } - anim = GetAnim(ANIMCHANNEL_LEGS, animname); + anim = GetAnim(ANIMCHANNEL_LEGS, animname.value); if (0 == anim) { idThread.ReturnInt(false); return; @@ -6206,7 +6484,7 @@ protected void Event_CanHitEnemyFromAnim(final String animname) { } } - protected void Event_CanHitEnemyFromJoint(final String jointname) { + protected void Event_CanHitEnemyFromJoint(final idEventArg jointname) { trace_s[] tr = {null}; idVec3 muzzle = new idVec3(); idMat3 axis = new idMat3(); @@ -6229,9 +6507,9 @@ protected void Event_CanHitEnemyFromJoint(final String jointname) { final idVec3 org = physicsObj.GetOrigin(); idVec3 toPos = enemyEnt.GetEyePosition(); - int/*jointHandle_t*/ joint = animator.GetJointHandle(jointname); + int/*jointHandle_t*/ joint = animator.GetJointHandle(jointname.value); if (joint == INVALID_JOINT) { - gameLocal.Error("Unknown joint '%s' on %s", jointname, GetEntityDefName()); + gameLocal.Error("Unknown joint '%s' on %s", jointname.value, GetEntityDefName()); } animator.GetJointTransform(joint, gameLocal.time, muzzle, axis); muzzle = org.oPlus((muzzle.oPlus(modelOffset)).oMultiply(viewAxis).oMultiply(physicsObj.GetGravityAxis())); @@ -6276,7 +6554,7 @@ protected void Event_EnemyPositionValid() { idThread.ReturnInt(result); } - protected void Event_ChargeAttack(final String damageDef) { + protected void Event_ChargeAttack(final idEventArg damageDef) { idActor enemyEnt = enemy.GetEntity(); StopMove(MOVE_STATUS_DEST_NOT_FOUND); @@ -6291,7 +6569,7 @@ protected void Event_ChargeAttack(final String damageDef) { enemyOrg = enemyEnt.GetPhysics().GetOrigin(); } - BeginAttack(damageDef); + BeginAttack(damageDef.value); DirectMoveToPosition(enemyOrg); TurnToward(enemyOrg); } @@ -6332,7 +6610,7 @@ protected void Event_TestChargeAttack() { } } - protected void Event_TestAnimMoveTowardEnemy(final String animname) { + protected void Event_TestAnimMoveTowardEnemy(final idEventArg animname) { int anim; predictedPath_s path = new predictedPath_s(); idVec3 moveVec; @@ -6346,9 +6624,9 @@ protected void Event_TestAnimMoveTowardEnemy(final String animname) { return; } - anim = GetAnim(ANIMCHANNEL_LEGS, animname); + anim = GetAnim(ANIMCHANNEL_LEGS, animname.value); if (0 == anim) { - gameLocal.DWarning("missing '%s' animation on '%s' (%s)", animname, name, GetEntityDefName()); + gameLocal.DWarning("missing '%s' animation on '%s' (%s)", animname.value, name, GetEntityDefName()); idThread.ReturnInt(false); return; } @@ -6367,14 +6645,14 @@ protected void Event_TestAnimMoveTowardEnemy(final String animname) { idThread.ReturnInt(path.endEvent == 0); } - protected void Event_TestAnimMove(final String animname) { + protected void Event_TestAnimMove(final idEventArg animname) { int anim; predictedPath_s path = new predictedPath_s(); idVec3 moveVec; - anim = GetAnim(ANIMCHANNEL_LEGS, animname); + anim = GetAnim(ANIMCHANNEL_LEGS, animname.value); if (0 == anim) { - gameLocal.DWarning("missing '%s' animation on '%s' (%s)", animname, name, GetEntityDefName()); + gameLocal.DWarning("missing '%s' animation on '%s' (%s)", animname.value, name, GetEntityDefName()); idThread.ReturnInt(false); return; } @@ -6390,7 +6668,8 @@ protected void Event_TestAnimMove(final String animname) { idThread.ReturnInt(path.endEvent == 0); } - protected void Event_TestMoveToPosition(final idVec3 position) { + protected void Event_TestMoveToPosition(final idEventArg _position) { + idVec3 position = _position.value; predictedPath_s path = new predictedPath_s(); idAI.PredictPath(this, aas, physicsObj.GetOrigin(), position.oMinus(physicsObj.GetOrigin()), 1000, 1000, (move.moveType == MOVETYPE_FLY) ? SE_BLOCKED : (SE_ENTER_OBSTACLE | SE_BLOCKED | SE_ENTER_LEDGE_AREA), path); @@ -6411,13 +6690,13 @@ protected void Event_TestMeleeAttack() { idThread.ReturnInt(result); } - protected void Event_TestAnimAttack(final String animname) { + protected void Event_TestAnimAttack(final idEventArg animname) { int anim; predictedPath_s path = new predictedPath_s(); - anim = GetAnim(ANIMCHANNEL_LEGS, animname); + anim = GetAnim(ANIMCHANNEL_LEGS, animname.value); if (0 == anim) { - gameLocal.DWarning("missing '%s' animation on '%s' (%s)", animname, name, GetEntityDefName()); + gameLocal.DWarning("missing '%s' animation on '%s' (%s)", animname.value, name, GetEntityDefName()); idThread.ReturnInt(false); return; } @@ -6427,16 +6706,16 @@ protected void Event_TestAnimAttack(final String animname) { idThread.ReturnInt(path.blockingEntity != null && (path.blockingEntity.equals(enemy.GetEntity()))); } - protected void Event_Shrivel(float shrivel_time) { + protected void Event_Shrivel(idEventArg shrivel_time) { float t; if (idThread.BeginMultiFrameEvent(this, AI_Shrivel)) { - if (shrivel_time <= 0.0f) { + if (shrivel_time.value <= 0.0f) { idThread.EndMultiFrameEvent(this, AI_Shrivel); return; } - shrivel_rate = 0.001f / shrivel_time; + shrivel_rate = 0.001f / shrivel_time.value; shrivel_start = gameLocal.time; } @@ -6470,7 +6749,8 @@ protected void Event_ClearBurn() { UpdateVisuals(); } - protected void Event_SetSmokeVisibility(int num, int on) { + protected void Event_SetSmokeVisibility(idEventArg _num, idEventArg on) { + int num = _num.value; int i; int time; @@ -6479,7 +6759,7 @@ protected void Event_SetSmokeVisibility(int num, int on) { return; } - if (on != 0) { + if (on.value != 0) { time = gameLocal.time; BecomeActive(TH_UPDATEPARTICLES); } else { @@ -6524,7 +6804,8 @@ protected void Event_GetMoveType() { idThread.ReturnInt(etoi(move.moveType)); } - protected void Event_SetMoveType(int moveType) { + protected void Event_SetMoveType(idEventArg _moveType) { + int moveType = _moveType.value; if ((moveType < 0) || (moveType >= etoi(NUM_MOVETYPES))) { gameLocal.Error("Invalid movetype %d", moveType); } @@ -6604,8 +6885,8 @@ protected void Event_RestoreMove() { } } - protected void Event_AllowMovement(float flag) { - allowMove = (flag != 0.0f); + protected void Event_AllowMovement(idEventArg flag) { + allowMove = (flag.value != 0.0f); } protected void Event_JumpFrame() { @@ -6638,22 +6919,22 @@ protected void Event_DisableAFPush() { af_push_moveables = false; } - protected void Event_SetFlySpeed(float speed) { + protected void Event_SetFlySpeed(idEventArg speed) { if (move.speed == fly_speed) { - move.speed = speed; + move.speed = speed.value; } - fly_speed = speed; + fly_speed = speed.value; } - protected void Event_SetFlyOffset(int offset) { - fly_offset = offset; + protected void Event_SetFlyOffset(idEventArg offset) { + fly_offset = offset.value; } protected void Event_ClearFlyOffset() { fly_offset = spawnArgs.GetInt("fly_offset", "0"); } - protected void Event_GetClosestHiddenTarget(final String type) { + protected void Event_GetClosestHiddenTarget(final idEventArg type) { int i; idEntity ent; idEntity bestEnt; @@ -6670,7 +6951,7 @@ protected void Event_GetClosestHiddenTarget(final String type) { if (targets.Num() == 1) { ent = targets.oGet(0).GetEntity(); - if (ent != null && idStr.Cmp(ent.GetEntityDefName(), type) == 0) { + if (ent != null && idStr.Cmp(ent.GetEntityDefName(), type.value) == 0) { if (!EntityCanSeePos(enemyEnt, lastVisibleEnemyPos, ent.GetPhysics().GetOrigin())) { idThread.ReturnEntity(ent); return; @@ -6684,7 +6965,7 @@ protected void Event_GetClosestHiddenTarget(final String type) { bestTime = idMath.INFINITY; for (i = 0; i < targets.Num(); i++) { ent = targets.oGet(i).GetEntity(); - if (ent != null && idStr.Cmp(ent.GetEntityDefName(), type) == 0) { + if (ent != null && idStr.Cmp(ent.GetEntityDefName(), type.value) == 0) { final idVec3 destOrg = ent.GetPhysics().GetOrigin(); time = TravelDistance(org, destOrg); if ((time >= 0.0f) && (time < bestTime)) { @@ -6698,7 +6979,7 @@ protected void Event_GetClosestHiddenTarget(final String type) { idThread.ReturnEntity(bestEnt); } - protected void Event_GetRandomTarget(final String type) { + protected void Event_GetRandomTarget(final idEventArg type) { int i; int num; int which; @@ -6708,7 +6989,7 @@ protected void Event_GetRandomTarget(final String type) { num = 0; for (i = 0; i < targets.Num(); i++) { ent = targets.oGet(i).GetEntity(); - if (ent != null && idStr.Cmp(ent.GetEntityDefName(), type) == 0) { + if (ent != null && idStr.Cmp(ent.GetEntityDefName(), type.value) == 0) { ents[ num++] = ent; if (num >= MAX_GENTITIES) { break; @@ -6725,37 +7006,38 @@ protected void Event_GetRandomTarget(final String type) { idThread.ReturnEntity(ents[ which]); } - protected void Event_TravelDistanceToPoint(final idVec3 pos) { + protected void Event_TravelDistanceToPoint(final idEventArg pos) { float time; - time = TravelDistance(physicsObj.GetOrigin(), pos); + time = TravelDistance(physicsObj.GetOrigin(), pos.value); idThread.ReturnFloat(time); } - protected void Event_TravelDistanceToEntity(idEntity ent) { + protected void Event_TravelDistanceToEntity(idEventArg ent) { float time; - time = TravelDistance(physicsObj.GetOrigin(), ent.GetPhysics().GetOrigin()); + time = TravelDistance(physicsObj.GetOrigin(), ent.value.GetPhysics().GetOrigin()); idThread.ReturnFloat(time); } - protected void Event_TravelDistanceBetweenPoints(final idVec3 source, final idVec3 dest) { + protected void Event_TravelDistanceBetweenPoints(final idEventArg source, final idEventArg dest) { float time; - time = TravelDistance(source, dest); + time = TravelDistance(source.value, dest.value); idThread.ReturnFloat(time); } - protected void Event_TravelDistanceBetweenEntities(idEntity source, idEntity dest) { + protected void Event_TravelDistanceBetweenEntities(idEventArg source, idEventArg dest) { float time; - assert (source != null); - assert (dest != null); - time = TravelDistance(source.GetPhysics().GetOrigin(), dest.GetPhysics().GetOrigin()); + assert (source.value != null); + assert (dest.value != null); + time = TravelDistance(source.value.GetPhysics().GetOrigin(), dest.value.GetPhysics().GetOrigin()); idThread.ReturnFloat(time); } - protected void Event_LookAtEntity(idEntity ent, float duration) { + protected void Event_LookAtEntity(idEventArg _ent, idEventArg duration) { + idEntity ent = _ent.value; if (ent.equals(this)) { ent = null; } else if ((!ent.equals(focusEntity.GetEntity())) || (focusTime < gameLocal.time)) { @@ -6765,10 +7047,10 @@ protected void Event_LookAtEntity(idEntity ent, float duration) { blink_time = 0; } - focusTime = (int) (gameLocal.time + SEC2MS(duration)); + focusTime = (int) (gameLocal.time + SEC2MS(duration.value)); } - protected void Event_LookAtEnemy(float duration) { + protected void Event_LookAtEnemy(idEventArg duration) { idActor enemyEnt; enemyEnt = enemy.GetEntity(); @@ -6779,11 +7061,11 @@ protected void Event_LookAtEnemy(float duration) { blink_time = 0; } - focusTime = (int) (gameLocal.time + SEC2MS(duration)); + focusTime = (int) (gameLocal.time + SEC2MS(duration.value)); } - protected void Event_SetJointMod(int allow) { - allowJointMod = itob(allow); + protected void Event_SetJointMod(idEventArg allow) { + allowJointMod = itob(allow.value); } protected void Event_ThrowMoveable() { @@ -6818,8 +7100,8 @@ protected void Event_ThrowAF() { } } - protected void Event_SetAngles(final idAngles ang) { - current_yaw = ang.yaw; + protected void Event_SetAngles(final idEventArg ang) { + current_yaw = ang.value.yaw; viewAxis = new idAngles(0, current_yaw, 0).ToMat3(); } @@ -6845,8 +7127,8 @@ protected void Event_Kill() { PostEventMS(AI_RealKill, 0); } - protected void Event_WakeOnFlashlight(int enable) { - wakeOnFlashlight = (enable != 0); + protected void Event_WakeOnFlashlight(idEventArg enable) { + wakeOnFlashlight = (enable.value != 0); } protected void Event_LocateEnemy() { @@ -6863,12 +7145,12 @@ protected void Event_LocateEnemy() { UpdateEnemyPosition(); } - protected void Event_KickObstacles(idEntity kickEnt, float force) { + protected void Event_KickObstacles(idEventArg kickEnt, idEventArg force) { idVec3 dir; idEntity obEnt; - if (kickEnt != null) { - obEnt = kickEnt; + if (kickEnt.value != null) { + obEnt = kickEnt.value; } else { obEnt = move.obstacle.GetEntity(); } @@ -6879,14 +7161,15 @@ protected void Event_KickObstacles(idEntity kickEnt, float force) { } else { dir = viewAxis.oGet(0); } - KickObstacles(dir, force, obEnt); + KickObstacles(dir, force.value, obEnt); } protected void Event_GetObstacle() { idThread.ReturnEntity(move.obstacle.GetEntity()); } - protected void Event_PushPointIntoAAS(final idVec3 pos) { + protected void Event_PushPointIntoAAS(final idEventArg _pos) { + idVec3 pos = _pos.value; int areaNum; idVec3 newPos; @@ -6904,14 +7187,14 @@ protected void Event_GetTurnRate() { idThread.ReturnFloat(turnRate); } - protected void Event_SetTurnRate(float rate) { - turnRate = rate; + protected void Event_SetTurnRate(idEventArg rate) { + turnRate = rate.value; } - protected void Event_AnimTurn(float angles) { + protected void Event_AnimTurn(idEventArg angles) { turnVel = 0.0f; - anim_turn_angles = angles; - if (angles != 0) { + anim_turn_angles = angles.value; + if (angles.value != 0) { anim_turn_yaw = current_yaw; anim_turn_amount = idMath.Fabs(idMath.AngleNormalize180(current_yaw - ideal_yaw)); if (anim_turn_amount > anim_turn_angles) { @@ -6926,21 +7209,21 @@ protected void Event_AnimTurn(float angles) { } } - protected void Event_AllowHiddenMovement(int enable) { - allowHiddenMovement = (enable != 0); + protected void Event_AllowHiddenMovement(idEventArg enable) { + allowHiddenMovement = (enable.value != 0); } - protected void Event_TriggerParticles(final String jointName) { - TriggerParticles(jointName); + protected void Event_TriggerParticles(final idEventArg jointName) { + TriggerParticles(jointName.value); } - protected void Event_FindActorsInBounds(final idVec3 mins, final idVec3 maxs) { + protected void Event_FindActorsInBounds(final idEventArg mins, final idEventArg maxs) { idEntity ent; idEntity[] entityList = new idEntity[MAX_GENTITIES]; int numListedEntities; int i; - numListedEntities = gameLocal.clip.EntitiesTouchingBounds(new idBounds(mins, maxs), CONTENTS_BODY, entityList, MAX_GENTITIES); + numListedEntities = gameLocal.clip.EntitiesTouchingBounds(new idBounds(mins.value, maxs.value), CONTENTS_BODY, entityList, MAX_GENTITIES); for (i = 0; i < numListedEntities; i++) { ent = entityList[ i]; if (!ent.equals(this) && !ent.IsHidden() && (ent.health > 0) && ent.IsType(idActor.class)) { @@ -6952,21 +7235,22 @@ protected void Event_FindActorsInBounds(final idVec3 mins, final idVec3 maxs) { idThread.ReturnEntity(null); } - protected void Event_CanReachPosition(final idVec3 pos) { + protected void Event_CanReachPosition(final idEventArg pos) { aasPath_s path = new aasPath_s(); int toAreaNum; int areaNum; - toAreaNum = PointReachableAreaNum(pos); + toAreaNum = PointReachableAreaNum(pos.value); areaNum = PointReachableAreaNum(physicsObj.GetOrigin()); - if (0 == toAreaNum || !PathToGoal(path, areaNum, physicsObj.GetOrigin(), toAreaNum, pos)) { + if (0 == toAreaNum || !PathToGoal(path, areaNum, physicsObj.GetOrigin(), toAreaNum, pos.value)) { idThread.ReturnInt(false); } else { idThread.ReturnInt(true); } } - protected void Event_CanReachEntity(idEntity ent) { + protected void Event_CanReachEntity(idEventArg _ent) { + idEntity ent = _ent.value; aasPath_s path = new aasPath_s(); int toAreaNum; int areaNum; @@ -7043,7 +7327,8 @@ protected void Event_CanReachEnemy() { } } - protected void Event_GetReachableEntityPosition(idEntity ent) { + protected void Event_GetReachableEntityPosition(idEventArg _ent) { + idEntity ent = _ent.value; int toAreaNum; idVec3 pos = new idVec3(); @@ -7073,10 +7358,20 @@ protected void Event_GetReachableEntityPosition(idEntity ent) { public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; public static class idCombatNode extends idEntity { // CLASS_PROTOTYPE( idCombatNode ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_CombatNode_MarkUsed, (eventCallback_t0) idCombatNode::Event_MarkUsed ); + eventCallbacks.put(EV_Activate, (eventCallback_t1) idCombatNode::Event_Activate ); + } private float min_dist; private float max_dist; @@ -7241,7 +7536,7 @@ public static void DrawDebugInfo() { } } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { disabled = !disabled; } @@ -7255,6 +7550,12 @@ private void Event_MarkUsed() { public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* diff --git a/src/main/java/neo/Game/AI/AI_Vagary.java b/src/main/java/neo/Game/AI/AI_Vagary.java index 7f2e4a3b..6c0867fd 100644 --- a/src/main/java/neo/Game/AI/AI_Vagary.java +++ b/src/main/java/neo/Game/AI/AI_Vagary.java @@ -2,18 +2,27 @@ import neo.Game.AI.AI.idAI; import neo.Game.Entity.idEntity; +import neo.Game.GameSys.Class; +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t2; +import neo.Game.GameSys.Class.eventCallback_t5; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Event.idEventDef; -import static neo.Game.GameSys.SysCvar.ai_debugTrajectory; -import static neo.Game.Game_local.MAX_GENTITIES; -import static neo.Game.Game_local.gameLocal; import neo.Game.Moveable.idMoveable; import neo.Game.Physics.Physics.idPhysics; import neo.Game.Script.Script_Thread.idThread; -import static neo.TempDump.NOT; import neo.idlib.BV.Bounds.idBounds; -import static neo.idlib.Lib.MAX_WORLD_SIZE; import neo.idlib.math.Vector.idVec3; +import java.util.HashMap; +import java.util.Map; + +import static neo.Game.GameSys.SysCvar.ai_debugTrajectory; +import static neo.Game.Game_local.MAX_GENTITIES; +import static neo.Game.Game_local.gameLocal; +import static neo.TempDump.NOT; +import static neo.idlib.Lib.MAX_WORLD_SIZE; + /** * */ @@ -26,21 +35,27 @@ public class AI_Vagary { ***********************************************************************/ - static final idEventDef AI_Vagary_ChooseObjectToThrow = new idEventDef("vagary_ChooseObjectToThrow", "vvfff", 'e'); - static final idEventDef AI_Vagary_ThrowObjectAtEnemy = new idEventDef("vagary_ThrowObjectAtEnemy", "ef"); + private static final idEventDef AI_Vagary_ChooseObjectToThrow = new idEventDef("vagary_ChooseObjectToThrow", "vvfff", 'e'); + private static final idEventDef AI_Vagary_ThrowObjectAtEnemy = new idEventDef("vagary_ThrowObjectAtEnemy", "ef"); // public static class idAI_Vagary extends idAI { //CLASS_PROTOTYPE( idAI_Vagary ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(AI_Vagary_ChooseObjectToThrow, (eventCallback_t5) idAI_Vagary::Event_ChooseObjectToThrow); + eventCallbacks.put(AI_Vagary_ThrowObjectAtEnemy, (eventCallback_t2) idAI_Vagary::Event_ThrowObjectAtEnemy); + } - private void Event_ChooseObjectToThrow(final idVec3 mins, final idVec3 maxs, float speed, float minDist, float offset) { + private void Event_ChooseObjectToThrow(final idEventArg mins, final idEventArg maxs, + idEventArg speed, idEventArg minDist, idEventArg offset) { idEntity ent; idEntity[] entityList = new idEntity[MAX_GENTITIES]; int numListedEntities; int i, index; float dist; idVec3 vel = new idVec3(); - idVec3 offsetVec = new idVec3(0, 0, offset); + idVec3 offsetVec = new idVec3(0, 0, offset.value); idEntity enemyEnt = enemy.GetEntity(); if (null == enemyEnt) { @@ -49,7 +64,7 @@ private void Event_ChooseObjectToThrow(final idVec3 mins, final idVec3 maxs, flo idVec3 enemyEyePos = lastVisibleEnemyPos.oPlus(lastVisibleEnemyEyeOffset); final idBounds myBounds = physicsObj.GetAbsBounds(); - idBounds checkBounds = new idBounds(mins, maxs); + idBounds checkBounds = new idBounds(mins.value, maxs.value); checkBounds.TranslateSelf(physicsObj.GetOrigin()); numListedEntities = gameLocal.clip.EntitiesTouchingBounds(checkBounds, -1, entityList, MAX_GENTITIES); @@ -71,7 +86,7 @@ private void Event_ChooseObjectToThrow(final idVec3 mins, final idVec3 maxs, flo idPhysics entPhys = ent.GetPhysics(); final idVec3 entOrg = entPhys.GetOrigin(); dist = (entOrg.oMinus(enemyEyePos)).LengthFast(); - if (dist < minDist) { + if (dist < minDist.value) { continue; } @@ -81,7 +96,7 @@ private void Event_ChooseObjectToThrow(final idVec3 mins, final idVec3 maxs, flo continue; } - if (PredictTrajectory(entPhys.GetOrigin().oPlus(offsetVec), enemyEyePos, speed, entPhys.GetGravity(), + if (PredictTrajectory(entPhys.GetOrigin().oPlus(offsetVec), enemyEyePos, speed.value, entPhys.GetGravity(), entPhys.GetClipModel(), entPhys.GetClipMask(), MAX_WORLD_SIZE, null, enemyEnt, ai_debugTrajectory.GetBool() ? 4000 : 0, vel)) { idThread.ReturnEntity(ent); return; @@ -91,7 +106,9 @@ private void Event_ChooseObjectToThrow(final idVec3 mins, final idVec3 maxs, flo idThread.ReturnEntity(null); } - private void Event_ThrowObjectAtEnemy(idEntity ent, float speed) { + private void Event_ThrowObjectAtEnemy(idEventArg _ent, idEventArg _speed) { + idEntity ent = _ent.value; + float speed = _speed.value; idVec3 vel = new idVec3(); idEntity enemyEnt; idPhysics entPhys; @@ -113,5 +130,11 @@ private void Event_ThrowObjectAtEnemy(idEntity ent, float speed) { ment.EnableDamage(true, 2.5f); } } + + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/Actor.java b/src/main/java/neo/Game/Actor.java index 755bfc4d..e1e56209 100644 --- a/src/main/java/neo/Game/Actor.java +++ b/src/main/java/neo/Game/Actor.java @@ -19,9 +19,19 @@ import static neo.Game.Animation.Anim.jointModTransform_t.JOINTMOD_WORLD_OVERRIDE; import neo.Game.Animation.Anim_Blend.idAnimBlend; import neo.Game.Animation.Anim_Blend.idAnimator; + +import static neo.Game.Entity.EV_StopSound; import static neo.Game.Entity.TH_PHYSICS; import neo.Game.Entity.idEntity; import static neo.Game.GameSys.Class.EV_Remove; + +import neo.Game.GameSys.Class; +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.eventCallback_t2; +import neo.Game.GameSys.Class.eventCallback_t3; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Class.idEventFunc; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; @@ -70,6 +80,9 @@ import static neo.idlib.math.Vector.getVec3_origin; import neo.idlib.math.Vector.idVec3; +import java.util.HashMap; +import java.util.Map; + /** * */ @@ -351,7 +364,52 @@ public static class idActor extends idAFEntity_Gibbable { // // public static idClass CreateInstance(); // public idTypeInfo GetType(); -// public static idEventFunc[] eventCallbacks; + private static Map eventCallbacks = new HashMap<>(); + + static { + eventCallbacks.put(AI_EnableEyeFocus, (eventCallback_t0) idActor::Event_EnableEyeFocus); + eventCallbacks.put(AI_DisableEyeFocus, (eventCallback_t0) idActor::Event_DisableEyeFocus); + eventCallbacks.put(EV_Footstep, (eventCallback_t0) idActor::Event_Footstep); + eventCallbacks.put(EV_FootstepLeft, (eventCallback_t0) idActor::Event_Footstep); + eventCallbacks.put(EV_FootstepRight, (eventCallback_t0) idActor::Event_Footstep); + eventCallbacks.put(EV_EnableWalkIK, (eventCallback_t0) idActor::Event_EnableWalkIK); + eventCallbacks.put(EV_DisableWalkIK, (eventCallback_t0) idActor::Event_DisableWalkIK); + eventCallbacks.put(EV_EnableLegIK, (eventCallback_t1) idActor::Event_EnableLegIK); + eventCallbacks.put(EV_DisableLegIK, (eventCallback_t1) idActor::Event_DisableLegIK); + eventCallbacks.put(AI_PreventPain, (eventCallback_t1) idActor::Event_PreventPain); + eventCallbacks.put(AI_DisablePain, (eventCallback_t0) idActor::Event_DisablePain); + eventCallbacks.put(AI_EnablePain, (eventCallback_t0) idActor::Event_EnablePain); + eventCallbacks.put(AI_GetPainAnim, (eventCallback_t0) idActor::Event_GetPainAnim); + eventCallbacks.put(AI_SetAnimPrefix, (eventCallback_t1) idActor::Event_SetAnimPrefix); + eventCallbacks.put(AI_StopAnim, (eventCallback_t2) idActor::Event_StopAnim); + eventCallbacks.put(AI_PlayAnim, (eventCallback_t2) idActor::Event_PlayAnim); + eventCallbacks.put(AI_PlayCycle, (eventCallback_t2) idActor::Event_PlayCycle); + eventCallbacks.put(AI_IdleAnim, (eventCallback_t2) idActor::Event_IdleAnim); + eventCallbacks.put(AI_SetSyncedAnimWeight, (eventCallback_t3) idActor::Event_SetSyncedAnimWeight); + eventCallbacks.put(AI_SetBlendFrames, (eventCallback_t2) idActor::Event_SetBlendFrames); + eventCallbacks.put(AI_GetBlendFrames, (eventCallback_t1) idActor::Event_GetBlendFrames); + eventCallbacks.put(AI_AnimState, (eventCallback_t3) idActor::Event_AnimState); + eventCallbacks.put(AI_GetAnimState, (eventCallback_t1) idActor::Event_GetAnimState); + eventCallbacks.put(AI_InAnimState, (eventCallback_t2) idActor::Event_InAnimState); + eventCallbacks.put(AI_FinishAction, (eventCallback_t1) idActor::Event_FinishAction); + eventCallbacks.put(AI_AnimDone, (eventCallback_t2) idActor::Event_AnimDone); + eventCallbacks.put(AI_OverrideAnim, (eventCallback_t1) idActor::Event_OverrideAnim); + eventCallbacks.put(AI_EnableAnim, (eventCallback_t2) idActor::Event_EnableAnim); + eventCallbacks.put(AI_HasAnim, (eventCallback_t2) idActor::Event_HasAnim); + eventCallbacks.put(AI_CheckAnim, (eventCallback_t2) idActor::Event_CheckAnim); + eventCallbacks.put(AI_ChooseAnim, (eventCallback_t2) idActor::Event_ChooseAnim); + eventCallbacks.put(AI_AnimLength, (eventCallback_t2) idActor::Event_AnimLength); + eventCallbacks.put(AI_AnimDistance, (eventCallback_t2) idActor::Event_AnimDistance); + eventCallbacks.put(AI_HasEnemies, (eventCallback_t0) idActor::Event_HasEnemies); + eventCallbacks.put(AI_NextEnemy, (eventCallback_t1) idActor::Event_NextEnemy); + eventCallbacks.put(AI_ClosestEnemyToPoint, (eventCallback_t1) idActor::Event_ClosestEnemyToPoint); + eventCallbacks.put(EV_StopSound, (eventCallback_t2) idActor::Event_StopSound); + eventCallbacks.put(AI_SetNextState, (eventCallback_t1) idActor::Event_SetNextState); + eventCallbacks.put(AI_SetState, (eventCallback_t1) idActor::Event_SetState); + eventCallbacks.put(AI_GetState, (eventCallback_t0) idActor::Event_GetState); + eventCallbacks.put(AI_GetHead, (eventCallback_t0) idActor::Event_GetHead); + } + // public int team; public int rank; // monsters don't fight back if the attacker's rank is higher @@ -2180,21 +2238,21 @@ private void Event_DisableWalkIK() { walkIK.DisableAll(); } - private void Event_EnableLegIK(int num) { - walkIK.EnableLeg(num); + private void Event_EnableLegIK(idEventArg num) { + walkIK.EnableLeg(num.value); } - private void Event_DisableLegIK(int num) { - walkIK.DisableLeg(num); + private void Event_DisableLegIK(idEventArg num) { + walkIK.DisableLeg(num.value); } - private void Event_SetAnimPrefix(final String prefix) { - animPrefix.oSet(prefix); + private void Event_SetAnimPrefix(final idEventArg prefix) { + animPrefix.oSet(prefix.value); } // private void Event_LookAtEntity(idEntity ent, float duration); - private void Event_PreventPain(float duration) { - painTime = (int) (gameLocal.time + SEC2MS(duration)); + private void Event_PreventPain(idEventArg duration) { + painTime = (int) (gameLocal.time + SEC2MS(duration.value)); } private void Event_DisablePain() { @@ -2213,18 +2271,18 @@ private void Event_GetPainAnim() { } } - private void Event_StopAnim(int channel, int frames) { - switch (channel) { + private void Event_StopAnim(idEventArg channel, idEventArg frames) { + switch (channel.value) { case ANIMCHANNEL_HEAD: - headAnim.StopAnim(frames); + headAnim.StopAnim(frames.value); break; case ANIMCHANNEL_TORSO: - torsoAnim.StopAnim(frames); + torsoAnim.StopAnim(frames.value); break; case ANIMCHANNEL_LEGS: - legsAnim.StopAnim(frames); + legsAnim.StopAnim(frames.value); break; default: @@ -2233,7 +2291,9 @@ private void Event_StopAnim(int channel, int frames) { } } - private void Event_PlayAnim(int channel, final String animName) { + private void Event_PlayAnim(idEventArg _channel, final idEventArg _animName) { + final int channel = _channel.value; + final String animName = _animName.value; animFlags_t flags; idEntity headEnt; int anim; @@ -2308,7 +2368,9 @@ private void Event_PlayAnim(int channel, final String animName) { idThread.ReturnInt(1); } - private void Event_PlayCycle(int channel, final String animName) { + private void Event_PlayCycle(idEventArg _channel, final idEventArg _animName) { + final int channel = _channel.value; + final String animName = _animName.value; animFlags_t flags; int anim; @@ -2377,7 +2439,9 @@ private void Event_PlayCycle(int channel, final String animName) { idThread.ReturnInt(true); } - private void Event_IdleAnim(int channel, final String animName) { + private void Event_IdleAnim(idEventArg _channel, final idEventArg _animName) { + final int channel = _channel.value; + final String animName = _animName.value; int anim; anim = GetAnim(channel, animName); @@ -2479,7 +2543,10 @@ private void Event_IdleAnim(int channel, final String animName) { idThread.ReturnInt(true); } - private void Event_SetSyncedAnimWeight(int channel, int anim, float weight) { + private void Event_SetSyncedAnimWeight(idEventArg _channel, final idEventArg _anim, final idEventArg _weight) { + final int channel = _channel.value; + final int anim = _anim.value; + final float weight = _weight.value; idEntity headEnt; headEnt = head.GetEntity(); @@ -2523,8 +2590,8 @@ private void Event_SetSyncedAnimWeight(int channel, int anim, float weight) { } } - private void Event_OverrideAnim(int channel) { - switch (channel) { + private void Event_OverrideAnim(idEventArg channel) { + switch (channel.value) { case ANIMCHANNEL_HEAD: headAnim.Disable(); if (!torsoAnim.IsIdle()) { @@ -2553,8 +2620,9 @@ private void Event_OverrideAnim(int channel) { } } - private void Event_EnableAnim(int channel, int blendFrames) { - switch (channel) { + private void Event_EnableAnim(idEventArg channel, idEventArg _blendFrames) { + final int blendFrames = _blendFrames.value; + switch (channel.value) { case ANIMCHANNEL_HEAD: headAnim.Enable(blendFrames); break; @@ -2573,7 +2641,9 @@ private void Event_EnableAnim(int channel, int blendFrames) { } } - private void Event_SetBlendFrames(int channel, int blendFrames) { + private void Event_SetBlendFrames(idEventArg _channel, final idEventArg _blendFrames) { + final int channel = _channel.value; + final int blendFrames = _blendFrames.value; switch (channel) { case ANIMCHANNEL_HEAD: headAnim.animBlendFrames = blendFrames; @@ -2596,7 +2666,8 @@ private void Event_SetBlendFrames(int channel, int blendFrames) { } } - private void Event_GetBlendFrames(int channel) { + private void Event_GetBlendFrames(idEventArg _channel) { + final int channel = _channel.value; switch (channel) { case ANIMCHANNEL_HEAD: idThread.ReturnInt(headAnim.animBlendFrames); @@ -2616,34 +2687,35 @@ private void Event_GetBlendFrames(int channel) { } } - private void Event_AnimState(int channel, final String statename, int blendFrames) { - SetAnimState(channel, statename, blendFrames); + private void Event_AnimState(idEventArg channel, final idEventArg statename, idEventArg blendFrames) { + SetAnimState(channel.value, statename.value, blendFrames.value); } - private void Event_GetAnimState(int channel) { + private void Event_GetAnimState(idEventArg channel) { final idStr state; - state = GetAnimState(channel); + state = GetAnimState(channel.value); idThread.ReturnString(state); } - private void Event_InAnimState(int channel, final String statename) { + private void Event_InAnimState(idEventArg channel, final idEventArg statename) { boolean instate; - instate = InAnimState(channel, statename); + instate = InAnimState(channel.value, statename.value); idThread.ReturnInt(instate); } - private void Event_FinishAction(final String actionname) { - if (waitState.equals(actionname)) { + private void Event_FinishAction(final idEventArg actionname) { + if (waitState.equals(actionname.value)) { SetWaitState(""); } } - private void Event_AnimDone(int channel, int blendFrames) { + private void Event_AnimDone(idEventArg channel, idEventArg _blendFrames) { + int blendFrames = _blendFrames.value; boolean result; - switch (channel) { + switch (channel.value) { case ANIMCHANNEL_HEAD: result = headAnim.AnimDone(blendFrames); idThread.ReturnInt(result); @@ -2664,16 +2736,16 @@ private void Event_AnimDone(int channel, int blendFrames) { } } - private void Event_HasAnim(int channel, final String animName) { - if (GetAnim(channel, animName) != 0) { + private void Event_HasAnim(idEventArg channel, final idEventArg animName) { + if (GetAnim(channel.value, animName.value) != 0) { idThread.ReturnFloat(1.0f); } else { idThread.ReturnFloat(0); } } - private void Event_CheckAnim(int channel, final String animname) { - if (0 == GetAnim(channel, animname)) { + private void Event_CheckAnim(idEventArg channel, final idEventArg animname) { + if (0 == GetAnim(channel.value, animname.value)) { if (animPrefix.Length() != 0) { gameLocal.Error("Can't find anim '%s_%s' for '%s'", animPrefix, animname, name); } else { @@ -2682,12 +2754,12 @@ private void Event_CheckAnim(int channel, final String animname) { } } - private void Event_ChooseAnim(int channel, final String animname) { + private void Event_ChooseAnim(idEventArg channel, final idEventArg animname) { int anim; - anim = GetAnim(channel, animname); + anim = GetAnim(channel.value, animname.value); if (anim != 0) { - if (channel == ANIMCHANNEL_HEAD) { + if (channel.value == ANIMCHANNEL_HEAD) { if (head.GetEntity() != null) { idThread.ReturnString(head.GetEntity().GetAnimator().AnimFullName(anim)); return; @@ -2701,12 +2773,12 @@ private void Event_ChooseAnim(int channel, final String animname) { idThread.ReturnString(""); } - private void Event_AnimLength(int channel, final String animname) { + private void Event_AnimLength(idEventArg channel, final idEventArg animname) { int anim; - anim = GetAnim(channel, animname); + anim = GetAnim(channel.value, animname.value); if (anim != 0) { - if (channel == ANIMCHANNEL_HEAD) { + if (channel.value == ANIMCHANNEL_HEAD) { if (head.GetEntity() != null) { idThread.ReturnFloat(MS2SEC(head.GetEntity().GetAnimator().AnimLength(anim))); return; @@ -2720,12 +2792,12 @@ private void Event_AnimLength(int channel, final String animname) { idThread.ReturnFloat(0); } - private void Event_AnimDistance(int channel, final String animname) { + private void Event_AnimDistance(idEventArg channel, final idEventArg animname) { int anim; - anim = GetAnim(channel, animname); + anim = GetAnim(channel.value, animname.value); if (anim != 0) { - if (channel == ANIMCHANNEL_HEAD) { + if (channel.value == ANIMCHANNEL_HEAD) { if (head.GetEntity() != null) { idThread.ReturnFloat(head.GetEntity().GetAnimator().TotalMovementDelta(anim).Length()); return; @@ -2746,7 +2818,8 @@ private void Event_HasEnemies() { idThread.ReturnInt(hasEnemy); } - private void Event_NextEnemy(idEntity ent) { + private void Event_NextEnemy(idEventArg _ent) { + idEntity ent = _ent.value; idActor actor; if (null == ent || (ent.equals(this))) { @@ -2772,30 +2845,30 @@ private void Event_NextEnemy(idEntity ent) { idThread.ReturnEntity(null); } - private void Event_ClosestEnemyToPoint(final idVec3 pos) { - idActor bestEnt = ClosestEnemyToPoint(pos); + private void Event_ClosestEnemyToPoint(final idEventArg pos) { + idActor bestEnt = ClosestEnemyToPoint(pos.value); idThread.ReturnEntity(bestEnt); } - private void Event_StopSound(int channel, int netSync) { - if (channel == etoi(SND_CHANNEL_VOICE)) { + private void Event_StopSound(idEventArg channel, idEventArg netSync) { + if (channel.value == etoi(SND_CHANNEL_VOICE)) { idEntity headEnt = head.GetEntity(); if (headEnt != null) { - headEnt.StopSound(channel, (netSync != 0)); + headEnt.StopSound(channel.value, (netSync.value != 0)); } } - StopSound(channel, (netSync != 0)); + StopSound(channel.value, (netSync.value != 0)); } - private void Event_SetNextState(final String name) { - idealState = GetScriptFunction(name); + private void Event_SetNextState(final idEventArg name) { + idealState = GetScriptFunction(name.value); if (idealState == state) { state = null; } } - private void Event_SetState(final String name) { - idealState = GetScriptFunction(name); + private void Event_SetState(final idEventArg name) { + idealState = GetScriptFunction(name.value); if (idealState == state) { state = null; } @@ -2813,5 +2886,10 @@ private void Event_GetState() { private void Event_GetHead() { idThread.ReturnEntity(head.GetEntity()); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/Animation/Anim_Testmodel.java b/src/main/java/neo/Game/Animation/Anim_Testmodel.java index 11a4088a..d106e61b 100644 --- a/src/main/java/neo/Game/Animation/Anim_Testmodel.java +++ b/src/main/java/neo/Game/Animation/Anim_Testmodel.java @@ -1,6 +1,9 @@ package neo.Game.Animation; import neo.Game.Actor.copyJoints_t; + +import static neo.Game.Actor.EV_FootstepLeft; +import static neo.Game.Actor.EV_FootstepRight; import static neo.Game.Animation.Anim.ANIMCHANNEL_ALL; import static neo.Game.Animation.Anim.FRAME2MS; import static neo.Game.Animation.Anim.jointModTransform_t.JOINTMOD_LOCAL_OVERRIDE; @@ -14,6 +17,11 @@ import neo.Game.Entity.idEntity; import neo.Game.GameSys.Class; import static neo.Game.GameSys.Class.EV_Remove; + +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Event; +import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; import static neo.Game.GameSys.SysCvar.g_showTestModelFrame; @@ -59,6 +67,9 @@ import neo.idlib.math.Matrix.idMat3; import neo.idlib.math.Vector.idVec3; +import java.util.HashMap; +import java.util.Map; + /* ============================================================================= @@ -92,6 +103,12 @@ public class Anim_Testmodel { */ public static class idTestModel extends idAnimatedEntity { // CLASS_PROTOTYPE( idTestModel ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_FootstepLeft, (eventCallback_t0) idTestModel::Event_Footstep); + eventCallbacks.put(EV_FootstepRight, (eventCallback_t0) idTestModel::Event_Footstep); + } + private idEntityPtr head; private idAnimator headAnimator; @@ -1073,5 +1090,10 @@ private void Event_Footstep() { public void oSet(Class.idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/BrittleFracture.java b/src/main/java/neo/Game/BrittleFracture.java index 29df8935..211cb7da 100644 --- a/src/main/java/neo/Game/BrittleFracture.java +++ b/src/main/java/neo/Game/BrittleFracture.java @@ -3,14 +3,29 @@ import static java.lang.Math.cos; import static java.lang.Math.sin; import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; + import static neo.CM.CollisionModel.CM_CLIP_EPSILON; import neo.CM.CollisionModel.trace_s; + +import static neo.Game.Entity.EV_Activate; +import static neo.Game.Entity.EV_Touch; import static neo.Game.Entity.TH_PHYSICS; import static neo.Game.Entity.TH_THINK; import static neo.Game.Entity.TH_UPDATEVISUALS; import neo.Game.Entity.idEntity; import neo.Game.FX.idEntityFx; import static neo.Game.GameSys.Class.EV_Remove; + +import neo.Game.GameSys.Class; +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.eventCallback_t2; +import neo.Game.GameSys.Class.idEventArg; +import neo.Game.GameSys.Event; +import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; import static neo.Game.Game_local.MASK_SOLID; @@ -97,6 +112,12 @@ public static class shard_s { public static class idBrittleFracture extends idEntity { // public CLASS_PROTOTYPE( idBrittleFracture ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idBrittleFracture::Event_Activate); + eventCallbacks.put(EV_Touch, (eventCallback_t2) idBrittleFracture::Event_Touch); + } + // // enum { @@ -1248,14 +1269,16 @@ private void FindNeighbours() { } } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { disableFracture = false; if (health <= 0) { Break(); } } - private void Event_Touch(idEntity other, trace_s trace) { + private void Event_Touch(idEventArg _other, idEventArg _trace) { + idEntity other = _other.value; + trace_s trace = _trace.value; idVec3 point, impulse; if (!IsBroken()) { @@ -1271,5 +1294,10 @@ private void Event_Touch(idEntity other, trace_s trace) { Shatter(point, impulse, gameLocal.time); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/Camera.java b/src/main/java/neo/Game/Camera.java index 7e642989..af3cd47b 100644 --- a/src/main/java/neo/Game/Camera.java +++ b/src/main/java/neo/Game/Camera.java @@ -1,8 +1,13 @@ package neo.Game; +import static neo.Game.Entity.EV_Activate; import static neo.Game.Entity.TH_THINK; import neo.Game.Entity.idEntity; import neo.Game.GameSys.Class; +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -11,6 +16,8 @@ import static neo.Game.Game_local.gameLocal; import neo.Game.Game_local.idEntityPtr; import neo.Game.Script.Script_Thread.idThread; + +import static neo.Game.Script.Script_Thread.EV_Thread_SetCallback; import static neo.Renderer.Model.MD5_CAMERA_EXT; import static neo.Renderer.Model.MD5_VERSION; import static neo.Renderer.Model.MD5_VERSION_STRING; @@ -29,6 +36,9 @@ import neo.idlib.math.Quat.idQuat; import neo.idlib.math.Vector.idVec3; +import java.util.HashMap; +import java.util.Map; + /** * */ @@ -71,6 +81,11 @@ public void Stop() { */ public static class idCameraView extends idCamera { // public CLASS_PROTOTYPE( idCameraView ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idCameraView::Event_Activate); + eventCallbacks.put(EV_Camera_SetAttachments, (eventCallback_t0) idCameraView::Event_SetAttachments); + } protected float fov; protected idEntity attachedTo; @@ -162,7 +177,7 @@ public void Stop() { ActivateTargets(gameLocal.GetLocalPlayer()); } - protected void Event_Activate(idEntity activator) { + protected void Event_Activate(idEventArg activator) { if (spawnArgs.GetBool("trigger")) { if (gameLocal.GetCamera() != this) { if (g_debugCinematic.GetBool()) { @@ -203,6 +218,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -226,6 +246,14 @@ public cameraFrame_t() { public static class idCameraAnim extends idCamera { // public CLASS_PROTOTYPE( idCameraAnim ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Thread_SetCallback, (eventCallback_t0) idCameraAnim::Event_SetCallback); + eventCallbacks.put(EV_Camera_Stop, (eventCallback_t0) idCameraAnim::Event_Stop); + eventCallbacks.put(EV_Camera_Start, (eventCallback_t0) idCameraAnim::Event_Start); + eventCallbacks.put(EV_Activate, (eventCallback_t1) idCameraAnim::Event_Activate); + } + private int threadNum; private idVec3 offset; @@ -652,8 +680,8 @@ private void Event_SetCallback() { } } - private void Event_Activate(idEntity _activator) { - activator.oSet(_activator); + private void Event_Activate(idEventArg _activator) { + activator.oSet(_activator.value); if ((thinkFlags & TH_THINK) != 0) { Stop(); } else { @@ -670,5 +698,10 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/Entity.java b/src/main/java/neo/Game/Entity.java index 8868a498..91a68920 100644 --- a/src/main/java/neo/Game/Entity.java +++ b/src/main/java/neo/Game/Entity.java @@ -65,6 +65,9 @@ import neo.Game.Script.Script_Program.function_t; import neo.Game.Script.Script_Program.idScriptObject; import neo.Game.Script.Script_Thread.idThread; + +import static neo.Game.Script.Script_Thread.EV_Thread_Wait; +import static neo.Game.Script.Script_Thread.EV_Thread_WaitFrame; import static neo.Renderer.Material.CONTENTS_TRIGGER; import static neo.Renderer.Material.MAX_ENTITY_SHADER_PARMS; import neo.Renderer.Material.idMaterial; @@ -335,11 +338,11 @@ public static class idEntity extends neo.Game.GameSys.Class.idClass implements n eventCallbacks.put(EV_DistanceTo, (eventCallback_t1) idEntity::Event_DistanceTo); eventCallbacks.put(EV_DistanceToPoint, (eventCallback_t1) idEntity::Event_DistanceToPoint); eventCallbacks.put(EV_StartFx, (eventCallback_t1) idEntity::Event_StartFx); -// eventCallbacks.put(EV_Thread_WaitFrame, (eventCallback_t0) idEntity::Event_WaitFrame); -// eventCallbacks.put(EV_Thread_Wait, (eventCallback_t0) idEntity::Event_Wait); -// eventCallbacks.put(EV_HasFunction, (eventCallback_t0) idEntity::Event_HasFunction); -// eventCallbacks.put(EV_CallFunction, (eventCallback_t0) idEntity::Event_CallFunction); -// eventCallbacks.put(EV_SetNeverDormant, (eventCallback_t0) idEntity::Event_SetNeverDormant); + eventCallbacks.put(EV_Thread_WaitFrame, (eventCallback_t0) idEntity::Event_WaitFrame); + eventCallbacks.put(EV_Thread_Wait, (eventCallback_t1) idEntity::Event_Wait); + eventCallbacks.put(EV_HasFunction, (eventCallback_t1) idEntity::Event_HasFunction); + eventCallbacks.put(EV_CallFunction, (eventCallback_t1) idEntity::Event_CallFunction); + eventCallbacks.put(EV_SetNeverDormant, (eventCallback_t1) idEntity::Event_SetNeverDormant); } public static final int MAX_PVS_AREAS = 4; @@ -4146,7 +4149,7 @@ private static void Event_StartFx(idEntity e, final idEventArg fx) { idEntityFx.StartFx(fx.value, null, null, e, true); } - private static void Event_WaitFrame() { + private void Event_WaitFrame() { idThread thread; thread = idThread.CurrentThread(); @@ -4155,20 +4158,20 @@ private static void Event_WaitFrame() { } } - private static void Event_Wait(float time) { + private void Event_Wait(idEventArg time) { idThread thread = idThread.CurrentThread(); if (null == thread) { gameLocal.Error("Event 'wait' called from outside thread"); } - thread.WaitSec(time); + thread.WaitSec(time.value); } - private static void Event_HasFunction(idEntity e, final String name) { + private void Event_HasFunction(final idEventArg name) { function_t func; - func = e.scriptObject.GetFunction(name); + func = scriptObject.GetFunction(name.value); if (func != null) { idThread.ReturnInt(true); } else { @@ -4176,7 +4179,8 @@ private static void Event_HasFunction(idEntity e, final String name) { } } - private static void Event_CallFunction(idEntity e, final String funcName) { + private void Event_CallFunction(final idEventArg _funcName) { + final String funcName = _funcName.value; function_t func; idThread thread; @@ -4185,25 +4189,25 @@ private static void Event_CallFunction(idEntity e, final String funcName) { gameLocal.Error("Event 'callFunction' called from outside thread"); } - func = e.scriptObject.GetFunction(funcName); + func = scriptObject.GetFunction(funcName); if (NOT(func)) { - gameLocal.Error("Unknown function '%s' in '%s'", funcName, e.scriptObject.GetTypeName()); + gameLocal.Error("Unknown function '%s' in '%s'", funcName, scriptObject.GetTypeName()); } if (func.type.NumParameters() != 1) { gameLocal.Error("Function '%s' has the wrong number of parameters for 'callFunction'", funcName); } - if (!e.scriptObject.GetTypeDef().Inherits(func.type.GetParmType(0))) { + if (!scriptObject.GetTypeDef().Inherits(func.type.GetParmType(0))) { gameLocal.Error("Function '%s' is the wrong type for 'callFunction'", funcName); } // function args will be invalid after this call - thread.CallFunction(e, func, false); + thread.CallFunction(this, func, false); } - private static void Event_SetNeverDormant(idEntity e, int enable) { - e.fl.neverDormant = (enable != 0); - e.dormantStart = 0; + private void Event_SetNeverDormant(idEventArg enable) { + fl.neverDormant = (enable.value != 0); + dormantStart = 0; } public static void delete(final idEntity entity){ diff --git a/src/main/java/neo/Game/FX.java b/src/main/java/neo/Game/FX.java index b4b9b462..ebed6110 100644 --- a/src/main/java/neo/Game/FX.java +++ b/src/main/java/neo/Game/FX.java @@ -6,6 +6,12 @@ import neo.Game.FX.idEntityFx; import neo.Game.FX.idFXLocalAction; import static neo.Game.GameSys.Class.EV_Remove; + +import neo.Game.GameSys.Class; +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -44,6 +50,9 @@ import static neo.idlib.math.Vector.getVec3_origin; import neo.idlib.math.Vector.idVec3; +import java.util.HashMap; +import java.util.Map; + /** * */ @@ -82,6 +91,13 @@ public static class idFXLocalAction { public static class idEntityFx extends idEntity { + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idEntityFx::Event_Trigger); + eventCallbacks.put(EV_Fx_KillFx, (eventCallback_t0) idEntityFx::Event_ClearFx); + } + + protected int started; protected int nextTriggerTime; protected idDeclFX fxEffect; // GetFX() should be called before using fxEffect as a pointer @@ -608,7 +624,7 @@ public static idEntityFx StartFx(final idStr fx, final idVec3 useOrigin, final i return StartFx(fx.toString(), useOrigin, useAxis, ent, bind); } - protected void Event_Trigger(idEntity activator) { + protected void Event_Trigger(idEventArg activator) { if (g_skipFX.GetBool()) { return; @@ -635,7 +651,7 @@ protected void Event_Trigger(idEntity activator) { // prevent multiple triggers on same frame nextTriggerTime = gameLocal.time + 1; } - PostEventSec(EV_Fx_Action, fxActionDelay, activator); + PostEventSec(EV_Fx_Action, fxActionDelay, activator.value); } /* @@ -715,6 +731,11 @@ protected void ApplyFade(final idFXSingleAction fxaction, idFXLocalAction lactio } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -725,15 +746,25 @@ protected void ApplyFade(final idFXSingleAction fxaction, idFXLocalAction lactio =============================================================================== */ public static class idTeleporter extends idEntityFx { - // public CLASS_PROTOTYPE( idTeleporter ); + + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTeleporter::Event_DoAction); + } + // teleporters to this location - private void Event_DoAction(idEntity activator) { + private void Event_DoAction(idEventArg activator) { float angle; angle = spawnArgs.GetFloat("angle"); idAngles a = new idAngles(0, spawnArgs.GetFloat("angle"), 0); - activator.Teleport(GetPhysics().GetOrigin(), a, null); + activator.value.Teleport(GetPhysics().GetOrigin(), a, null); + } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); } }; } diff --git a/src/main/java/neo/Game/GameSys/Class.java b/src/main/java/neo/Game/GameSys/Class.java index fb51a1ab..d4a0a06a 100644 --- a/src/main/java/neo/Game/GameSys/Class.java +++ b/src/main/java/neo/Game/GameSys/Class.java @@ -326,7 +326,7 @@ public void Restore(idRestoreGame savefile) { } public boolean RespondsTo(final idEventDef ev) { - return false;//HACKME::7 + return getEventCallBack(ev) != null;//HACKME::7 // throw new TODO_Exception(); // final idTypeInfo c; // diff --git a/src/main/java/neo/Game/GameSys/Event.java b/src/main/java/neo/Game/GameSys/Event.java index 6ace3bf2..f215bd8c 100644 --- a/src/main/java/neo/Game/GameSys/Event.java +++ b/src/main/java/neo/Game/GameSys/Event.java @@ -424,24 +424,23 @@ public static idEvent Alloc(final idEventDef evdef, int numargs, idEventArg... a public static void CopyArgs(final idEventDef evdef, int numargs, idEventArg[] args, idEventArg[] data/*[ D_EVENT_MAXARGS ]*/) { int i; - String format; + char[] format; - format = evdef.GetArgFormat(); + format = evdef.GetArgFormat().toCharArray(); if (numargs != evdef.GetNumArgs()) { gameLocal.Error("idEvent::CopyArgs : Wrong number of args for '%s' event.", evdef.GetName()); } for (i = 0; i < numargs; i++) { - for (idEventArg arg : args) { - if (format.charAt(i) != arg.type) { - // when NULL is passed in for an entity, it gets cast as an integer 0, so don't give an error when it happens - if (!(((format.charAt(i) == D_EVENT_TRACE) || (format.charAt(i) == D_EVENT_ENTITY)) && (arg.type == 'd') && (arg.value == Integer.valueOf(0)))) { - gameLocal.Error("idEvent::CopyArgs : Wrong type passed in for arg # %d on '%s' event.", i, evdef.GetName()); - } + idEventArg arg = args[i]; + if (format[i] != arg.type) { + // when NULL is passed in for an entity, it gets cast as an integer 0, so don't give an error when it happens + if (!(((format[i] == D_EVENT_TRACE) || (format[i] == D_EVENT_ENTITY)) && (arg.type == 'd') && (arg.value == Integer.valueOf(0)))) { + gameLocal.Error("idEvent::CopyArgs : Wrong type passed in for arg # %d on '%s' event.", i, evdef.GetName()); } - - data[i] = arg; } + + data[i] = arg; } } diff --git a/src/main/java/neo/Game/Item.java b/src/main/java/neo/Game/Item.java index 29075e1a..20e627b9 100644 --- a/src/main/java/neo/Game/Item.java +++ b/src/main/java/neo/Game/Item.java @@ -3,10 +3,14 @@ import static java.lang.Math.ceil; import static java.lang.Math.cos; import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; import java.util.Scanner; import static neo.CM.CollisionModel.CM_CLIP_EPSILON; import neo.CM.CollisionModel.trace_s; import neo.CM.CollisionModel_local; + +import static neo.Game.AFEntity.EV_Gib; import static neo.Game.Entity.EV_Activate; import static neo.Game.Entity.EV_Touch; import static neo.Game.Entity.TH_PHYSICS; @@ -17,6 +21,12 @@ import neo.Game.FX.idEntityFx; import neo.Game.GameSys.Class; import static neo.Game.GameSys.Class.EV_Remove; + +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.eventCallback_t2; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -83,7 +93,16 @@ public class Item { =============================================================================== */ public static class idItem extends idEntity { -// public CLASS_PROTOTYPE( idItem ); + // public CLASS_PROTOTYPE( idItem ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_DropToFloor, (eventCallback_t0) idItem::Event_DropToFloor); + eventCallbacks.put(EV_Touch, (eventCallback_t2) idItem::Event_Touch); + eventCallbacks.put(EV_Activate, (eventCallback_t1) idItem::Event_Trigger); + eventCallbacks.put(EV_RespawnItem, (eventCallback_t0) idItem::Event_Respawn); + eventCallbacks.put(EV_RespawnFx, (eventCallback_t0) idItem::Event_RespawnFx); + } + // enum { public static final int EVENT_PICKUP = idEntity.EVENT_MAXEVENTS; @@ -509,7 +528,8 @@ private void Event_DropToFloor() { SetOrigin(trace[0].endpos); } - private void Event_Touch(idEntity other, trace_s trace) { + private void Event_Touch(idEventArg _other, idEventArg trace) { + idEntity other = _other.value; if (!other.IsType(idPlayer.class)) { return; } @@ -521,8 +541,8 @@ private void Event_Touch(idEntity other, trace_s trace) { Pickup((idPlayer) other); } - private void Event_Trigger(idEntity activator) { - + private void Event_Trigger(idEventArg _activator) { + idEntity activator = _activator.value; if (!canPickUp && spawnArgs.GetBool("triggerFirst")) { canPickUp = true; return; @@ -556,6 +576,11 @@ private void Event_RespawnFx() { idEntityFx.StartFx(sfx, null, null, this, true); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -615,7 +640,14 @@ public boolean GiveToPlayer(idPlayer player) { =============================================================================== */ public static class idObjective extends idItem { -// public CLASS_PROTOTYPE( idObjective ); + //public CLASS_PROTOTYPE( idObjective ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idObjective::Event_Trigger); + eventCallbacks.put(EV_HideObjective, (eventCallback_t1) idObjective::Event_HideObjective); + eventCallbacks.put(EV_GetPlayerPos, (eventCallback_t0) idObjective::Event_GetPlayerPos); + eventCallbacks.put(EV_CamShot, (eventCallback_t0) idObjective::Event_CamShot); + } private idVec3 playerPos; // @@ -644,7 +676,7 @@ public void Spawn() { PostEventMS(EV_CamShot, 250); } - private void Event_Trigger(idEntity activator) { + private void Event_Trigger(idEventArg activator) { idPlayer player = gameLocal.GetLocalPlayer(); if (player != null) { @@ -678,7 +710,7 @@ private void Event_Trigger(idEntity activator) { } } - private void Event_HideObjective(idEntity e) { + private void Event_HideObjective(idEventArg e) { idPlayer player = gameLocal.GetLocalPlayer(); if (player != null) { idVec3 v = player.GetPhysics().GetOrigin().oMinus(playerPos); @@ -721,6 +753,11 @@ private void Event_CamShot() { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -773,7 +810,12 @@ public boolean GiveToPlayer(idPlayer player) { =============================================================================== */ public static class idMoveableItem extends idItem { -// public CLASS_PROTOTYPE( idMoveableItem ); + // public CLASS_PROTOTYPE( idMoveableItem ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_DropToFloor, (eventCallback_t0) idMoveableItem::Event_DropToFloor); + eventCallbacks.put(EV_Gib, (eventCallback_t1) idMoveableItem::Event_Gib); + } private idPhysics_RigidBody physicsObj; private idClipModel trigger; @@ -1044,8 +1086,13 @@ private void Event_DropToFloor() { // the physics will drop the moveable to the floor } - private void Event_Gib(final String damageDefName) { - Gib(new idVec3(0, 0, 1), damageDefName); + private void Event_Gib(final idEventArg damageDefName) { + Gib(new idVec3(0, 0, 1), damageDefName.value); + } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); } }; @@ -1084,8 +1131,11 @@ public boolean GiveToPlayer(idPlayer player) { =============================================================================== */ public static class idItemRemover extends idEntity { - -// public CLASS_PROTOTYPE( idItemRemover ); + //public CLASS_PROTOTYPE( idItemRemover ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idItemRemover::Event_Trigger); + } public void RemoveItem(idPlayer player) { final String remove; @@ -1094,7 +1144,8 @@ public void RemoveItem(idPlayer player) { player.RemoveInventoryItem(remove); } - private void Event_Trigger(idEntity activator) { + private void Event_Trigger(idEventArg _activator) { + idEntity activator = _activator.value; if (activator.IsType(idPlayer.class)) { RemoveItem((idPlayer) activator); } @@ -1109,6 +1160,11 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1119,8 +1175,14 @@ public Class.idClass CreateInstance() { =============================================================================== */ public static class idObjectiveComplete extends idItemRemover { + // public CLASS_PROTOTYPE( idObjectiveComplete ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idObjectiveComplete::Event_Trigger); + eventCallbacks.put(EV_HideObjective, (eventCallback_t1) idObjectiveComplete::Event_HideObjective); + eventCallbacks.put(EV_GetPlayerPos, (eventCallback_t0) idObjectiveComplete::Event_GetPlayerPos); + } -// public CLASS_PROTOTYPE( idObjectiveComplete ); private idVec3 playerPos; // // @@ -1146,7 +1208,7 @@ public void Spawn() { Hide(); } - private void Event_Trigger(idEntity activator) { + private void Event_Trigger(idEventArg activator) { if (!spawnArgs.GetBool("objEnabled")) { return; } @@ -1166,7 +1228,7 @@ private void Event_Trigger(idEntity activator) { } } - private void Event_HideObjective(idEntity e) { + private void Event_HideObjective(idEventArg e) { idPlayer player = gameLocal.GetLocalPlayer(); if (player != null) { playerPos.oSet(player.GetPhysics().GetOrigin()); @@ -1187,5 +1249,10 @@ private void Event_GetPlayerPos() { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/Light.java b/src/main/java/neo/Game/Light.java index 6ae60e92..bfe3c424 100644 --- a/src/main/java/neo/Game/Light.java +++ b/src/main/java/neo/Game/Light.java @@ -1,10 +1,21 @@ package neo.Game; +import static neo.Game.Entity.EV_Activate; +import static neo.Game.Entity.EV_Hide; import static neo.Game.Entity.EV_PostSpawn; +import static neo.Game.Entity.EV_Show; import static neo.Game.Entity.TH_THINK; import static neo.Game.Entity.TH_UPDATEVISUALS; import neo.Game.Entity.idEntity; +import neo.Game.GameSys.Class; +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.eventCallback_t2; +import neo.Game.GameSys.Class.eventCallback_t3; +import neo.Game.GameSys.Class.eventCallback_t4; import neo.Game.GameSys.Class.idClass; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -51,6 +62,9 @@ import neo.idlib.math.Vector.idVec3; import neo.idlib.math.Vector.idVec4; +import java.util.HashMap; +import java.util.Map; + /** * */ @@ -75,7 +89,25 @@ public class Light { public static final idEventDef EV_Light_FadeIn = new idEventDef("fadeInLight", "f"); public static class idLight extends idEntity { -// public CLASS_PROTOTYPE( idLight ); + // public CLASS_PROTOTYPE( idLight ); + private static Map eventCallbacks = new HashMap<>(); + static{ + eventCallbacks.put(EV_Light_SetShader, (eventCallback_t1) idLight::Event_SetShader); + eventCallbacks.put(EV_Light_GetLightParm, (eventCallback_t1) idLight::Event_GetLightParm); + eventCallbacks.put(EV_Light_SetLightParm, (eventCallback_t2) idLight::Event_SetLightParm); + eventCallbacks.put(EV_Light_SetLightParms, (eventCallback_t4) idLight::Event_SetLightParms); + eventCallbacks.put(EV_Light_SetRadiusXYZ, (eventCallback_t3) idLight::Event_SetRadiusXYZ); + eventCallbacks.put(EV_Light_SetRadius, (eventCallback_t1) idLight::Event_SetRadius); + eventCallbacks.put(EV_Hide, (eventCallback_t0) idLight::Event_Hide); + eventCallbacks.put(EV_Show, (eventCallback_t0) idLight::Event_Show); + eventCallbacks.put(EV_Light_On, (eventCallback_t0) idLight::Event_On); + eventCallbacks.put(EV_Light_Off, (eventCallback_t0) idLight::Event_Off); + eventCallbacks.put(EV_Activate, (eventCallback_t1) idLight::Event_ToggleOnOff); + eventCallbacks.put(EV_PostSpawn, (eventCallback_t0) idLight::Event_SetSoundHandles); + eventCallbacks.put(EV_Light_FadeOut, (eventCallback_t1) idLight::Event_FadeOut); + eventCallbacks.put(EV_Light_FadeIn, (eventCallback_t1) idLight::Event_FadeIn); + } + private renderLight_s renderLight; // light presented to the renderer private idVec3 localLightOrigin; // light origin relative to the physics origin @@ -762,11 +794,12 @@ private void PresentModelDefChange() { } } - private void Event_SetShader(final String shadername) { - SetShader(shadername); + private void Event_SetShader(final idEventArg shadername) { + SetShader(shadername.value); } - private void Event_GetLightParm(int parmnum) { + private void Event_GetLightParm(idEventArg _parmnum) { + int parmnum = _parmnum.value; if ((parmnum < 0) || (parmnum >= MAX_ENTITY_SHADER_PARMS)) { gameLocal.Error("shader parm index (%d) out of range", parmnum); } @@ -774,20 +807,20 @@ private void Event_GetLightParm(int parmnum) { idThread.ReturnFloat(renderLight.shaderParms[ parmnum]); } - private void Event_SetLightParm(int parmnum, float value) { - SetLightParm(parmnum, value); + private void Event_SetLightParm(idEventArg parmnum, idEventArg value) { + SetLightParm(parmnum.value, value.value); } - private void Event_SetLightParms(float parm0, float parm1, float parm2, float parm3) { - SetLightParms(parm0, parm1, parm2, parm3); + private void Event_SetLightParms(idEventArg parm0, idEventArg parm1, idEventArg parm2, idEventArg parm3) { + SetLightParms(parm0.value, parm1.value, parm2.value, parm3.value); } - private void Event_SetRadiusXYZ(float x, float y, float z) { - SetRadiusXYZ(x, y, z); + private void Event_SetRadiusXYZ(idEventArg x, idEventArg y, idEventArg z) { + SetRadiusXYZ(x.value, y.value, z.value); } - private void Event_SetRadius(float radius) { - SetRadius(radius); + private void Event_SetRadius(idEventArg radius) { + SetRadius(radius.value); } private void Event_Hide() { @@ -810,7 +843,7 @@ private void Event_Off() { Off(); } - private void Event_ToggleOnOff(idEntity activator) { + private void Event_ToggleOnOff(idEventArg activator) { triggercount++; if (triggercount < count) { return; @@ -820,7 +853,7 @@ private void Event_ToggleOnOff(idEntity activator) { triggercount = 0; if (breakOnTrigger) { - BecomeBroken(activator); + BecomeBroken(activator.value); breakOnTrigger = false; return; } @@ -870,12 +903,12 @@ private void Event_SetSoundHandles() { } } - private void Event_FadeOut(float time) { - FadeOut(time); + private void Event_FadeOut(idEventArg time) { + FadeOut(time.value); } - private void Event_FadeIn(float time) { - FadeIn(time); + private void Event_FadeIn(idEventArg time) { + FadeIn(time.value); } @Override @@ -887,5 +920,10 @@ public idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/Moveable.java b/src/main/java/neo/Game/Moveable.java index 8725ca63..067469d5 100644 --- a/src/main/java/neo/Game/Moveable.java +++ b/src/main/java/neo/Game/Moveable.java @@ -1,6 +1,9 @@ package neo.Game; import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; + import static neo.CM.CollisionModel.CM_CLIP_EPSILON; import neo.CM.CollisionModel.trace_s; import neo.CM.CollisionModel_local; @@ -14,6 +17,11 @@ import neo.Game.FX.idEntityFx; import neo.Game.GameSys.Class; import static neo.Game.GameSys.Class.EV_Remove; + +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -103,22 +111,31 @@ public class Moveable { public static class idMoveable extends idEntity { // CLASS_PROTOTYPE( idMoveable ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idMoveable::Event_Activate); + eventCallbacks.put(EV_BecomeNonSolid, (eventCallback_t0) idMoveable::Event_BecomeNonSolid); + eventCallbacks.put(EV_SetOwnerFromSpawnArgs, (eventCallback_t0) idMoveable::Event_SetOwnerFromSpawnArgs); + eventCallbacks.put(EV_IsAtRest, (eventCallback_t0) idMoveable::Event_IsAtRest); + eventCallbacks.put(EV_EnableDamage, (eventCallback_t1) idMoveable::Event_EnableDamage); + } - protected idPhysics_RigidBody physicsObj; // physics object - protected idStr brokenModel; // model set when health drops down to or below zero - protected idStr damage; // if > 0 apply damage to hit entities - protected idStr fxCollide; // fx system to start when collides with something - protected int nextCollideFxTime; // next time it is ok to spawn collision fx - protected float minDamageVelocity; // minimum velocity before moveable applies damage - protected float maxDamageVelocity; // velocity at which the maximum damage is applied - protected idCurve_Spline initialSpline; // initial spline path the moveable follows - protected idVec3 initialSplineDir; // initial relative direction along the spline path - protected boolean explode; // entity explodes when health drops down to or below zero - protected boolean unbindOnDeath; // unbind from master when health drops down to or below zero - protected boolean allowStep; // allow monsters to step on the object - protected boolean canDamage; // only apply damage when this is set - protected int nextDamageTime; // next time the movable can hurt the player - protected int nextSoundTime; // next time the moveable can make a sound + + protected idPhysics_RigidBody physicsObj; // physics object + protected idStr brokenModel; // model set when health drops down to or below zero + protected idStr damage; // if > 0 apply damage to hit entities + protected idStr fxCollide; // fx system to start when collides with something + protected int nextCollideFxTime;// next time it is ok to spawn collision fx + protected float minDamageVelocity;// minimum velocity before moveable applies damage + protected float maxDamageVelocity;// velocity at which the maximum damage is applied + protected idCurve_Spline initialSpline; // initial spline path the moveable follows + protected idVec3 initialSplineDir; // initial relative direction along the spline path + protected boolean explode; // entity explodes when health drops down to or below zero + protected boolean unbindOnDeath; // unbind from master when health drops down to or below zero + protected boolean allowStep; // allow monsters to step on the object + protected boolean canDamage; // only apply damage when this is set + protected int nextDamageTime; // next time the movable can hurt the player + protected int nextSoundTime; // next time the moveable can make a sound // // @@ -444,7 +461,7 @@ protected boolean FollowInitialSplinePath() { return false; } - protected void Event_Activate(idEntity activator) { + protected void Event_Activate(idEventArg activator) { float delay; idVec3 init_velocity = new idVec3(), init_avelocity = new idVec3(); @@ -492,8 +509,8 @@ protected void Event_IsAtRest() { idThread.ReturnInt(physicsObj.IsAtRest()); } - protected void Event_EnableDamage(float enable) { - canDamage = (enable != 0.0f); + protected void Event_EnableDamage(idEventArg enable) { + canDamage = (enable.value != 0.0f); } @Override @@ -507,6 +524,11 @@ public Class.idClass CreateInstance() { public void idEntity_Damage(idEntity inflictor, idEntity attacker, final idVec3 dir, final String damageDefName, final float damageScale, final int location) { super.Damage(inflictor, attacker, dir, damageDefName, damageScale, location); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -696,6 +718,13 @@ public void ClientPredictionThink() { */ public static class idExplodingBarrel extends idBarrel { // CLASS_PROTOTYPE( idExplodingBarrel ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idExplodingBarrel::Event_Activate); + eventCallbacks.put(EV_Respawn, (eventCallback_t0) idExplodingBarrel::Event_Respawn); + eventCallbacks.put(EV_Explode, (eventCallback_t0) idExplodingBarrel::Event_Explode); + eventCallbacks.put(EV_TriggerTargets, (eventCallback_t0) idExplodingBarrel::Event_TriggerTargets); + } // enum { public static final int EVENT_EXPLODE = idEntity.EVENT_MAXEVENTS; @@ -1048,8 +1077,8 @@ private void ExplodingEffects() { } @Override - public void Event_Activate(idEntity activator) { - Killed(activator, activator, 0, getVec3_origin(), 0); + public void Event_Activate(idEventArg activator) { + Killed(activator.value, activator.value, 0, getVec3_origin(), 0); } private void Event_Respawn() { @@ -1097,5 +1126,10 @@ private void Event_Explode() { private void Event_TriggerTargets() { ActivateTargets(this); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/Mover.java b/src/main/java/neo/Game/Mover.java index 5a6ef444..4ec322bd 100644 --- a/src/main/java/neo/Game/Mover.java +++ b/src/main/java/neo/Game/Mover.java @@ -2,6 +2,7 @@ import neo.CM.CollisionModel.trace_s; import static neo.Game.Entity.EV_Activate; +import static neo.Game.Entity.EV_Touch; import static neo.Game.Entity.TH_PHYSICS; import static neo.Game.Entity.TH_THINK; import neo.Game.Entity.idEntity; @@ -9,7 +10,15 @@ import static neo.Game.Entity.signalNum_t.SIG_MOVER_2TO1; import static neo.Game.Entity.signalNum_t.SIG_MOVER_POS1; import static neo.Game.Entity.signalNum_t.SIG_MOVER_POS2; + +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.eventCallback_t2; +import neo.Game.GameSys.Class.eventCallback_t3; +import neo.Game.GameSys.Class.eventCallback_t5; import neo.Game.GameSys.Class.idClass; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -43,6 +52,9 @@ import neo.Game.Physics.Physics_Parametric.idPhysics_Parametric; import neo.Game.Player.idPlayer; import neo.Game.Script.Script_Thread.idThread; + +import static neo.Game.Player.EV_SpectatorTouch; +import static neo.Game.Script.Script_Thread.EV_Thread_SetCallback; import static neo.Game.Sound.SSF_NO_OCCLUSION; import static neo.Renderer.Material.CONTENTS_SOLID; import static neo.Renderer.Material.CONTENTS_TRIGGER; @@ -85,6 +97,9 @@ import static neo.idlib.math.Vector.getVec3_zero; import neo.idlib.math.Vector.idVec3; +import java.util.HashMap; +import java.util.Map; + /** * */ @@ -107,60 +122,60 @@ public class Mover { "3", // moving 1 to 2 "4" // moving 2 to 1 }; - public static final idEventDef EV_FindGuiTargets = new idEventDef("", null); - public static final idEventDef EV_TeamBlocked = new idEventDef("", "ee"); - public static final idEventDef EV_PartBlocked = new idEventDef("", "e"); - public static final idEventDef EV_ReachedPos = new idEventDef("", null); - public static final idEventDef EV_ReachedAng = new idEventDef("", null); - public static final idEventDef EV_PostRestore = new idEventDef("", "ddddd"); - public static final idEventDef EV_StopMoving = new idEventDef("stopMoving", null); - public static final idEventDef EV_StopRotating = new idEventDef("stopRotating", null); - public static final idEventDef EV_Speed = new idEventDef("speed", "f"); - public static final idEventDef EV_Time = new idEventDef("time", "f"); - public static final idEventDef EV_AccelTime = new idEventDef("accelTime", "f"); - public static final idEventDef EV_DecelTime = new idEventDef("decelTime", "f"); - public static final idEventDef EV_MoveTo = new idEventDef("moveTo", "e"); - public static final idEventDef EV_MoveToPos = new idEventDef("moveToPos", "v"); - public static final idEventDef EV_Move = new idEventDef("move", "ff"); - public static final idEventDef EV_MoveAccelerateTo = new idEventDef("accelTo", "ff"); - public static final idEventDef EV_MoveDecelerateTo = new idEventDef("decelTo", "ff"); - public static final idEventDef EV_RotateDownTo = new idEventDef("rotateDownTo", "df"); - public static final idEventDef EV_RotateUpTo = new idEventDef("rotateUpTo", "df"); - public static final idEventDef EV_RotateTo = new idEventDef("rotateTo", "v"); - public static final idEventDef EV_Rotate = new idEventDef("rotate", "v"); - public static final idEventDef EV_RotateOnce = new idEventDef("rotateOnce", "v"); - public static final idEventDef EV_Bob = new idEventDef("bob", "ffv"); - public static final idEventDef EV_Sway = new idEventDef("sway", "ffv"); - public static final idEventDef EV_Mover_OpenPortal = new idEventDef("openPortal"); - public static final idEventDef EV_Mover_ClosePortal = new idEventDef("closePortal"); - public static final idEventDef EV_AccelSound = new idEventDef("accelSound", "s"); - public static final idEventDef EV_DecelSound = new idEventDef("decelSound", "s"); - public static final idEventDef EV_MoveSound = new idEventDef("moveSound", "s"); - public static final idEventDef EV_Mover_InitGuiTargets = new idEventDef("", null); - public static final idEventDef EV_EnableSplineAngles = new idEventDef("enableSplineAngles", null); - public static final idEventDef EV_DisableSplineAngles = new idEventDef("disableSplineAngles", null); + public static final idEventDef EV_FindGuiTargets = new idEventDef("", null); + public static final idEventDef EV_TeamBlocked = new idEventDef("", "ee"); + public static final idEventDef EV_PartBlocked = new idEventDef("", "e"); + public static final idEventDef EV_ReachedPos = new idEventDef("", null); + public static final idEventDef EV_ReachedAng = new idEventDef("", null); + public static final idEventDef EV_PostRestore = new idEventDef("", "ddddd"); + public static final idEventDef EV_StopMoving = new idEventDef("stopMoving", null); + public static final idEventDef EV_StopRotating = new idEventDef("stopRotating", null); + public static final idEventDef EV_Speed = new idEventDef("speed", "f"); + public static final idEventDef EV_Time = new idEventDef("time", "f"); + public static final idEventDef EV_AccelTime = new idEventDef("accelTime", "f"); + public static final idEventDef EV_DecelTime = new idEventDef("decelTime", "f"); + public static final idEventDef EV_MoveTo = new idEventDef("moveTo", "e"); + public static final idEventDef EV_MoveToPos = new idEventDef("moveToPos", "v"); + public static final idEventDef EV_Move = new idEventDef("move", "ff"); + public static final idEventDef EV_MoveAccelerateTo = new idEventDef("accelTo", "ff"); + public static final idEventDef EV_MoveDecelerateTo = new idEventDef("decelTo", "ff"); + public static final idEventDef EV_RotateDownTo = new idEventDef("rotateDownTo", "df"); + public static final idEventDef EV_RotateUpTo = new idEventDef("rotateUpTo", "df"); + public static final idEventDef EV_RotateTo = new idEventDef("rotateTo", "v"); + public static final idEventDef EV_Rotate = new idEventDef("rotate", "v"); + public static final idEventDef EV_RotateOnce = new idEventDef("rotateOnce", "v"); + public static final idEventDef EV_Bob = new idEventDef("bob", "ffv"); + public static final idEventDef EV_Sway = new idEventDef("sway", "ffv"); + public static final idEventDef EV_Mover_OpenPortal = new idEventDef("openPortal"); + public static final idEventDef EV_Mover_ClosePortal = new idEventDef("closePortal"); + public static final idEventDef EV_AccelSound = new idEventDef("accelSound", "s"); + public static final idEventDef EV_DecelSound = new idEventDef("decelSound", "s"); + public static final idEventDef EV_MoveSound = new idEventDef("moveSound", "s"); + public static final idEventDef EV_Mover_InitGuiTargets = new idEventDef("", null); + public static final idEventDef EV_EnableSplineAngles = new idEventDef("enableSplineAngles", null); + public static final idEventDef EV_DisableSplineAngles = new idEventDef("disableSplineAngles", null); public static final idEventDef EV_RemoveInitialSplineAngles = new idEventDef("removeInitialSplineAngles", null); - public static final idEventDef EV_StartSpline = new idEventDef("startSpline", "e"); - public static final idEventDef EV_StopSpline = new idEventDef("stopSpline", null); - public static final idEventDef EV_IsMoving = new idEventDef("isMoving", null, 'd'); - public static final idEventDef EV_IsRotating = new idEventDef("isRotating", null, 'd'); + public static final idEventDef EV_StartSpline = new idEventDef("startSpline", "e"); + public static final idEventDef EV_StopSpline = new idEventDef("stopSpline", null); + public static final idEventDef EV_IsMoving = new idEventDef("isMoving", null, 'd'); + public static final idEventDef EV_IsRotating = new idEventDef("isRotating", null, 'd'); // - public static final idEventDef EV_PostArrival = new idEventDef("postArrival", null); - public static final idEventDef EV_GotoFloor = new idEventDef("gotoFloor", "d"); + public static final idEventDef EV_PostArrival = new idEventDef("postArrival", null); + public static final idEventDef EV_GotoFloor = new idEventDef("gotoFloor", "d"); // - public static final idEventDef EV_Mover_ReturnToPos1 = new idEventDef("", null); - public static final idEventDef EV_Mover_MatchTeam = new idEventDef("", "dd"); - public static final idEventDef EV_Mover_Enable = new idEventDef("enable", null); - public static final idEventDef EV_Mover_Disable = new idEventDef("disable", null); + public static final idEventDef EV_Mover_ReturnToPos1 = new idEventDef("", null); + public static final idEventDef EV_Mover_MatchTeam = new idEventDef("", "dd"); + public static final idEventDef EV_Mover_Enable = new idEventDef("enable", null); + public static final idEventDef EV_Mover_Disable = new idEventDef("disable", null); // - public static final idEventDef EV_Door_StartOpen = new idEventDef("", null); - public static final idEventDef EV_Door_SpawnDoorTrigger = new idEventDef("", null); - public static final idEventDef EV_Door_SpawnSoundTrigger = new idEventDef("", null); - public static final idEventDef EV_Door_Open = new idEventDef("open", null); - public static final idEventDef EV_Door_Close = new idEventDef("close", null); - public static final idEventDef EV_Door_Lock = new idEventDef("lock", "d"); - public static final idEventDef EV_Door_IsOpen = new idEventDef("isOpen", null, 'f'); - public static final idEventDef EV_Door_IsLocked = new idEventDef("isLocked", null, 'f'); + public static final idEventDef EV_Door_StartOpen = new idEventDef("", null); + public static final idEventDef EV_Door_SpawnDoorTrigger = new idEventDef("", null); + public static final idEventDef EV_Door_SpawnSoundTrigger = new idEventDef("", null); + public static final idEventDef EV_Door_Open = new idEventDef("open", null); + public static final idEventDef EV_Door_Close = new idEventDef("close", null); + public static final idEventDef EV_Door_Lock = new idEventDef("lock", "d"); + public static final idEventDef EV_Door_IsOpen = new idEventDef("isOpen", null, 'f'); + public static final idEventDef EV_Door_IsLocked = new idEventDef("isLocked", null, 'f'); /* =============================================================================== @@ -171,6 +186,49 @@ public class Mover { */ public static class idMover extends idEntity { // CLASS_PROTOTYPE( idMover ); + private static Map eventCallbacks = new HashMap<>(); + static{ + eventCallbacks.put(EV_FindGuiTargets, (eventCallback_t0) idMover::Event_FindGuiTargets); + eventCallbacks.put(EV_Thread_SetCallback, (eventCallback_t0) idMover::Event_SetCallback); + eventCallbacks.put(EV_TeamBlocked, (eventCallback_t2) idMover::Event_TeamBlocked); + eventCallbacks.put(EV_PartBlocked, (eventCallback_t1) idMover::Event_PartBlocked); + eventCallbacks.put(EV_ReachedPos, (eventCallback_t0) idMover::Event_UpdateMove); + eventCallbacks.put(EV_ReachedAng, (eventCallback_t0) idMover::Event_UpdateRotation); + eventCallbacks.put(EV_PostRestore, (eventCallback_t5) idMover::Event_PostRestore); + eventCallbacks.put(EV_StopMoving, (eventCallback_t0) idMover::Event_StopMoving); + eventCallbacks.put(EV_StopRotating, (eventCallback_t0) idMover::Event_StopRotating); + eventCallbacks.put(EV_Speed, (eventCallback_t1) idMover::Event_SetMoveSpeed); + eventCallbacks.put(EV_Time, (eventCallback_t1) idMover::Event_SetMoveTime); + eventCallbacks.put(EV_AccelTime, (eventCallback_t1) idMover::Event_SetAccellerationTime); + eventCallbacks.put(EV_DecelTime, (eventCallback_t1) idMover::Event_SetDecelerationTime); + eventCallbacks.put(EV_MoveTo, (eventCallback_t1) idMover::Event_MoveTo); + eventCallbacks.put(EV_MoveToPos, (eventCallback_t1) idMover::Event_MoveToPos); + eventCallbacks.put(EV_Move, (eventCallback_t2) idMover::Event_MoveDir); + eventCallbacks.put(EV_MoveAccelerateTo, (eventCallback_t2) idMover::Event_MoveAccelerateTo); + eventCallbacks.put(EV_MoveDecelerateTo, (eventCallback_t2) idMover::Event_MoveDecelerateTo); + eventCallbacks.put(EV_RotateDownTo, (eventCallback_t2) idMover::Event_RotateDownTo); + eventCallbacks.put(EV_RotateUpTo, (eventCallback_t2) idMover::Event_RotateUpTo); + eventCallbacks.put(EV_RotateTo, (eventCallback_t1) idMover::Event_RotateTo); + eventCallbacks.put(EV_Rotate, (eventCallback_t1) idMover::Event_Rotate); + eventCallbacks.put(EV_RotateOnce, (eventCallback_t1) idMover::Event_RotateOnce); + eventCallbacks.put(EV_Bob, (eventCallback_t3) idMover::Event_Bob); + eventCallbacks.put(EV_Sway, (eventCallback_t3) idMover::Event_Sway); + eventCallbacks.put(EV_Mover_OpenPortal, (eventCallback_t0) idMover::Event_OpenPortal); + eventCallbacks.put(EV_Mover_ClosePortal, (eventCallback_t0) idMover::Event_ClosePortal); + eventCallbacks.put(EV_AccelSound, (eventCallback_t1) idMover::Event_SetAccelSound); + eventCallbacks.put(EV_DecelSound, (eventCallback_t1) idMover::Event_SetDecelSound); + eventCallbacks.put(EV_MoveSound, (eventCallback_t1) idMover::Event_SetMoveSound); + eventCallbacks.put(EV_Mover_InitGuiTargets, (eventCallback_t0) idMover::Event_InitGuiTargets); + eventCallbacks.put(EV_EnableSplineAngles, (eventCallback_t0) idMover::Event_EnableSplineAngles); + eventCallbacks.put(EV_DisableSplineAngles, (eventCallback_t0) idMover::Event_DisableSplineAngles); + eventCallbacks.put(EV_RemoveInitialSplineAngles, (eventCallback_t0) idMover::Event_RemoveInitialSplineAngles); + eventCallbacks.put(EV_StartSpline, (eventCallback_t1) idMover::Event_StartSpline); + eventCallbacks.put(EV_StopSpline, (eventCallback_t0) idMover::Event_StopSpline); + eventCallbacks.put(EV_Activate, (eventCallback_t1) idMover::Event_Activate); + eventCallbacks.put(EV_IsMoving, (eventCallback_t0) idMover::Event_IsMoving); + eventCallbacks.put(EV_IsRotating, (eventCallback_t0) idMover::Event_IsRotating); + } + protected moveState_t move; // @@ -563,12 +621,12 @@ protected void Event_ClosePortal() { } } - protected void Event_PartBlocked(idEntity blockingEntity) { + protected void Event_PartBlocked(idEventArg blockingEntity) { if (damage > 0.0f) { - blockingEntity.Damage(this, this, getVec3_origin(), "damage_moverCrush", damage, INVALID_JOINT); + blockingEntity.value.Damage(this, this, getVec3_origin(), "damage_moverCrush", damage, INVALID_JOINT); } if (g_debugMover.GetBool()) { - gameLocal.Printf("%d: '%s' blocked by '%s'\n", gameLocal.time, name, blockingEntity.name); + gameLocal.Printf("%d: '%s' blocked by '%s'\n", gameLocal.time, name, blockingEntity.value.name); } } @@ -923,9 +981,9 @@ private void Event_SetCallback() { } } - private void Event_TeamBlocked(idEntity blockedPart, idEntity blockingEntity) { + private void Event_TeamBlocked(idEventArg blockedPart, idEventArg blockingEntity) { if (g_debugMover.GetBool()) { - gameLocal.Printf("%d: '%s' stopped due to team member '%s' blocked by '%s'\n", gameLocal.time, name, blockedPart.name, blockingEntity.name); + gameLocal.Printf("%d: '%s' stopped due to team member '%s' blocked by '%s'\n", gameLocal.time, name, blockedPart.value.name, blockingEntity.value.name); } } @@ -1043,71 +1101,71 @@ private void Event_UpdateRotation() { } } - private void Event_SetMoveSpeed(float speed) { - if (speed <= 0) { + private void Event_SetMoveSpeed(idEventArg speed) { + if (speed.value <= 0) { gameLocal.Error("Cannot set speed less than or equal to 0."); } - move_speed = speed; + move_speed = speed.value; move_time = 0; // move_time is calculated for each move when move_speed is non-0 } - private void Event_SetMoveTime(float time) { - if (time <= 0) { + private void Event_SetMoveTime(idEventArg time) { + if (time.value <= 0) { gameLocal.Error("Cannot set time less than or equal to 0."); } move_speed = 0; - move_time = (int) SEC2MS(time); + move_time = (int) SEC2MS(time.value); } - private void Event_SetDecelerationTime(float time) { - if (time < 0) { + private void Event_SetDecelerationTime(idEventArg time) { + if (time.value < 0) { gameLocal.Error("Cannot set deceleration time less than 0."); } - deceltime = (int) SEC2MS(time); + deceltime = (int) SEC2MS(time.value); } - private void Event_SetAccellerationTime(float time) { - if (time < 0) { + private void Event_SetAccellerationTime(idEventArg time) { + if (time.value < 0) { gameLocal.Error("Cannot set acceleration time less than 0."); } - acceltime = (int) SEC2MS(time); + acceltime = (int) SEC2MS(time.value); } - private void Event_MoveTo(idEntity ent) { - if (null == ent) { + private void Event_MoveTo(idEventArg ent) { + if (null == ent.value) { gameLocal.Warning("Entity not found"); } - dest_position = GetLocalCoordinates(ent.GetPhysics().GetOrigin()); + dest_position = GetLocalCoordinates(ent.value.GetPhysics().GetOrigin()); BeginMove(idThread.CurrentThread()); } - private void Event_MoveToPos(idVec3 pos) { - dest_position = GetLocalCoordinates(pos); + private void Event_MoveToPos(idEventArg pos) { + dest_position = GetLocalCoordinates(pos.value); BeginMove(null); } - private void Event_MoveDir(float angle, float distance) { + private void Event_MoveDir(idEventArg angle, idEventArg distance) { idVec3 dir = new idVec3(); idVec3 org = new idVec3(); physicsObj.GetLocalOrigin(org); - VectorForDir(angle, dir); - dest_position = org.oPlus(dir.oMultiply(distance)); + VectorForDir(angle.value, dir); + dest_position = org.oPlus(dir.oMultiply(distance.value)); BeginMove(idThread.CurrentThread()); } - private void Event_MoveAccelerateTo(float speed, float time) { + private void Event_MoveAccelerateTo(idEventArg speed, idEventArg time) { float v; idVec3 org = new idVec3(), dir; int at; - if (time < 0) { + if (time.value < 0) { gameLocal.Error("idMover::Event_MoveAccelerateTo: cannot set acceleration time less than 0."); } @@ -1120,11 +1178,11 @@ private void Event_MoveAccelerateTo(float speed, float time) { } // if already moving faster than the desired speed - if (v >= speed) { + if (v >= speed.value) { return; } - at = idPhysics.SnapTimeToPhysicsFrame((int) SEC2MS(time)); + at = idPhysics.SnapTimeToPhysicsFrame((int) SEC2MS(time.value)); lastCommand = MOVER_MOVING; @@ -1137,15 +1195,15 @@ private void Event_MoveAccelerateTo(float speed, float time) { StartSound("snd_accel", SND_CHANNEL_BODY2, 0, false, null); StartSound("snd_move", SND_CHANNEL_BODY, 0, false, null); - physicsObj.SetLinearExtrapolation(EXTRAPOLATION_ACCELLINEAR, gameLocal.time, move.acceleration, org, dir.oMultiply(speed - v), dir.oMultiply(v)); + physicsObj.SetLinearExtrapolation(EXTRAPOLATION_ACCELLINEAR, gameLocal.time, move.acceleration, org, dir.oMultiply(speed.value - v), dir.oMultiply(v)); } - private void Event_MoveDecelerateTo(float speed, float time) { + private void Event_MoveDecelerateTo(idEventArg speed, idEventArg time) { float v; idVec3 org = new idVec3(), dir; int dt; - if (time < 0) { + if (time.value < 0) { gameLocal.Error("idMover::Event_MoveDecelerateTo: cannot set deceleration time less than 0."); } @@ -1158,11 +1216,11 @@ private void Event_MoveDecelerateTo(float speed, float time) { } // if already moving slower than the desired speed - if (v <= speed) { + if (v <= speed.value) { return; } - dt = idPhysics.SnapTimeToPhysicsFrame((int) SEC2MS(time)); + dt = idPhysics.SnapTimeToPhysicsFrame((int) SEC2MS(time.value)); lastCommand = MOVER_MOVING; @@ -1175,10 +1233,11 @@ private void Event_MoveDecelerateTo(float speed, float time) { StartSound("snd_decel", SND_CHANNEL_BODY2, 0, false, null); StartSound("snd_move", SND_CHANNEL_BODY, 0, false, null); - physicsObj.SetLinearExtrapolation(EXTRAPOLATION_DECELLINEAR, gameLocal.time, move.deceleration, org, dir.oMultiply(v - speed), dir.oMultiply(speed)); + physicsObj.SetLinearExtrapolation(EXTRAPOLATION_DECELLINEAR, gameLocal.time, move.deceleration, org, dir.oMultiply(v - speed.value), dir.oMultiply(speed.value)); } - private void Event_RotateDownTo(int axis, float angle) { + private void Event_RotateDownTo(idEventArg _axis, idEventArg angle) { + int axis = _axis.value; idAngles ang = new idAngles(); if ((axis < 0) || (axis > 2)) { @@ -1187,7 +1246,7 @@ private void Event_RotateDownTo(int axis, float angle) { physicsObj.GetLocalAngles(ang); - dest_angles.oSet(axis, angle); + dest_angles.oSet(axis, angle.value); if (dest_angles.oGet(axis) > ang.oGet(axis)) { dest_angles.oMinSet(axis, 360); } @@ -1195,7 +1254,8 @@ private void Event_RotateDownTo(int axis, float angle) { BeginRotation(idThread.CurrentThread(), true); } - private void Event_RotateUpTo(int axis, float angle) { + private void Event_RotateUpTo(idEventArg _axis, idEventArg angle) { + int axis = _axis.value; idAngles ang = new idAngles(); if ((axis < 0) || (axis > 2)) { @@ -1204,7 +1264,7 @@ private void Event_RotateUpTo(int axis, float angle) { physicsObj.GetLocalAngles(ang); - dest_angles.oSet(axis, angle); + dest_angles.oSet(axis, angle.value); if (dest_angles.oGet(axis) < ang.oGet(axis)) { dest_angles.oPluSet(axis, 360); } @@ -1212,12 +1272,12 @@ private void Event_RotateUpTo(int axis, float angle) { BeginRotation(idThread.CurrentThread(), true); } - private void Event_RotateTo(idAngles angles) { - dest_angles = angles; + private void Event_RotateTo(idEventArg angles) { + dest_angles.oSet(angles.value); BeginRotation(idThread.CurrentThread(), true); } - private void Event_Rotate(idAngles angles) { + private void Event_Rotate(idEventArg angles) { idAngles ang = new idAngles(); if (rotate_thread != 0) { @@ -1225,12 +1285,12 @@ private void Event_Rotate(idAngles angles) { } physicsObj.GetLocalAngles(ang); - dest_angles = ang.oPlus(angles.oMultiply(move_time - (acceltime + deceltime) / 2).oMultiply(0.001f)); + dest_angles = ang.oPlus(angles.value.oMultiply(move_time - (acceltime + deceltime) / 2).oMultiply(0.001f)); BeginRotation(idThread.CurrentThread(), false); } - private void Event_RotateOnce(idAngles angles) { + private void Event_RotateOnce(idEventArg angles) { idAngles ang = new idAngles(); if (rotate_thread != 0) { @@ -1238,38 +1298,40 @@ private void Event_RotateOnce(idAngles angles) { } physicsObj.GetLocalAngles(ang); - dest_angles = ang.oPlus(angles); + dest_angles = ang.oPlus(angles.value); BeginRotation(idThread.CurrentThread(), true); } - private void Event_Bob(float speed, float phase, idVec3 depth) { + private void Event_Bob(idEventArg speed, idEventArg phase, idEventArg depth) { idVec3 org = new idVec3(); physicsObj.GetLocalOrigin(org); - physicsObj.SetLinearExtrapolation((EXTRAPOLATION_DECELSINE | EXTRAPOLATION_NOSTOP), (int) (speed * 1000 * phase), (int) (speed * 500), org, depth.oMultiply(2.0f), getVec3_origin()); + physicsObj.SetLinearExtrapolation((EXTRAPOLATION_DECELSINE | EXTRAPOLATION_NOSTOP), (int) (speed.value * 1000 * phase.value), + (int) (speed.value * 500), org, depth.value.oMultiply(2.0f), getVec3_origin()); } - private void Event_Sway(float speed, float phase, idAngles depth) { + private void Event_Sway(idEventArg speed, idEventArg phase, idEventArg _depth) { + idAngles depth = _depth.value; idAngles ang = new idAngles(), angSpeed; float duration; physicsObj.GetLocalAngles(ang); - assert (speed > 0.0f); - duration = idMath.Sqrt(depth.oGet(0) * depth.oGet(0) + depth.oGet(1) * depth.oGet(1) + depth.oGet(2) * depth.oGet(2)) / speed; + assert (speed.value > 0.0f); + duration = idMath.Sqrt(depth.oGet(0) * depth.oGet(0) + depth.oGet(1) * depth.oGet(1) + depth.oGet(2) * depth.oGet(2)) / speed.value; angSpeed = depth.oDivide(duration * idMath.SQRT_1OVER2); - physicsObj.SetAngularExtrapolation((EXTRAPOLATION_DECELSINE | EXTRAPOLATION_NOSTOP), (int) (duration * 1000.0f * phase), (int) (duration * 1000.0f), ang, angSpeed, getAng_zero()); + physicsObj.SetAngularExtrapolation((EXTRAPOLATION_DECELSINE | EXTRAPOLATION_NOSTOP), (int) (duration * 1000.0f * phase.value), (int) (duration * 1000.0f), ang, angSpeed, getAng_zero()); } - private void Event_SetAccelSound(final String sound) { + private void Event_SetAccelSound(final idEventArg sound) { // refSound.SetSound( "accel", sound ); } - private void Event_SetDecelSound(final String sound) { + private void Event_SetDecelSound(final idEventArg sound) { // refSound.SetSound( "decel", sound ); } - private void Event_SetMoveSound(final String sound) { + private void Event_SetMoveSound(final idEventArg sound) { // refSound.SetSound( "move", sound ); } @@ -1301,7 +1363,8 @@ private void Event_RemoveInitialSplineAngles() { physicsObj.SetAngularExtrapolation(EXTRAPOLATION_NONE, 0, 0, ang.oNegative(), getAng_zero(), getAng_zero()); } - private void Event_StartSpline(idEntity splineEntity) { + private void Event_StartSpline(idEventArg _splineEntity) { + idEntity splineEntity = _splineEntity.value; idCurve_Spline spline; if (null == splineEntity) { @@ -1340,12 +1403,13 @@ private void Event_StopSpline() { splineEnt = null; } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { Show(); - Event_StartSpline(this); + Event_StartSpline(idEventArg.toArg(this)); } - private void Event_PostRestore(int start, int total, int accel, int decel, int useSplineAng) { + private void Event_PostRestore(idEventArg start, idEventArg total, idEventArg accel, + idEventArg decel, idEventArg useSplineAng) { idCurve_Spline spline; idEntity splineEntity = splineEnt.GetEntity(); @@ -1357,10 +1421,10 @@ private void Event_PostRestore(int start, int total, int accel, int decel, int u spline = splineEntity.GetSpline(); - spline.MakeUniform(total); - spline.ShiftTime(start - spline.GetTime(0)); + spline.MakeUniform(total.value); + spline.ShiftTime(start.value - spline.GetTime(0)); - physicsObj.SetSpline(spline, accel, decel, (useSplineAng != 0)); + physicsObj.SetSpline(spline, accel.value, decel.value, (useSplineAng.value != 0)); physicsObj.SetLinearExtrapolation(EXTRAPOLATION_NONE, 0, 0, dest_position, getVec3_origin(), getVec3_origin()); } @@ -1379,6 +1443,11 @@ private void Event_IsRotating() { idThread.ReturnInt(true); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1421,6 +1490,15 @@ public static class floorInfo_s { */ public static class idElevator extends idMover { // CLASS_PROTOTYPE( idElevator ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idElevator::Event_Activate); + eventCallbacks.put(EV_TeamBlocked, (eventCallback_t2) idElevator::Event_TeamBlocked); + eventCallbacks.put(EV_PartBlocked, (eventCallback_t1) idElevator::Event_PartBlocked); + eventCallbacks.put(EV_PostArrival, (eventCallback_t0) idElevator::Event_PostFloorArrival); + eventCallbacks.put(EV_GotoFloor, (eventCallback_t1) idElevator::Event_GotoFloor); + eventCallbacks.put(EV_Touch, (eventCallback_t2) idElevator::Event_Touch); + } protected enum elevatorState_t { @@ -1572,8 +1650,8 @@ public boolean HandleSingleGuiCommand(idEntity entityGui, idLexer src) { return false; } - public void Event_GotoFloor(int floor) { - floorInfo_s fi = GetFloorInfo(floor); + public void Event_GotoFloor(idEventArg floor) { + floorInfo_s fi = GetFloorInfo(floor.value); if (fi != null) { idDoor door = GetDoor(spawnArgs.GetString("innerdoor")); if (door != null) { @@ -1585,7 +1663,7 @@ public void Event_GotoFloor(int floor) { DisableAllDoors(); CloseAllDoors(); state = WAITING_ON_DOORS; - pendingFloor = floor; + pendingFloor = floor.value; } } @@ -1651,13 +1729,13 @@ protected void BeginMove(idThread thread /*= NULL*/) { // protected void GetLocalTriggerPosition(); // - protected void Event_Touch(idEntity other, trace_s trace) { + protected void Event_Touch(idEventArg other, idEventArg trace) { if (gameLocal.time < lastTouchTime + 2000) { return; } - if (!other.IsType(idPlayer.class)) { + if (!other.value.IsType(idPlayer.class)) { return; } @@ -1717,7 +1795,7 @@ public void Think() { } } - Event_GotoFloor(pendingFloor); + Event_GotoFloor(idEventArg.toArg(pendingFloor)); DisableAllDoors(); SetGuiStates((pendingFloor == 1) ? guiBinaryMoverStates[0] : guiBinaryMoverStates[1]); } else if (state == WAITING_ON_DOORS) { @@ -1798,12 +1876,12 @@ private void EnableProperDoors() { } } - private void Event_TeamBlocked(idEntity blockedEntity, idEntity blockingEntity) { - if (blockedEntity == this) { - Event_GotoFloor(lastFloor); - } else if (blockedEntity != null && blockedEntity.IsType(idDoor.class)) { + private void Event_TeamBlocked(idEventArg blockedEntity, idEventArg blockingEntity) { + if (blockedEntity.value == this) { + Event_GotoFloor(idEventArg.toArg(lastFloor)); + } else if (blockedEntity != null && blockedEntity.value.IsType(idDoor.class)) { // open the inner doors if one is blocked - idDoor blocked = (idDoor) blockedEntity; + idDoor blocked = (idDoor) blockedEntity.value; idDoor door = GetDoor(spawnArgs.GetString("innerdoor")); if (door != null && blocked.GetMoveMaster() == door.GetMoveMaster()) {//TODO:equalds door.SetBlocked(true); @@ -1813,10 +1891,10 @@ private void Event_TeamBlocked(idEntity blockedEntity, idEntity blockingEntity) } } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { int triggerFloor = spawnArgs.GetInt("triggerFloor"); if (spawnArgs.GetBool("trigger") && triggerFloor != currentFloor) { - Event_GotoFloor(triggerFloor); + Event_GotoFloor(idEventArg.toArg(triggerFloor)); } } @@ -1829,6 +1907,11 @@ private void Event_PostFloorArrival() { PostEventSec(EV_GotoFloor, returnTime, returnFloor); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1859,6 +1942,20 @@ Doors, plats, and buttons are all binary (two position) movers */ public static class idMover_Binary extends idEntity { // CLASS_PROTOTYPE( idMover_Binary ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_FindGuiTargets, (eventCallback_t0) idMover_Binary::Event_FindGuiTargets); + eventCallbacks.put(EV_Thread_SetCallback, (eventCallback_t0) idMover_Binary::Event_SetCallback); + eventCallbacks.put(EV_Mover_ReturnToPos1, (eventCallback_t0) idMover_Binary::Event_ReturnToPos1); + eventCallbacks.put(EV_Activate, (eventCallback_t1) idMover_Binary::Event_Use_BinaryMover); + eventCallbacks.put(EV_ReachedPos, (eventCallback_t0) idMover_Binary::Event_Reached_BinaryMover); + eventCallbacks.put(EV_Mover_MatchTeam, (eventCallback_t2) idMover_Binary::Event_MatchActivateTeam); + eventCallbacks.put(EV_Mover_Enable, (eventCallback_t0) idMover_Binary::Event_Enable); + eventCallbacks.put(EV_Mover_Disable, (eventCallback_t0) idMover_Binary::Event_Disable); + eventCallbacks.put(EV_Mover_OpenPortal, (eventCallback_t0) idMover_Binary::Event_OpenPortal); + eventCallbacks.put(EV_Mover_ClosePortal, (eventCallback_t0) idMover_Binary::Event_ClosePortal); + eventCallbacks.put(EV_Mover_InitGuiTargets, (eventCallback_t0) idMover_Binary::Event_InitGuiTargets); + } protected idVec3 pos1; protected idVec3 pos2; @@ -1916,6 +2013,7 @@ public idMover_Binary() { areaPortal = 0; blocked = false; fl.networkSync = true; + guiTargets = new idList<>(); } // ~idMover_Binary(); @@ -2582,8 +2680,8 @@ protected void Event_ReturnToPos1() { MatchActivateTeam(MOVER_2TO1, gameLocal.time); } - protected void Event_Use_BinaryMover(idEntity activator) { - Use_BinaryMover(activator); + protected void Event_Use_BinaryMover(idEventArg activator) { + Use_BinaryMover(activator.value); } protected void Event_Reached_BinaryMover() { @@ -2638,8 +2736,8 @@ protected void Event_Reached_BinaryMover() { } } - protected void Event_MatchActivateTeam(moverState_t newstate, int time) { - MatchActivateTeam(newstate, time); + protected void Event_MatchActivateTeam(idEventArg newstate, idEventArg time) { + MatchActivateTeam(newstate.value, time.value); } /* @@ -2748,6 +2846,11 @@ public idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -2761,6 +2864,25 @@ public idClass CreateInstance() { =============================================================================== */ public static class idDoor extends idMover_Binary { + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_TeamBlocked, (eventCallback_t2) idDoor::Event_TeamBlocked); + eventCallbacks.put(EV_PartBlocked, (eventCallback_t1) idDoor::Event_PartBlocked); + eventCallbacks.put(EV_Touch, (eventCallback_t2) idDoor::Event_Touch); + eventCallbacks.put(EV_Activate, (eventCallback_t1) idDoor::Event_Activate); + eventCallbacks.put(EV_Door_StartOpen, (eventCallback_t0) idDoor::Event_StartOpen); + eventCallbacks.put(EV_Door_SpawnDoorTrigger, (eventCallback_t0) idDoor::Event_SpawnDoorTrigger); + eventCallbacks.put(EV_Door_SpawnSoundTrigger, (eventCallback_t0) idDoor::Event_SpawnSoundTrigger); + eventCallbacks.put(EV_Door_Open, (eventCallback_t0) idDoor::Event_Open); + eventCallbacks.put(EV_Door_Close, (eventCallback_t0) idDoor::Event_Close); + eventCallbacks.put(EV_Door_Lock, (eventCallback_t1) idDoor::Event_Lock); + eventCallbacks.put(EV_Door_IsOpen, (eventCallback_t0) idDoor::Event_IsOpen); + eventCallbacks.put(EV_Door_IsLocked, (eventCallback_t0) idDoor::Event_Locked); + eventCallbacks.put(EV_ReachedPos, (eventCallback_t0) idDoor::Event_Reached_BinaryMover); + eventCallbacks.put(EV_SpectatorTouch, (eventCallback_t2) idDoor::Event_SpectatorTouch); + eventCallbacks.put(EV_Mover_OpenPortal, (eventCallback_t0) idDoor::Event_OpenPortal); + eventCallbacks.put(EV_Mover_ClosePortal, (eventCallback_t0) idDoor::Event_ClosePortal); + } private float triggersize; private boolean crusher; @@ -3223,7 +3345,7 @@ protected void Event_Reached_BinaryMover() { super.Event_Reached_BinaryMover(); } - private void Event_TeamBlocked(idEntity blockedEntity, idEntity blockingEntity) { + private void Event_TeamBlocked(idEventArg blockedEntity, idEventArg blockingEntity) { SetBlocked(true); if (crusher) { @@ -3234,17 +3356,19 @@ private void Event_TeamBlocked(idEntity blockedEntity, idEntity blockingEntity) Use_BinaryMover(moveMaster.GetActivator()); if (companionDoor != null) { - companionDoor.ProcessEvent(EV_TeamBlocked, blockedEntity, blockingEntity); + companionDoor.ProcessEvent(EV_TeamBlocked, blockedEntity.value, blockingEntity.value); } } - private void Event_PartBlocked(idEntity blockingEntity) { + private void Event_PartBlocked(idEventArg blockingEntity) { if (damage > 0.0f) { - blockingEntity.Damage(this, this, getVec3_origin(), "damage_moverCrush", damage, INVALID_JOINT); + blockingEntity.value.Damage(this, this, getVec3_origin(), "damage_moverCrush", damage, INVALID_JOINT); } } - private void Event_Touch(idEntity other, trace_s trace) { + private void Event_Touch(idEventArg _other, idEventArg _trace) { + idEntity other = _other.value; + trace_s trace = _trace.value; // idVec3 contact, translate; // idVec3 planeaxis1, planeaxis2, normal; // idBounds bounds; @@ -3265,7 +3389,7 @@ private void Event_Touch(idEntity other, trace_s trace) { } } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { int old_lock; if (spawnArgs.GetInt("locked") != 0) { @@ -3296,12 +3420,12 @@ private void Event_Activate(idEntity activator) { } } - ActivateTargets(activator); + ActivateTargets(activator.value); renderEntity.shaderParms[ SHADERPARM_MODE] = 1; UpdateVisuals(); - Use_BinaryMover(activator); + Use_BinaryMover(activator.value); } /* @@ -3415,8 +3539,8 @@ private void Event_Open() { Open(); } - private void Event_Lock(int f) { - Lock(f); + private void Event_Lock(idEventArg f) { + Lock(f.value); } private void Event_IsOpen() { @@ -3430,7 +3554,8 @@ private void Event_Locked() { idThread.ReturnFloat(spawnArgs.GetInt("locked")); } - private void Event_SpectatorTouch(idEntity other, trace_s trace) { + private void Event_SpectatorTouch(idEventArg _other, idEventArg trace) { + idEntity other = _other.value; idVec3 contact, translate, normal = new idVec3(); idBounds bounds; idPlayer p; @@ -3445,7 +3570,7 @@ private void Event_SpectatorTouch(idEntity other, trace_s trace) { if (trigger != null && !IsOpen()) { // teleport to the other side, center to the middle of the trigger brush bounds = trigger.GetAbsBounds(); - contact = trace.endpos.oMinus(bounds.GetCenter()); + contact = trace.value.endpos.oMinus(bounds.GetCenter()); translate = bounds.GetCenter(); normal.Zero(); normal.oSet(normalAxisIndex, 1.0f); @@ -3506,6 +3631,11 @@ protected void Event_ClosePortal() { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -3517,6 +3647,12 @@ protected void Event_ClosePortal() { */ public static class idPlat extends idMover_Binary { // CLASS_PROTOTYPE( idPlat ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Touch, (eventCallback_t2) idPlat::Event_Touch); + eventCallbacks.put(EV_TeamBlocked, (eventCallback_t2) idPlat::Event_TeamBlocked); + eventCallbacks.put(EV_PartBlocked, (eventCallback_t1) idPlat::Event_PartBlocked); + } private idClipModel trigger; private idVec3 localTriggerOrigin; @@ -3662,26 +3798,32 @@ private void SpawnPlatTrigger(idVec3 pos) { trigger.SetContents(CONTENTS_TRIGGER); } - private void Event_TeamBlocked(idEntity blockedEntity, idEntity blockingEntity) { + private void Event_TeamBlocked(idEventArg blockedEntity, idEventArg blockingEntity) { // reverse direction Use_BinaryMover(activatedBy.GetEntity()); } - private void Event_PartBlocked(idEntity blockingEntity) { + private void Event_PartBlocked(idEventArg blockingEntity) { if (damage > 0) { - blockingEntity.Damage(this, this, getVec3_origin(), "damage_moverCrush", damage, INVALID_JOINT); + blockingEntity.value.Damage(this, this, getVec3_origin(), "damage_moverCrush", damage, INVALID_JOINT); } } - private void Event_Touch(idEntity other, trace_s trace) { + private void Event_Touch(idEventArg _other, idEventArg trace) { + idEntity other = _other.value; if (!other.IsType(idPlayer.class)) { return; } - if ((GetMoverState() == MOVER_POS1) && trigger != null && (trace.c.id == trigger.GetId()) && (other.health > 0)) { + if ((GetMoverState() == MOVER_POS1) && trigger != null && (trace.value.c.id == trigger.GetId()) && (other.health > 0)) { Use_BinaryMover(other); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -3700,6 +3842,11 @@ private void Event_Touch(idEntity other, trace_s trace) { */ public static class idMover_Periodic extends idEntity { // CLASS_PROTOTYPE( idMover_Periodic ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_TeamBlocked, (eventCallback_t2) idMover_Periodic::Event_TeamBlocked); + eventCallbacks.put(EV_PartBlocked, (eventCallback_t1) idMover_Periodic::Event_PartBlocked); + } protected idPhysics_Parametric physicsObj; protected float[] damage = {0}; @@ -3759,12 +3906,12 @@ public void ReadFromSnapshot(final idBitMsgDelta msg) { } } - protected void Event_TeamBlocked(idEntity blockedEntity, idEntity blockingEntity) { + protected void Event_TeamBlocked(idEventArg blockedEntity, idEventArg blockingEntity) { } - protected void Event_PartBlocked(idEntity blockingEntity) { + protected void Event_PartBlocked(idEventArg blockingEntity) { if (damage[0] > 0) { - blockingEntity.Damage(this, this, getVec3_origin(), "damage_moverCrush", damage[0], INVALID_JOINT); + blockingEntity.value.Damage(this, this, getVec3_origin(), "damage_moverCrush", damage[0], INVALID_JOINT); } } @@ -3777,6 +3924,11 @@ public idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -3788,6 +3940,10 @@ public idClass CreateInstance() { */ public static class idRotater extends idMover_Periodic { // CLASS_PROTOTYPE( idRotater ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idRotater::Event_Activate); + } private idEntityPtr activatedBy; // @@ -3826,13 +3982,13 @@ public void Restore(idRestoreGame savefile) { activatedBy.Restore(savefile); } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { float[] speed = {0}; boolean[] x_axis = {false}; boolean[] y_axis = {false}; idAngles delta = new idAngles(); - activatedBy.oSet(activator); + activatedBy.oSet(activator.value); delta.Zero(); @@ -3856,6 +4012,11 @@ private void Event_Activate(idEntity activator) { physicsObj.SetAngularExtrapolation((EXTRAPOLATION_LINEAR | EXTRAPOLATION_NOSTOP), gameLocal.time, 0, physicsObj.GetAxis().ToAngles(), delta, getAng_zero()); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -3969,6 +4130,10 @@ public void Spawn() { */ public static class idRiser extends idMover_Periodic { // CLASS_PROTOTYPE( idRiser ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idRiser::Event_Activate); + } //public idRiser( ){} @Override @@ -3989,7 +4154,7 @@ public void Spawn() { SetPhysics(physicsObj); } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { if (!IsHidden() && spawnArgs.GetBool("hide")) { Hide(); @@ -4008,5 +4173,10 @@ private void Event_Activate(idEntity activator) { physicsObj.SetLinearExtrapolation(EXTRAPOLATION_LINEAR, gameLocal.time, (int) (time[0] * 1000), physicsObj.GetOrigin(), delta, getVec3_origin()); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/Projectile.java b/src/main/java/neo/Game/Projectile.java index bddd8bf7..fb304ded 100644 --- a/src/main/java/neo/Game/Projectile.java +++ b/src/main/java/neo/Game/Projectile.java @@ -1,17 +1,27 @@ package neo.Game; import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; + import neo.CM.CollisionModel.trace_s; import neo.CM.CollisionModel_local; import neo.Game.AFEntity.idAFAttachment; import neo.Game.AI.AI.idAI; import neo.Game.Actor.idActor; import static neo.Game.Entity.EV_Activate; +import static neo.Game.Entity.EV_Touch; import static neo.Game.Entity.TH_THINK; import neo.Game.Entity.idEntity; import static neo.Game.Game.TEST_PARTICLE_IMPACT; import neo.Game.GameSys.Class; import static neo.Game.GameSys.Class.EV_Remove; + +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.eventCallback_t2; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -124,6 +134,15 @@ public class Projectile { public static final idEventDef EV_RemoveBeams = new idEventDef("", null); public static class idProjectile extends idEntity { + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Explode, (eventCallback_t0) idProjectile::Event_Explode); + eventCallbacks.put(EV_Fizzle, (eventCallback_t0) idProjectile::Event_Fizzle); + eventCallbacks.put(EV_Touch, (eventCallback_t2) idProjectile::Event_Touch); + eventCallbacks.put(EV_RadiusDamage, (eventCallback_t1) idProjectile::Event_RadiusDamage); + eventCallbacks.put(EV_GetProjectileState, (eventCallback_t0) idProjectile::Event_GetProjectileState); + } + protected idEntityPtr owner; // @@ -852,7 +871,7 @@ public void Explode(final trace_s collision, idEntity ignore) { } PostEventSec(EV_RadiusDamage, delay, ignore); } else { - Event_RadiusDamage(ignore); + Event_RadiusDamage(idEventArg.toArg(ignore)); } } @@ -1226,20 +1245,20 @@ private void Event_Fizzle() { Fizzle(); } - private void Event_RadiusDamage(idEntity ignore) { + private void Event_RadiusDamage(idEventArg ignore) { final String splash_damage = spawnArgs.GetString("def_splash_damage"); if (!splash_damage.isEmpty()) {//[0] != '\0' ) { - gameLocal.RadiusDamage(physicsObj.GetOrigin(), this, owner.GetEntity(), ignore, this, splash_damage, damagePower); + gameLocal.RadiusDamage(physicsObj.GetOrigin(), this, owner.GetEntity(), ignore.value, this, splash_damage, damagePower); } } - private void Event_Touch(idEntity other, trace_s trace) { + private void Event_Touch(idEventArg other, idEventArg trace) { if (IsHidden()) { return; } - if (!other.equals(owner.GetEntity())) { + if (!other.value.equals(owner.GetEntity())) { trace_s collision; collision = new trace_s();//memset( &collision, 0, sizeof( collision ) ); @@ -1255,6 +1274,11 @@ private void Event_Touch(idEntity other, trace_s trace) { private void Event_GetProjectileState() { idThread.ReturnInt(etoi(state)); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1663,6 +1687,10 @@ public static class beamTarget_t { */ public static class idBFGProjectile extends idProjectile { // CLASS_PROTOTYPE( idBFGProjectile ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_RemoveBeams, (eventCallback_t0) idBFGProjectile::Event_RemoveBeams); + } private idList beamTargets; private renderEntity_s secondModel; @@ -2006,6 +2034,11 @@ private void Event_RemoveBeams() { UpdateVisuals(); } + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } + // private void ApplyDamage(); }; @@ -2018,12 +2051,18 @@ private void Event_RemoveBeams() { */ public static class idDebris extends idEntity { // CLASS_PROTOTYPE( idDebris ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Explode, (eventCallback_t0) idDebris::Event_Explode); + eventCallbacks.put(EV_Fizzle, (eventCallback_t0) idDebris::Event_Fizzle); + } + private idEntityPtr owner; - private idPhysics_RigidBody physicsObj; - private idDeclParticle smokeFly; - private int smokeFlyTime; - private idSoundShader sndBounce; + private idPhysics_RigidBody physicsObj; + private idDeclParticle smokeFly; + private int smokeFlyTime; + private idSoundShader sndBounce; // // @@ -2307,5 +2346,10 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/Script/Script_Thread.java b/src/main/java/neo/Game/Script/Script_Thread.java index 4f386bbf..48bf7f2c 100644 --- a/src/main/java/neo/Game/Script/Script_Thread.java +++ b/src/main/java/neo/Game/Script/Script_Thread.java @@ -68,7 +68,7 @@ public class Script_Thread { static final idEventDef EV_Thread_Execute = new idEventDef("", null); - static final idEventDef EV_Thread_SetCallback = new idEventDef("", null); + public static final idEventDef EV_Thread_SetCallback = new idEventDef("", null); // // script callable events static final idEventDef EV_Thread_TerminateThread = new idEventDef("terminate", "d"); diff --git a/src/main/java/neo/Game/SecurityCamera.java b/src/main/java/neo/Game/SecurityCamera.java index b63f7996..020a31cf 100644 --- a/src/main/java/neo/Game/SecurityCamera.java +++ b/src/main/java/neo/Game/SecurityCamera.java @@ -6,6 +6,9 @@ import static neo.Game.Entity.TH_UPDATEVISUALS; import neo.Game.Entity.idEntity; import neo.Game.FX.idEntityFx; +import neo.Game.GameSys.Class; +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -40,6 +43,9 @@ import neo.idlib.math.Vector.idVec3; import neo.idlib.math.Vector.idVec4; +import java.util.HashMap; +import java.util.Map; + /** * */ @@ -59,6 +65,14 @@ public class SecurityCamera { public static final idEventDef EV_SecurityCam_AddLight = new idEventDef(""); public static class idSecurityCamera extends idEntity { + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_SecurityCam_ReverseSweep, (eventCallback_t0) idSecurityCamera::Event_ReverseSweep); + eventCallbacks.put(EV_SecurityCam_ContinueSweep, (eventCallback_t0) idSecurityCamera::Event_ContinueSweep); + eventCallbacks.put(EV_SecurityCam_Pause, (eventCallback_t0) idSecurityCamera::Event_Pause); + eventCallbacks.put(EV_SecurityCam_Alert, (eventCallback_t0) idSecurityCamera::Event_Alert); + eventCallbacks.put(EV_SecurityCam_AddLight, (eventCallback_t0) idSecurityCamera::Event_AddLight); + } private static final int SCANNING = 0; private static final int LOSINGINTEREST = 1; @@ -532,5 +546,10 @@ private void Event_AddLight() { spotLight.Bind(this, true); spotLight.UpdateVisuals(); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/Sound.java b/src/main/java/neo/Game/Sound.java index 56b3cf37..8525ee7f 100644 --- a/src/main/java/neo/Game/Sound.java +++ b/src/main/java/neo/Game/Sound.java @@ -1,9 +1,14 @@ package neo.Game; +import static neo.Game.Entity.EV_Activate; import static neo.Game.Entity.TH_THINK; import static neo.Game.Entity.TH_UPDATEVISUALS; import neo.Game.Entity.idEntity; import neo.Game.GameSys.Class; +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -23,6 +28,9 @@ import static neo.idlib.math.Vector.getVec3_zero; import neo.idlib.math.Vector.idVec3; +import java.util.HashMap; +import java.util.Map; + /** * */ @@ -83,6 +91,14 @@ static class soundShaderParms_t { =============================================================================== */ public static class idSound extends idEntity { + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idSound::Event_Trigger); + eventCallbacks.put(EV_Speaker_On, (eventCallback_t0) idSound::Event_On); + eventCallbacks.put(EV_Speaker_Off, (eventCallback_t0) idSound::Event_Off); + eventCallbacks.put(EV_Speaker_Timer, (eventCallback_t0) idSound::Event_Timer); + } + private float lastSoundVol; private float soundVol; @@ -244,7 +260,7 @@ public void ShowEditingDialog() { this will toggle the idle idSound on and off ================ */ - private void Event_Trigger(idEntity activator) { + private void Event_Trigger(idEventArg activator) { if (wait > 0.0f) { if (timerOn) { timerOn = false; @@ -312,5 +328,10 @@ public Class.idClass CreateInstance() { public java.lang.Class /*idTypeInfo*/ GetType() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/Target.java b/src/main/java/neo/Game/Target.java index d58c7f8a..de99026c 100644 --- a/src/main/java/neo/Game/Target.java +++ b/src/main/java/neo/Game/Target.java @@ -7,7 +7,14 @@ import static neo.Game.Entity.TH_THINK; import neo.Game.Entity.idEntity; import static neo.Game.GameSys.Class.EV_Remove; + +import neo.Game.GameSys.Class; +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.eventCallback_t2; import neo.Game.GameSys.Class.idClass; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -62,6 +69,10 @@ import static neo.idlib.math.Vector.getVec4_zero; import neo.idlib.math.Vector.idVec3; import neo.idlib.math.Vector.idVec4; + +import java.util.HashMap; +import java.util.Map; + import static neo.ui.UserInterface.uiManager; /** @@ -109,8 +120,13 @@ public idClass CreateInstance() { */ public static class idTarget_Remove extends idTarget { // CLASS_PROTOTYPE( idTarget_Remove ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_Remove::Event_Activate); + } + - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { int i; idEntity ent; @@ -125,6 +141,10 @@ private void Event_Activate(idEntity activator) { PostEventMS(EV_Remove, 0); } + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -137,8 +157,13 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_Show extends idTarget { // CLASS_PROTOTYPE( idTarget_Show ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_Show::Event_Activate); + } + - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { int i; idEntity ent; @@ -152,6 +177,11 @@ private void Event_Activate(idEntity activator) { // delete our self when done PostEventMS(EV_Remove, 0); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -164,8 +194,13 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_Damage extends idTarget { // CLASS_PROTOTYPE( idTarget_Damage ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_Damage::Event_Activate); + } + - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { int i; String damage; idEntity ent; @@ -178,6 +213,11 @@ private void Event_Activate(idEntity activator) { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -189,11 +229,20 @@ private void Event_Activate(idEntity activator) { =============================================================================== */ public static class idTarget_SessionCommand extends idTarget { -// CLASS_PROTOTYPE(idTarget_SessionCommand ); + // CLASS_PROTOTYPE(idTarget_SessionCommand ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SessionCommand::Event_Activate); + } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { gameLocal.sessionCommand.oSet(spawnArgs.GetString("command")); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -207,8 +256,13 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_EndLevel extends idTarget { // CLASS_PROTOTYPE( idTarget_EndLevel ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_EndLevel::Event_Activate); + } + - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { String[] nextMap = {null}; if (ID_DEMO_BUILD) { @@ -237,6 +291,11 @@ private void Event_Activate(idEntity activator) { gameLocal.sessionCommand.oPluSet(nextMap[0]); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -249,6 +308,11 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_WaitForButton extends idTarget { // CLASS_PROTOTYPE( idTarget_WaitForButton ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_WaitForButton::Event_Activate); + } + @Override public void Think() { @@ -266,7 +330,7 @@ public void Think() { } } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { if ((thinkFlags & TH_THINK) != 0) { BecomeInactive(TH_THINK); } else { @@ -275,6 +339,11 @@ private void Event_Activate(idEntity activator) { BecomeActive(TH_THINK); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -286,14 +355,24 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_SetGlobalShaderTime extends idTarget { // CLASS_PROTOTYPE( idTarget_SetGlobalShaderTime ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetGlobalShaderTime::Event_Activate); + } - private void Event_Activate(idEntity activator) { + + private void Event_Activate(idEventArg activator) { int parm = spawnArgs.GetInt("globalParm"); float time = -MS2SEC(gameLocal.time); if (parm >= 0 && parm < MAX_GLOBAL_SHADER_PARMS) { gameLocal.globalShaderParms[parm] = time; } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -306,8 +385,13 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_SetShaderParm extends idTarget { // CLASS_PROTOTYPE( idTarget_SetShaderParm ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetShaderParm::Event_Activate); + } + - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { int i; idEntity ent; float[] value = {0}; @@ -342,6 +426,11 @@ private void Event_Activate(idEntity activator) { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -354,8 +443,13 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_SetShaderTime extends idTarget { // CLASS_PROTOTYPE( idTarget_SetShaderTime ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetShaderTime::Event_Activate); + } + - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { int i; idEntity ent; float time; @@ -371,6 +465,11 @@ private void Event_Activate(idEntity activator) { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -382,6 +481,10 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_FadeEntity extends idTarget { // CLASS_PROTOTYPE( idTarget_FadeEntity ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_FadeEntity::Event_Activate); + } private idVec4 fadeFrom; private int fadeStart; @@ -439,7 +542,7 @@ public void Think() { } } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { idEntity ent; int i; @@ -463,6 +566,11 @@ private void Event_Activate(idEntity activator) { fadeStart = gameLocal.time; fadeEnd = (int) (gameLocal.time + SEC2MS(spawnArgs.GetFloat("fadetime"))); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -474,8 +582,13 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_LightFadeIn extends idTarget { // CLASS_PROTOTYPE( idTarget_LightFadeIn ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_LightFadeIn::Event_Activate); + } + - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { idEntity ent; idLight light; int i; @@ -500,6 +613,11 @@ private void Event_Activate(idEntity activator) { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -511,8 +629,13 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_LightFadeOut extends idTarget { // CLASS_PROTOTYPE( idTarget_LightFadeOut ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_LightFadeOut::Event_Activate); + } + - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { idEntity ent; idLight light; int i; @@ -537,6 +660,11 @@ private void Event_Activate(idEntity activator) { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -548,6 +676,11 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_Give extends idTarget { // CLASS_PROTOTYPE( idTarget_Give ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_Give::Event_Activate); + } + @Override public void Spawn() { @@ -557,7 +690,7 @@ public void Spawn() { } private static int giveNum = 0; - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { if (spawnArgs.GetBool("development") && developer.GetInteger() == 0) { return; @@ -582,6 +715,11 @@ private void Event_Activate(idEntity activator) { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -594,8 +732,13 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_GiveEmail extends idTarget { // CLASS_PROTOTYPE( idTarget_GiveEmail ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_GiveEmail::Event_Activate); + } + - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { idPlayer player = gameLocal.GetLocalPlayer(); idDeclPDA pda = player.GetPDA(); if (pda != null) { @@ -604,6 +747,11 @@ private void Event_Activate(idEntity activator) { player.ShowTip(spawnArgs.GetString("text_infoTitle"), spawnArgs.GetString("text_PDANeeded"), true); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -615,6 +763,11 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_SetModel extends idTarget { // CLASS_PROTOTYPE( idTarget_SetModel ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetModel::Event_Activate); + } + @Override public void Spawn() { @@ -629,7 +782,7 @@ public void Spawn() { } } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { for (int i = 0; i < targets.Num(); i++) { idEntity ent = targets.oGet(i).GetEntity(); if (ent != null) { @@ -637,6 +790,11 @@ private void Event_Activate(idEntity activator) { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -648,6 +806,15 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_SetInfluence extends idTarget { // CLASS_PROTOTYPE( idTarget_SetInfluence ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetInfluence::Event_Activate); + eventCallbacks.put(EV_RestoreInfluence, (eventCallback_t0) idTarget_SetInfluence::Event_RestoreInfluence); + eventCallbacks.put(EV_GatherEntities, (eventCallback_t0) idTarget_SetInfluence::Event_GatherEntities); + eventCallbacks.put(EV_Flash, (eventCallback_t2) idTarget_SetInfluence::Event_Flash); + eventCallbacks.put(EV_ClearFlash, (eventCallback_t1) idTarget_SetInfluence::Event_ClearFlash); + } + private idList lightList; private idList guiList; @@ -786,7 +953,7 @@ public void Spawn() { cinematic = true; } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { int i, j; idEntity ent; idLight light; @@ -813,7 +980,7 @@ private void Event_Activate(idEntity activator) { float fadeTime = spawnArgs.GetFloat("fadeWorldSounds"); if (delay > 0.0f) { - PostEventSec(EV_Activate, delay, activator); + PostEventSec(EV_Activate, delay, activator.value); delay = 0.0f; // start any sound fading now if (fadeTime != 0) { @@ -827,7 +994,7 @@ private void Event_Activate(idEntity activator) { } if (spawnArgs.GetBool("triggerTargets")) { - ActivateTargets(activator); + ActivateTargets(activator.value); } if (flashIn != 0) { @@ -1079,7 +1246,9 @@ private void Event_GatherEntities() { } - private void Event_Flash(float flash, int out) { + private void Event_Flash(idEventArg _flash, idEventArg _out) { + float flash = _flash.value; + int out = _out.value; idPlayer player = gameLocal.GetLocalPlayer(); player.playerView.Fade(new idVec4(1, 1, 1, 1), (int) flash); idSoundShader shader; @@ -1093,9 +1262,9 @@ private void Event_Flash(float flash, int out) { PostEventSec(EV_ClearFlash, flash, flash); } - private void Event_ClearFlash(float flash) { + private void Event_ClearFlash(idEventArg flash) { idPlayer player = gameLocal.GetLocalPlayer(); - player.playerView.Fade(getVec4_zero(), (int) flash); + player.playerView.Fade(getVec4_zero(), flash.value.intValue()); } @Override @@ -1113,9 +1282,12 @@ public void Think() { BecomeInactive(TH_ALL); } } - } - ; + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } + }; /* @@ -1127,8 +1299,13 @@ public void Think() { */ public static class idTarget_SetKeyVal extends idTarget { // CLASS_PROTOTYPE( idTarget_SetKeyVal ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetKeyVal::Event_Activate); + } + - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { int i; String key, val; idEntity ent; @@ -1162,9 +1339,12 @@ private void Event_Activate(idEntity activator) { } } } - } - ; + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } + }; /* @@ -1176,6 +1356,11 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_SetFov extends idTarget { // CLASS_PROTOTYPE( idTarget_SetFov ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetFov::Event_Activate); + } + private idInterpolate fovSetting; // @@ -1220,7 +1405,7 @@ public void Think() { } } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { // always allow during cinematics cinematic = true; @@ -1228,9 +1413,12 @@ private void Event_Activate(idEntity activator) { fovSetting.Init(gameLocal.time, (float) SEC2MS(spawnArgs.GetFloat("time")), (int) (player != null ? player.DefaultFov() : g_fov.GetFloat()), (int) spawnArgs.GetFloat("fov")); BecomeActive(TH_THINK); } - } - ; + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } + }; /* @@ -1241,18 +1429,25 @@ private void Event_Activate(idEntity activator) { =============================================================================== */ public static class idTarget_SetPrimaryObjective extends idTarget { -// public: // CLASS_PROTOTYPE( idTarget_SetPrimaryObjective ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetPrimaryObjective::Event_Activate); + } + - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { idPlayer player = gameLocal.GetLocalPlayer(); if (player != null && player.objectiveSystem != null) { player.objectiveSystem.SetStateString("missionobjective", spawnArgs.GetString("text", common.GetLanguageDict().GetString("#str_04253"))); } } - } - ; + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } + }; /* =============================================================================== @@ -1262,10 +1457,14 @@ private void Event_Activate(idEntity activator) { =============================================================================== */ public static class idTarget_LockDoor extends idTarget { -// public: // CLASS_PROTOTYPE( idTarget_LockDoor ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_LockDoor::Event_Activate); + } - private void Event_Activate(idEntity activator) { + + private void Event_Activate(idEventArg activator) { int i; idEntity ent; int lock; @@ -1282,6 +1481,11 @@ private void Event_Activate(idEntity activator) { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1292,10 +1496,14 @@ private void Event_Activate(idEntity activator) { =============================================================================== */ public static class idTarget_CallObjectFunction extends idTarget { -// public: // CLASS_PROTOTYPE( idTarget_CallObjectFunction ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_CallObjectFunction::Event_Activate); + } + - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { int i; idEntity ent; function_t func; @@ -1323,6 +1531,11 @@ private void Event_Activate(idEntity activator) { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -1335,8 +1548,13 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_EnableLevelWeapons extends idTarget { // CLASS_PROTOTYPE( idTarget_EnableLevelWeapons ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_EnableLevelWeapons::Event_Activate); + } - private void Event_Activate(idEntity activator) { + + private void Event_Activate(idEventArg activator) { int i; String weap; @@ -1360,6 +1578,11 @@ private void Event_Activate(idEntity activator) { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1371,6 +1594,14 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_Tip extends idTarget { // CLASS_PROTOTYPE( idTarget_Tip ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_Tip::Event_Activate); + eventCallbacks.put(EV_TipOff, (eventCallback_t0) idTarget_Tip::Event_TipOff); + eventCallbacks.put(EV_GetPlayerPos, (eventCallback_t0) idTarget_Tip::Event_GetPlayerPos); + } + + private idVec3 playerPos; // // @@ -1389,11 +1620,11 @@ public void Restore(idRestoreGame savefile) { savefile.ReadVec3(playerPos); } - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { idPlayer player = gameLocal.GetLocalPlayer(); if (player != null) { if (player.IsTipVisible()) { - PostEventSec(EV_Activate, 5.1f, activator); + PostEventSec(EV_Activate, 5.1f, activator.value); return; } player.ShowTip(spawnArgs.GetString("text_title"), spawnArgs.GetString("text_tip"), false); @@ -1420,6 +1651,11 @@ private void Event_GetPlayerPos() { PostEventMS(EV_TipOff, 100); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1431,13 +1667,23 @@ private void Event_GetPlayerPos() { */ public static class idTarget_GiveSecurity extends idTarget { // CLASS_PROTOTYPE( idTarget_GiveSecurity ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_GiveSecurity::Event_Activate); + } + - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { idPlayer player = gameLocal.GetLocalPlayer(); if (player != null) { player.GiveSecurity(spawnArgs.GetString("text_security")); } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -1450,8 +1696,13 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_RemoveWeapons extends idTarget { // CLASS_PROTOTYPE( idTarget_RemoveWeapons ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_RemoveWeapons::Event_Activate); + } - private void Event_Activate(idEntity activator) { + + private void Event_Activate(idEventArg activator) { for (int i = 0; i < gameLocal.numClients; i++) { if (gameLocal.entities[ i] != null) { idPlayer player = (idPlayer) gameLocal.entities[i]; @@ -1464,6 +1715,11 @@ private void Event_Activate(idEntity activator) { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -1476,8 +1732,13 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_LevelTrigger extends idTarget { // CLASS_PROTOTYPE( idTarget_LevelTrigger );//TODO:understand this fucking macro + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_LevelTrigger::Event_Activate); + } - private void Event_Activate(idEntity activator) { + + private void Event_Activate(idEventArg activator) { for (int i = 0; i < gameLocal.numClients; i++) { if (gameLocal.entities[ i] != null) { idPlayer player = (idPlayer) gameLocal.entities[i]; @@ -1485,6 +1746,11 @@ private void Event_Activate(idEntity activator) { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1496,8 +1762,13 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_EnableStamina extends idTarget { // CLASS_PROTOTYPE( idTarget_EnableStamina ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_EnableStamina::Event_Activate); + } + - private void Event_Activate(idEntity activator) { + private void Event_Activate(idEventArg activator) { for (int i = 0; i < gameLocal.numClients; i++) { if (gameLocal.entities[ i] != null) { idPlayer player = (idPlayer) gameLocal.entities[i]; @@ -1509,6 +1780,11 @@ private void Event_Activate(idEntity activator) { } } } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -1520,8 +1796,14 @@ private void Event_Activate(idEntity activator) { */ public static class idTarget_FadeSoundClass extends idTarget { // CLASS_PROTOTYPE( idTarget_FadeSoundClass ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_FadeSoundClass::Event_Activate); + eventCallbacks.put(EV_RestoreVolume, (eventCallback_t0) idTarget_FadeSoundClass::Event_RestoreVolume); + } - private void Event_Activate(idEntity activator) { + + private void Event_Activate(idEventArg activator) { float fadeTime = spawnArgs.GetFloat("fadeTime"); float fadeDB = spawnArgs.GetFloat("fadeDB"); float fadeDuration = spawnArgs.GetFloat("fadeDuration"); @@ -1542,5 +1824,10 @@ private void Event_RestoreVolume() { // restore volume gameSoundWorld.FadeSoundClasses(0, fadeDB, fadeTime); } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/Trigger.java b/src/main/java/neo/Game/Trigger.java index 2ae54698..9bac0981 100644 --- a/src/main/java/neo/Game/Trigger.java +++ b/src/main/java/neo/Game/Trigger.java @@ -1,11 +1,21 @@ package neo.Game; import neo.CM.CollisionModel.trace_s; + +import static neo.Game.Entity.EV_Activate; import static neo.Game.Entity.EV_ActivateTargets; +import static neo.Game.Entity.EV_Touch; import static neo.Game.Entity.TH_THINK; import neo.Game.Entity.idEntity; import static neo.Game.GameSys.Class.EV_Remove; + +import neo.Game.GameSys.Class; +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.eventCallback_t2; import neo.Game.GameSys.Class.idClass; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; import neo.Game.GameSys.SaveGame.idSaveGame; @@ -36,6 +46,9 @@ import neo.idlib.math.Vector.idVec3; import neo.idlib.math.Vector.idVec4; +import java.util.HashMap; +import java.util.Map; + /** * */ @@ -57,6 +70,13 @@ public class Trigger { public static class idTrigger extends idEntity { // CLASS_PROTOTYPE( idTrigger ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Enable, (eventCallback_t0) idTrigger::Event_Enable); + eventCallbacks.put(EV_Disable, (eventCallback_t0) idTrigger::Event_Disable); + + } + protected function_t scriptFunction; // @@ -215,6 +235,11 @@ public idClass CreateInstance() { public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; /* @@ -226,13 +251,20 @@ public void oSet(idClass oGet) { */ public static class idTrigger_Multi extends idTrigger { // CLASS_PROTOTYPE( idTrigger_Multi ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Touch, (eventCallback_t2) idTrigger_Multi::Event_Touch); + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTrigger_Multi::Event_Trigger); + eventCallbacks.put(EV_TriggerAction, (eventCallback_t1) idTrigger_Multi::Event_TriggerAction); + } - private float wait; - private float random; - private float delay; - private float random_delay; - private int nextTriggerTime; - private idStr requires = new idStr(); + + private float wait; + private float random; + private float delay; + private float random_delay; + private int nextTriggerTime; + private idStr requires = new idStr(); private int removeItem; private boolean touchClient; private boolean touchOther; @@ -372,8 +404,8 @@ private void TriggerAction(idEntity activator) { } } - private void Event_TriggerAction(idEntity activator) { - TriggerAction(activator); + private void Event_TriggerAction(idEventArg activator) { + TriggerAction(activator.value); } /* @@ -386,7 +418,8 @@ activated should be the entity that originated the activation sequence (ie. the so wait for the delay time before firing ================ */ - private void Event_Trigger(idEntity activator) { + private void Event_Trigger(idEventArg _activator) { + idEntity activator = _activator.value; if (nextTriggerTime > gameLocal.time) { // can't retrigger until the wait is over return; @@ -418,7 +451,8 @@ private void Event_Trigger(idEntity activator) { } } - private void Event_Touch(idEntity other, trace_s trace) { + private void Event_Touch(idEventArg _other, idEventArg trace) { + idEntity other = _other.value; if (triggerFirst) { return; } @@ -467,9 +501,12 @@ private void Event_Touch(idEntity other, trace_s trace) { public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } - } - ; + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } + }; /* @@ -480,7 +517,14 @@ public void oSet(idClass oGet) { =============================================================================== */ public static class idTrigger_EntityName extends idTrigger { -// CLASS_PROTOTYPE(idTrigger_EntityName ); + //CLASS_PROTOTYPE(idTrigger_EntityName ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Touch, (eventCallback_t2) idTrigger_EntityName::Event_Touch); + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTrigger_EntityName::Event_Trigger); + eventCallbacks.put(EV_TriggerAction, (eventCallback_t1) idTrigger_EntityName::Event_TriggerAction); + } + private float wait; private float random; @@ -488,7 +532,7 @@ public static class idTrigger_EntityName extends idTrigger { private float random_delay; private int nextTriggerTime; private boolean triggerFirst; - private idStr entityName = new idStr(); + private idStr entityName = new idStr(); // // @@ -568,8 +612,8 @@ private void TriggerAction(idEntity activator) { } } - private void Event_TriggerAction(idEntity activator) { - TriggerAction(activator); + private void Event_TriggerAction(idEventArg activator) { + TriggerAction(activator.value); } @@ -582,7 +626,8 @@ activated should be the entity that originated the activation sequence (ie. the activator should be set to the activator so it can be held through a delay so wait for the delay time before firing ================ - */ private void Event_Trigger(idEntity activator) { + */ private void Event_Trigger(idEventArg _activator) { + idEntity activator = _activator.value; if (nextTriggerTime > gameLocal.time) { // can't retrigger until the wait is over return; @@ -609,7 +654,8 @@ activated should be the entity that originated the activation sequence (ie. the } } - private void Event_Touch(idEntity other, trace_s trace) { + private void Event_Touch(idEventArg _other, idEventArg trace) { + idEntity other = _other.value; if (triggerFirst) { return; } @@ -637,6 +683,11 @@ private void Event_Touch(idEntity other, trace_s trace) { public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -648,14 +699,20 @@ public void oSet(idClass oGet) { =============================================================================== */ public static class idTrigger_Timer extends idTrigger { -// CLASS_PROTOTYPE(idTrigger_Timer ); + // CLASS_PROTOTYPE(idTrigger_Timer ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Timer, (eventCallback_t0) idTrigger_Timer::Event_Timer); + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTrigger_Timer::Event_Use); + } - private float random; - private float wait; + + private float random; + private float wait; private boolean on; - private float delay; - private idStr onName = new idStr(); - private idStr offName = new idStr(); + private float delay; + private idStr onName = new idStr(); + private idStr offName = new idStr(); // // @@ -740,7 +797,8 @@ private void Event_Timer() { } } - private void Event_Use(idEntity activator) { + private void Event_Use(idEventArg _activator) { + idEntity activator = _activator.value; // if on, turn it off if (on) { if (offName.Length() != 0 && offName.Icmp(activator.GetName()) != 0) { @@ -762,6 +820,11 @@ private void Event_Use(idEntity activator) { public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -773,7 +836,13 @@ public void oSet(idClass oGet) { =============================================================================== */ public static class idTrigger_Count extends idTrigger { -// CLASS_PROTOTYPE(idTrigger_Count ); + // CLASS_PROTOTYPE(idTrigger_Count ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTrigger_Count::Event_Trigger); + eventCallbacks.put(EV_TriggerAction, (eventCallback_t1) idTrigger_Count::Event_TriggerAction); + } + private int goal; private int count; @@ -810,7 +879,7 @@ public void Spawn() { count = 0; } - private void Event_Trigger(idEntity activator) { + private void Event_Trigger(idEventArg activator) { // goal of -1 means trigger has been exhausted if (goal >= 0) { count++; @@ -820,13 +889,13 @@ private void Event_Trigger(idEntity activator) { } else { goal = -1; } - PostEventSec(EV_TriggerAction, delay, activator); + PostEventSec(EV_TriggerAction, delay, activator.value); } } } - private void Event_TriggerAction(idEntity activator) { - ActivateTargets(activator); + private void Event_TriggerAction(idEventArg activator) { + ActivateTargets(activator.value); CallScript(); if (goal == -1) { PostEventMS(EV_Remove, 0); @@ -837,6 +906,11 @@ private void Event_TriggerAction(idEntity activator) { public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -848,11 +922,17 @@ public void oSet(idClass oGet) { =============================================================================== */ static class idTrigger_Hurt extends idTrigger { -// CLASS_PROTOTYPE(idTrigger_Hurt ); + // CLASS_PROTOTYPE(idTrigger_Hurt ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Touch, (eventCallback_t2) idTrigger_Hurt::Event_Touch); + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTrigger_Hurt::Event_Toggle); + } + private boolean on; - private float delay; - private int nextTime; + private float delay; + private int nextTime; // // @@ -894,7 +974,8 @@ public void Spawn() { Enable(); } - private void Event_Touch(idEntity other, trace_s trace) { + private void Event_Touch(idEventArg _other, idEventArg trace) { + idEntity other = _other.value; final String damage; if (on && other != null && gameLocal.time >= nextTime) { @@ -908,7 +989,7 @@ private void Event_Touch(idEntity other, trace_s trace) { } } - private void Event_Toggle(idEntity activator) { + private void Event_Toggle(idEventArg activator) { on = !on; } @@ -916,6 +997,11 @@ private void Event_Toggle(idEntity activator) { public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -928,8 +1014,13 @@ public void oSet(idClass oGet) { */ public static class idTrigger_Fade extends idTrigger { // CLASS_PROTOTYPE( idTrigger_Fade ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTrigger_Fade::Event_Trigger); + } + - private void Event_Trigger(idEntity activator) { + private void Event_Trigger(idEventArg activator) { idVec4 fadeColor; int fadeTime; idPlayer player; @@ -939,7 +1030,7 @@ private void Event_Trigger(idEntity activator) { fadeColor = spawnArgs.GetVec4("fadeColor", "0, 0, 0, 1"); fadeTime = (int) SEC2MS(spawnArgs.GetFloat("fadeTime", "0.5")); player.playerView.Fade(fadeColor, fadeTime); - PostEventMS(EV_ActivateTargets, fadeTime, activator); + PostEventMS(EV_ActivateTargets, fadeTime, activator.value); } } @@ -947,6 +1038,11 @@ private void Event_Trigger(idEntity activator) { public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; @@ -959,6 +1055,11 @@ public void oSet(idClass oGet) { */ public static class idTrigger_Touch extends idTrigger { // CLASS_PROTOTYPE( idTrigger_Touch ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Activate, (eventCallback_t1) idTrigger_Touch::Event_Trigger); + } + private idClipModel clipModel; // @@ -1048,7 +1149,7 @@ public void TouchEntities() { } } - private void Event_Trigger(idEntity activator) { + private void Event_Trigger(idEventArg activator) { if ((thinkFlags & TH_THINK) != 0) { BecomeInactive(TH_THINK); } else { @@ -1060,5 +1161,10 @@ private void Event_Trigger(idEntity activator) { public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/Weapon.java b/src/main/java/neo/Game/Weapon.java index 0f45b4f7..982de0dc 100644 --- a/src/main/java/neo/Game/Weapon.java +++ b/src/main/java/neo/Game/Weapon.java @@ -1,18 +1,36 @@ package neo.Game; import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Map; + import neo.CM.CollisionModel.trace_s; import neo.CM.CollisionModel_local; import neo.Game.AFEntity.idAFAttachment; import neo.Game.AI.AI.idAI; import neo.Game.Actor.idActor; + +import static neo.Game.Actor.AI_AnimDone; +import static neo.Game.Actor.AI_GetBlendFrames; +import static neo.Game.Actor.AI_PlayAnim; +import static neo.Game.Actor.AI_PlayCycle; +import static neo.Game.Actor.AI_SetBlendFrames; import static neo.Game.Animation.Anim.FRAME2MS; +import static neo.Game.Entity.EV_SetSkin; import static neo.Game.Entity.EV_Touch; import neo.Game.Entity.idAnimatedEntity; import neo.Game.Entity.idEntity; import static neo.Game.Entity.signalNum_t.SIG_TOUCH; import neo.Game.Game.refSound_t; +import neo.Game.GameSys.Class; +import neo.Game.GameSys.Class.eventCallback_t; +import neo.Game.GameSys.Class.eventCallback_t0; +import neo.Game.GameSys.Class.eventCallback_t1; +import neo.Game.GameSys.Class.eventCallback_t2; +import neo.Game.GameSys.Class.eventCallback_t4; +import neo.Game.GameSys.Class.eventCallback_t5; import neo.Game.GameSys.Class.idClass; +import neo.Game.GameSys.Class.idEventArg; import neo.Game.GameSys.Class.idTypeInfo; import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; @@ -33,6 +51,10 @@ import static neo.Game.Game_local.gameState_t.GAMESTATE_SHUTDOWN; import neo.Game.Game_local.idEntityPtr; import neo.Game.Item.idMoveableItem; + +import static neo.Game.Light.EV_Light_GetLightParm; +import static neo.Game.Light.EV_Light_SetLightParm; +import static neo.Game.Light.EV_Light_SetLightParms; import static neo.Game.MultiplayerGame.gameType_t.GAME_TDM; import static neo.Game.Player.ASYNC_PLAYER_INV_CLIP_BITS; import static neo.Game.Player.BERSERK; @@ -170,6 +192,46 @@ public enum weaponStatus_t { ***********************************************************************/ public static class idWeapon extends idAnimatedEntity { // CLASS_PROTOTYPE( idWeapon ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Weapon_Clear, (eventCallback_t0) idWeapon::Event_Clear); + eventCallbacks.put(EV_Weapon_GetOwner, (eventCallback_t0) idWeapon::Event_GetOwner); + eventCallbacks.put(EV_Weapon_State, (eventCallback_t2) idWeapon::Event_WeaponState); + eventCallbacks.put(EV_Weapon_WeaponReady, (eventCallback_t0) idWeapon::Event_WeaponReady); + eventCallbacks.put(EV_Weapon_WeaponOutOfAmmo, (eventCallback_t0) idWeapon::Event_WeaponOutOfAmmo); + eventCallbacks.put(EV_Weapon_WeaponReloading, (eventCallback_t0) idWeapon::Event_WeaponReloading); + eventCallbacks.put(EV_Weapon_WeaponHolstered, (eventCallback_t0) idWeapon::Event_WeaponHolstered); + eventCallbacks.put(EV_Weapon_WeaponRising, (eventCallback_t0) idWeapon::Event_WeaponRising); + eventCallbacks.put(EV_Weapon_WeaponLowering, (eventCallback_t0) idWeapon::Event_WeaponLowering); + eventCallbacks.put(EV_Weapon_UseAmmo, (eventCallback_t1) idWeapon::Event_UseAmmo); + eventCallbacks.put(EV_Weapon_AddToClip, (eventCallback_t1) idWeapon::Event_AddToClip); + eventCallbacks.put(EV_Weapon_AmmoInClip, (eventCallback_t0) idWeapon::Event_AmmoInClip); + eventCallbacks.put(EV_Weapon_AmmoAvailable, (eventCallback_t0) idWeapon::Event_AmmoAvailable); + eventCallbacks.put(EV_Weapon_TotalAmmoCount, (eventCallback_t0) idWeapon::Event_TotalAmmoCount); + eventCallbacks.put(EV_Weapon_ClipSize, (eventCallback_t0) idWeapon::Event_ClipSize); + eventCallbacks.put(AI_PlayAnim, (eventCallback_t2) idWeapon::Event_PlayAnim); + eventCallbacks.put(AI_PlayCycle, (eventCallback_t2) idWeapon::Event_PlayCycle); + eventCallbacks.put(AI_SetBlendFrames, (eventCallback_t2) idWeapon::Event_SetBlendFrames); + eventCallbacks.put(AI_GetBlendFrames, (eventCallback_t1) idWeapon::Event_GetBlendFrames); + eventCallbacks.put(AI_AnimDone, (eventCallback_t2) idWeapon::Event_AnimDone); + eventCallbacks.put(EV_Weapon_Next, (eventCallback_t0) idWeapon::Event_Next); + eventCallbacks.put(EV_SetSkin, (eventCallback_t1) idWeapon::Event_SetSkin); + eventCallbacks.put(EV_Weapon_Flashlight, (eventCallback_t1) idWeapon::Event_Flashlight); + eventCallbacks.put(EV_Light_GetLightParm, (eventCallback_t1) idWeapon::Event_GetLightParm); + eventCallbacks.put(EV_Light_SetLightParm, (eventCallback_t2) idWeapon::Event_SetLightParm); + eventCallbacks.put(EV_Light_SetLightParms, (eventCallback_t4) idWeapon::Event_SetLightParms); + eventCallbacks.put(EV_Weapon_LaunchProjectiles, (eventCallback_t5) idWeapon::Event_LaunchProjectiles); + eventCallbacks.put(EV_Weapon_CreateProjectile, (eventCallback_t0) idWeapon::Event_CreateProjectile); + eventCallbacks.put(EV_Weapon_EjectBrass, (eventCallback_t0) idWeapon::Event_EjectBrass); + eventCallbacks.put(EV_Weapon_Melee, (eventCallback_t0) idWeapon::Event_Melee); + eventCallbacks.put(EV_Weapon_GetWorldModel, (eventCallback_t0) idWeapon::Event_GetWorldModel); + eventCallbacks.put(EV_Weapon_AllowDrop, (eventCallback_t1) idWeapon::Event_AllowDrop); + eventCallbacks.put(EV_Weapon_AutoReload, (eventCallback_t0) idWeapon::Event_AutoReload); + eventCallbacks.put(EV_Weapon_NetReload, (eventCallback_t0) idWeapon::Event_NetReload); + eventCallbacks.put(EV_Weapon_IsInvisible, (eventCallback_t0) idWeapon::Event_IsInvisible); + eventCallbacks.put(EV_Weapon_NetEndReload, (eventCallback_t0) idWeapon::Event_NetEndReload); + } + // script control private idScriptBool WEAPON_ATTACK = new idScriptBool(); @@ -2286,7 +2348,8 @@ private void Event_GetOwner() { idThread.ReturnEntity(owner); } - private void Event_WeaponState(final String statename, int blendFrames) { + private void Event_WeaponState(final idEventArg _statename, idEventArg blendFrames) { + String statename = _statename.value; function_t func; func = scriptObject.GetFunction(statename); @@ -2303,7 +2366,7 @@ private void Event_WeaponState(final String statename, int blendFrames) { isFiring = false; } - animBlendFrames = blendFrames; + animBlendFrames = blendFrames.value; thread.DoneProcessing(); } // @@ -2355,7 +2418,8 @@ private void Event_WeaponLowering() { owner.WeaponLoweringCallback(); } - private void Event_UseAmmo(int amount) { + private void Event_UseAmmo(idEventArg _amount) { + int amount = _amount.value; if (gameLocal.isClient) { return; } @@ -2369,14 +2433,14 @@ private void Event_UseAmmo(int amount) { } } - private void Event_AddToClip(int amount) { + private void Event_AddToClip(idEventArg amount) { int ammoAvail; if (gameLocal.isClient) { return; } - ammoClip += amount; + ammoClip += amount.value; if (ammoClip > clipSize) { ammoClip = clipSize; } @@ -2406,7 +2470,9 @@ private void Event_ClipSize() { idThread.ReturnFloat(clipSize); } - private void Event_PlayAnim(int channel, final String animname) { + private void Event_PlayAnim(idEventArg _channel, final idEventArg _animname) { + int channel = _channel.value; + String animname = _animname.value; int anim; anim = animator.GetAnim(animname); @@ -2431,7 +2497,9 @@ private void Event_PlayAnim(int channel, final String animname) { idThread.ReturnInt(0); } - private void Event_PlayCycle(int channel, final String animname) { + private void Event_PlayCycle(idEventArg _channel, final idEventArg _animname) { + int channel = _channel.value; + String animname = _animname.value; int anim; anim = animator.GetAnim(animname); @@ -2454,19 +2522,19 @@ private void Event_PlayCycle(int channel, final String animname) { idThread.ReturnInt(0); } - private void Event_AnimDone(int channel, int blendFrames) { - if (animDoneTime - FRAME2MS(blendFrames) <= gameLocal.time) { + private void Event_AnimDone(idEventArg channel, idEventArg blendFrames) { + if (animDoneTime - FRAME2MS(blendFrames.value) <= gameLocal.time) { idThread.ReturnInt(true); } else { idThread.ReturnInt(false); } } - private void Event_SetBlendFrames(int channel, int blendFrames) { - animBlendFrames = blendFrames; + private void Event_SetBlendFrames(idEventArg channel, idEventArg blendFrames) { + animBlendFrames = blendFrames.value; } - private void Event_GetBlendFrames(int channel) { + private void Event_GetBlendFrames(idEventArg channel) { idThread.ReturnInt(animBlendFrames); } @@ -2475,7 +2543,8 @@ private void Event_Next() { owner.NextBestWeapon(); } - private void Event_SetSkin(final String skinname) { + private void Event_SetSkin(final idEventArg _skinname) { + String skinname = _skinname.value; idDeclSkin skinDecl; if (!isNotNullOrEmpty(skinname)) { @@ -2501,8 +2570,8 @@ private void Event_SetSkin(final String skinname) { } } - private void Event_Flashlight(int enable) { - if (enable != 0) { + private void Event_Flashlight(idEventArg enable) { + if (enable.value != 0) { lightOn = true; MuzzleFlashLight(); } else { @@ -2511,7 +2580,8 @@ private void Event_Flashlight(int enable) { } } - private void Event_GetLightParm(int parmnum) { + private void Event_GetLightParm(idEventArg _parmnum) { + int parmnum = _parmnum.value; if ((parmnum < 0) || (parmnum >= MAX_ENTITY_SHADER_PARMS)) { gameLocal.Error("shader parm index (%d) out of range", parmnum); } @@ -2519,7 +2589,9 @@ private void Event_GetLightParm(int parmnum) { idThread.ReturnFloat(muzzleFlash.shaderParms[ parmnum]); } - private void Event_SetLightParm(int parmnum, float value) { + private void Event_SetLightParm(idEventArg _parmnum, idEventArg _value) { + int parmnum = _parmnum.value; + float value = _value.value; if ((parmnum < 0) || (parmnum >= MAX_ENTITY_SHADER_PARMS)) { gameLocal.Error("shader parm index (%d) out of range", parmnum); } @@ -2529,21 +2601,24 @@ private void Event_SetLightParm(int parmnum, float value) { UpdateVisuals(); } - private void Event_SetLightParms(float parm0, float parm1, float parm2, float parm3) { - muzzleFlash.shaderParms[ SHADERPARM_RED] = parm0; - muzzleFlash.shaderParms[ SHADERPARM_GREEN] = parm1; - muzzleFlash.shaderParms[ SHADERPARM_BLUE] = parm2; - muzzleFlash.shaderParms[ SHADERPARM_ALPHA] = parm3; + private void Event_SetLightParms(idEventArg parm0, idEventArg parm1, idEventArg parm2, idEventArg parm3) { + muzzleFlash.shaderParms[SHADERPARM_RED] = parm0.value; + muzzleFlash.shaderParms[SHADERPARM_GREEN] = parm1.value; + muzzleFlash.shaderParms[SHADERPARM_BLUE] = parm2.value; + muzzleFlash.shaderParms[SHADERPARM_ALPHA] = parm3.value; - worldMuzzleFlash.shaderParms[ SHADERPARM_RED] = parm0; - worldMuzzleFlash.shaderParms[ SHADERPARM_GREEN] = parm1; - worldMuzzleFlash.shaderParms[ SHADERPARM_BLUE] = parm2; - worldMuzzleFlash.shaderParms[ SHADERPARM_ALPHA] = parm3; + worldMuzzleFlash.shaderParms[SHADERPARM_RED] = parm0.value; + worldMuzzleFlash.shaderParms[SHADERPARM_GREEN] = parm1.value; + worldMuzzleFlash.shaderParms[SHADERPARM_BLUE] = parm2.value; + worldMuzzleFlash.shaderParms[SHADERPARM_ALPHA] = parm3.value; UpdateVisuals(); } - private void Event_LaunchProjectiles(int num_projectiles, float spread, float fuseOffset, float launchPower, float dmgPower) { + private void Event_LaunchProjectiles(idEventArg _num_projectiles, idEventArg _spread, idEventArg fuseOffset, idEventArg launchPower, idEventArg _dmgPower) { + int num_projectiles = _num_projectiles.value; + float spread = _spread.value; + float dmgPower = _dmgPower.value; idProjectile proj; idEntity[] ent = {null}; int i; @@ -2697,7 +2772,7 @@ private void Event_LaunchProjectiles(int num_projectiles, float spread, float fu muzzle_pos = tr[0].endpos; } - proj.Launch(muzzle_pos, dir, pushVelocity, fuseOffset, launchPower, dmgPower); + proj.Launch(muzzle_pos, dir, pushVelocity, fuseOffset.value, launchPower.value, dmgPower); } // toss the brass @@ -2891,8 +2966,8 @@ private void Event_GetWorldModel() { idThread.ReturnEntity(worldModel.GetEntity()); } - private void Event_AllowDrop(int allow) { - allowDrop = (allow != 0); + private void Event_AllowDrop(idEventArg allow) { + allowDrop = (allow.value != 0); } private void Event_AutoReload() { @@ -2930,5 +3005,10 @@ private void Event_NetEndReload() { public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/main/java/neo/Game/WorldSpawn.java b/src/main/java/neo/Game/WorldSpawn.java index 691e7053..7c5d2450 100644 --- a/src/main/java/neo/Game/WorldSpawn.java +++ b/src/main/java/neo/Game/WorldSpawn.java @@ -1,8 +1,13 @@ package neo.Game; import neo.Game.Entity.idEntity; +import neo.Game.GameSys.Class; import neo.Game.GameSys.Class.idClass; +import neo.Game.GameSys.Event; +import neo.Game.GameSys.Event.idEventDef; import neo.Game.GameSys.SaveGame.idRestoreGame; + +import static neo.Game.GameSys.Class.*; import static neo.Game.GameSys.SysCvar.g_gravity; import static neo.Game.GameSys.SysCvar.pm_stamina; import static neo.Game.Game_local.DEFAULT_GRAVITY; @@ -12,6 +17,10 @@ import static neo.framework.FileSystem_h.fileSystem; import neo.idlib.Dict_h.idKeyValue; import neo.idlib.Text.Str.idStr; + +import java.util.HashMap; +import java.util.Map; + import static neo.idlib.Text.Str.va; /* @@ -32,9 +41,16 @@ public class WorldSpawn { =============================================================================== */ public static class idWorldspawn extends idEntity { -// CLASS_PROTOTYPE( idWorldspawn ); + // CLASS_PROTOTYPE( idWorldspawn ); + private static Map eventCallbacks = new HashMap<>(); + static { + eventCallbacks.put(EV_Remove, (eventCallback_t0) idWorldspawn::Event_Remove); + eventCallbacks.put(EV_SafeRemove, (eventCallback_t0) idWorldspawn::Event_Remove); + } + -// ~idWorldspawn(); + + // ~idWorldspawn(); @Override public void Spawn() { super.Spawn(); @@ -116,5 +132,10 @@ public idClass CreateInstance() { public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + + @Override + public eventCallback_t getEventCallBack(idEventDef event) { + return eventCallbacks.get(event); + } }; } diff --git a/src/misc/bug_report_04.txt b/src/misc/bug_report_04.txt index 5d8a5640..ad85b98f 100644 --- a/src/misc/bug_report_04.txt +++ b/src/misc/bug_report_04.txt @@ -133,3 +133,7 @@ neo.Renderer.VertexCache$vertCache_s@4816c290 -idPlayer::UpdateViewAngles() :disables our mouse powers -idPlayer::GetViewPos() :screen almost looks identical to ours -idPlayerStart::Event_TeleportPlayer() + -idCameraAnim::Start() + -idEntity::TouchTriggers() + -idEntity::ActivateTargets() empty targets? + -idEntity::Event_FindTargets() From 79c8d5d6d9cd8c18b0f98078570fe957802de622 Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Fri, 20 May 2016 03:38:29 +0200 Subject: [PATCH 12/17] events are loaded in the 'correct' inherited order now, plus some fixes here and there --- src/main/java/neo/Game/AFEntity.java | 29 +++ src/main/java/neo/Game/AI/AI.java | 12 ++ src/main/java/neo/Game/AI/AI_Vagary.java | 6 + src/main/java/neo/Game/Actor.java | 6 + .../neo/Game/Animation/Anim_Testmodel.java | 6 + src/main/java/neo/Game/BrittleFracture.java | 6 + src/main/java/neo/Game/Camera.java | 12 ++ src/main/java/neo/Game/Entity.java | 11 ++ src/main/java/neo/Game/FX.java | 12 ++ src/main/java/neo/Game/GameSys/Class.java | 11 +- src/main/java/neo/Game/Item.java | 30 ++++ src/main/java/neo/Game/Light.java | 6 + src/main/java/neo/Game/Misc.java | 127 +++++++++++++ src/main/java/neo/Game/Moveable.java | 40 +++-- src/main/java/neo/Game/Mover.java | 48 +++++ src/main/java/neo/Game/Player.java | 6 + src/main/java/neo/Game/Projectile.java | 18 ++ .../java/neo/Game/Script/Script_Thread.java | 5 + src/main/java/neo/Game/SecurityCamera.java | 6 + src/main/java/neo/Game/Sound.java | 6 + src/main/java/neo/Game/Target.java | 168 ++++++++++++++++++ src/main/java/neo/Game/Trigger.java | 48 +++++ src/main/java/neo/Game/Weapon.java | 6 + src/main/java/neo/Game/WorldSpawn.java | 6 + 24 files changed, 614 insertions(+), 17 deletions(-) diff --git a/src/main/java/neo/Game/AFEntity.java b/src/main/java/neo/Game/AFEntity.java index ec67a7b4..151a0459 100644 --- a/src/main/java/neo/Game/AFEntity.java +++ b/src/main/java/neo/Game/AFEntity.java @@ -505,6 +505,7 @@ public static class idAFEntity_Base extends idAnimatedEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idAnimatedEntity.getEventCallBacks()); eventCallbacks.put(EV_SetConstraintPosition, (eventCallback_t2) idAFEntity_Base::Event_SetConstraintPosition); } @@ -815,6 +816,10 @@ protected void Event_SetConstraintPosition(final idEventArg name, final public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } }; /* =============================================================================== @@ -829,6 +834,7 @@ public static class idAFEntity_Gibbable extends idAFEntity_Base { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idAFEntity_Base.getEventCallBacks()); eventCallbacks.put(EV_Gib, (eventCallback_t1) idAFEntity_Gibbable::Event_Gib); eventCallbacks.put(EV_Gibbed, (eventCallback_t0) idAFEntity_Base::Event_Remove); } @@ -1054,6 +1060,11 @@ public final boolean idAFEntity_Base_UpdateAnimationControllers() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1068,6 +1079,7 @@ public static class idAFEntity_Generic extends idAFEntity_Gibbable { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idAFEntity_Gibbable.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idAFEntity_Generic::Event_Activate); } @@ -1154,6 +1166,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1168,6 +1185,7 @@ public static class idAFEntity_WithAttachedHead extends idAFEntity_Gibbable { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idAFEntity_Gibbable.getEventCallBacks()); eventCallbacks.put(EV_Gib, (eventCallback_t1) idAFEntity_WithAttachedHead::Event_Gib); eventCallbacks.put(EV_Activate, (eventCallback_t1) idAFEntity_WithAttachedHead::Event_Activate); } @@ -1358,6 +1376,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -2147,6 +2170,7 @@ public static class idAFEntity_ClawFourFingers extends idAFEntity_Base { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idAFEntity_Base.getEventCallBacks()); eventCallbacks.put(EV_SetFingerAngle, (eventCallback_t1) idAFEntity_ClawFourFingers::Event_SetFingerAngle); eventCallbacks.put(EV_StopFingers, (eventCallback_t0) idAFEntity_ClawFourFingers::Event_StopFingers); } @@ -2229,6 +2253,11 @@ private void Event_StopFingers() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* diff --git a/src/main/java/neo/Game/AI/AI.java b/src/main/java/neo/Game/AI/AI.java index 26511049..4b964228 100644 --- a/src/main/java/neo/Game/AI/AI.java +++ b/src/main/java/neo/Game/AI/AI.java @@ -705,6 +705,7 @@ public static class idAI extends idActor { // CLASS_PROTOTYPE( idAI ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idActor.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idAI::Event_Activate); eventCallbacks.put(EV_Touch, (eventCallback_t2) idAI::Event_Touch); eventCallbacks.put(AI_FindEnemy, (eventCallback_t1) idAI::Event_FindEnemy); @@ -7363,12 +7364,18 @@ public void oSet(idClass oGet) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; public static class idCombatNode extends idEntity { // CLASS_PROTOTYPE( idCombatNode ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_CombatNode_MarkUsed, (eventCallback_t0) idCombatNode::Event_MarkUsed ); eventCallbacks.put(EV_Activate, (eventCallback_t1) idCombatNode::Event_Activate ); } @@ -7556,6 +7563,11 @@ public void oSet(idClass oGet) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* diff --git a/src/main/java/neo/Game/AI/AI_Vagary.java b/src/main/java/neo/Game/AI/AI_Vagary.java index 6c0867fd..8e724c55 100644 --- a/src/main/java/neo/Game/AI/AI_Vagary.java +++ b/src/main/java/neo/Game/AI/AI_Vagary.java @@ -43,6 +43,7 @@ public static class idAI_Vagary extends idAI { //CLASS_PROTOTYPE( idAI_Vagary ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idAI.getEventCallBacks()); eventCallbacks.put(AI_Vagary_ChooseObjectToThrow, (eventCallback_t5) idAI_Vagary::Event_ChooseObjectToThrow); eventCallbacks.put(AI_Vagary_ThrowObjectAtEnemy, (eventCallback_t2) idAI_Vagary::Event_ThrowObjectAtEnemy); } @@ -136,5 +137,10 @@ private void Event_ThrowObjectAtEnemy(idEventArg _ent, idEventArg getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Actor.java b/src/main/java/neo/Game/Actor.java index e1e56209..265e4327 100644 --- a/src/main/java/neo/Game/Actor.java +++ b/src/main/java/neo/Game/Actor.java @@ -367,6 +367,7 @@ public static class idActor extends idAFEntity_Gibbable { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idAFEntity_Gibbable.getEventCallBacks()); eventCallbacks.put(AI_EnableEyeFocus, (eventCallback_t0) idActor::Event_EnableEyeFocus); eventCallbacks.put(AI_DisableEyeFocus, (eventCallback_t0) idActor::Event_DisableEyeFocus); eventCallbacks.put(EV_Footstep, (eventCallback_t0) idActor::Event_Footstep); @@ -2891,5 +2892,10 @@ private void Event_GetHead() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Animation/Anim_Testmodel.java b/src/main/java/neo/Game/Animation/Anim_Testmodel.java index d106e61b..a77c7984 100644 --- a/src/main/java/neo/Game/Animation/Anim_Testmodel.java +++ b/src/main/java/neo/Game/Animation/Anim_Testmodel.java @@ -105,6 +105,7 @@ public static class idTestModel extends idAnimatedEntity { // CLASS_PROTOTYPE( idTestModel ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idAnimatedEntity.getEventCallBacks()); eventCallbacks.put(EV_FootstepLeft, (eventCallback_t0) idTestModel::Event_Footstep); eventCallbacks.put(EV_FootstepRight, (eventCallback_t0) idTestModel::Event_Footstep); } @@ -1095,5 +1096,10 @@ public void oSet(Class.idClass oGet) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/BrittleFracture.java b/src/main/java/neo/Game/BrittleFracture.java index 211cb7da..8f5409e7 100644 --- a/src/main/java/neo/Game/BrittleFracture.java +++ b/src/main/java/neo/Game/BrittleFracture.java @@ -114,6 +114,7 @@ public static class idBrittleFracture extends idEntity { // public CLASS_PROTOTYPE( idBrittleFracture ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idBrittleFracture::Event_Activate); eventCallbacks.put(EV_Touch, (eventCallback_t2) idBrittleFracture::Event_Touch); } @@ -1299,5 +1300,10 @@ private void Event_Touch(idEventArg _other, idEventArg _trace public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Camera.java b/src/main/java/neo/Game/Camera.java index af3cd47b..594edbc7 100644 --- a/src/main/java/neo/Game/Camera.java +++ b/src/main/java/neo/Game/Camera.java @@ -83,6 +83,7 @@ public static class idCameraView extends idCamera { // public CLASS_PROTOTYPE( idCameraView ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idCamera.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idCameraView::Event_Activate); eventCallbacks.put(EV_Camera_SetAttachments, (eventCallback_t0) idCameraView::Event_SetAttachments); } @@ -223,6 +224,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -248,6 +254,7 @@ public static class idCameraAnim extends idCamera { // public CLASS_PROTOTYPE( idCameraAnim ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idCamera.getEventCallBacks()); eventCallbacks.put(EV_Thread_SetCallback, (eventCallback_t0) idCameraAnim::Event_SetCallback); eventCallbacks.put(EV_Camera_Stop, (eventCallback_t0) idCameraAnim::Event_Stop); eventCallbacks.put(EV_Camera_Start, (eventCallback_t0) idCameraAnim::Event_Start); @@ -703,5 +710,10 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Entity.java b/src/main/java/neo/Game/Entity.java index 91a68920..a5cf0448 100644 --- a/src/main/java/neo/Game/Entity.java +++ b/src/main/java/neo/Game/Entity.java @@ -388,6 +388,11 @@ public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + public static Map getEventCallBacks() { + return eventCallbacks; + } + + @Override public idEntity oSet(idEntity node) { throw new UnsupportedOperationException("Not supported yet."); @@ -4242,6 +4247,7 @@ public static class damageEffect_s { public static class idAnimatedEntity extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_GetJointHandle, (eventCallback_t1) idAnimatedEntity::Event_GetJointHandle); eventCallbacks.put(EV_ClearAllJoints, (eventCallback_t0) idAnimatedEntity::Event_ClearAllJoints); eventCallbacks.put(EV_ClearJoint, (eventCallback_t1) idAnimatedEntity::Event_ClearJoint); @@ -4760,6 +4766,11 @@ public final boolean idEntity_ServerReceiveEvent(int event, int time, final idBi public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + } /* diff --git a/src/main/java/neo/Game/FX.java b/src/main/java/neo/Game/FX.java index ebed6110..07944766 100644 --- a/src/main/java/neo/Game/FX.java +++ b/src/main/java/neo/Game/FX.java @@ -93,6 +93,7 @@ public static class idEntityFx extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idEntityFx::Event_Trigger); eventCallbacks.put(EV_Fx_KillFx, (eventCallback_t0) idEntityFx::Event_ClearFx); } @@ -736,6 +737,11 @@ protected void ApplyFade(final idFXSingleAction fxaction, idFXLocalAction lactio public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -750,6 +756,7 @@ public static class idTeleporter extends idEntityFx { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTeleporter::Event_DoAction); } @@ -766,5 +773,10 @@ private void Event_DoAction(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/GameSys/Class.java b/src/main/java/neo/Game/GameSys/Class.java index d4a0a06a..ad02d013 100644 --- a/src/main/java/neo/Game/GameSys/Class.java +++ b/src/main/java/neo/Game/GameSys/Class.java @@ -26,7 +26,6 @@ import static neo.TempDump.sizeof; import neo.framework.CmdSystem.cmdFunction_t; import neo.idlib.CmdArgs.idCmdArgs; -import neo.idlib.Lib.idException; import neo.idlib.Text.Str.idStr; import neo.idlib.containers.Hierarchy.idHierarchy; import neo.idlib.containers.List.idList; @@ -34,6 +33,8 @@ import neo.idlib.math.Math_h.idMath; import neo.idlib.math.Vector.idVec3; +import java.util.Map; + /** * */ @@ -168,7 +169,7 @@ public static idEventArg toArg(T data) { } }; - public static class idAllocError extends idException { + public static class idAllocError extends neo.idlib.Lib.idException { public idAllocError(final String text /*= ""*/) { super(text); @@ -241,6 +242,10 @@ public static abstract class idClass/**/ { public abstract eventCallback_t getEventCallBack(idEventDef event); + public static Map getEventCallBacks() { + throw new UnsupportedOperationException("Never call this function on idClass!"); + } + // #ifdef ID_REDIRECT_NEWDELETE // #undef new // #endif @@ -344,7 +349,7 @@ public boolean PostEventMS(final idEventDef ev, float time, Object arg1) { } public boolean PostEventMS(final idEventDef ev, int time, Object arg1, Object arg2) { - return PostEventArgs(ev, time, 2, toArg(arg1), toArg(arg1)); + return PostEventArgs(ev, time, 2, toArg(arg1), toArg(arg2)); } public boolean PostEventMS(final idEventDef ev, int time, Object arg1, Object arg2, Object arg3) { diff --git a/src/main/java/neo/Game/Item.java b/src/main/java/neo/Game/Item.java index 20e627b9..33a5ee84 100644 --- a/src/main/java/neo/Game/Item.java +++ b/src/main/java/neo/Game/Item.java @@ -96,6 +96,7 @@ public static class idItem extends idEntity { // public CLASS_PROTOTYPE( idItem ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_DropToFloor, (eventCallback_t0) idItem::Event_DropToFloor); eventCallbacks.put(EV_Touch, (eventCallback_t2) idItem::Event_Touch); eventCallbacks.put(EV_Activate, (eventCallback_t1) idItem::Event_Trigger); @@ -581,6 +582,11 @@ private void Event_RespawnFx() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -643,6 +649,7 @@ public static class idObjective extends idItem { //public CLASS_PROTOTYPE( idObjective ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idItem.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idObjective::Event_Trigger); eventCallbacks.put(EV_HideObjective, (eventCallback_t1) idObjective::Event_HideObjective); eventCallbacks.put(EV_GetPlayerPos, (eventCallback_t0) idObjective::Event_GetPlayerPos); @@ -758,6 +765,11 @@ private void Event_CamShot() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -813,6 +825,7 @@ public static class idMoveableItem extends idItem { // public CLASS_PROTOTYPE( idMoveableItem ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idItem.getEventCallBacks()); eventCallbacks.put(EV_DropToFloor, (eventCallback_t0) idMoveableItem::Event_DropToFloor); eventCallbacks.put(EV_Gib, (eventCallback_t1) idMoveableItem::Event_Gib); } @@ -1094,6 +1107,11 @@ private void Event_Gib(final idEventArg damageDefName) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1134,6 +1152,7 @@ public static class idItemRemover extends idEntity { //public CLASS_PROTOTYPE( idItemRemover ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idItemRemover::Event_Trigger); } @@ -1165,6 +1184,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1178,6 +1202,7 @@ public static class idObjectiveComplete extends idItemRemover { // public CLASS_PROTOTYPE( idObjectiveComplete ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idItemRemover.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idObjectiveComplete::Event_Trigger); eventCallbacks.put(EV_HideObjective, (eventCallback_t1) idObjectiveComplete::Event_HideObjective); eventCallbacks.put(EV_GetPlayerPos, (eventCallback_t0) idObjectiveComplete::Event_GetPlayerPos); @@ -1254,5 +1279,10 @@ private void Event_GetPlayerPos() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Light.java b/src/main/java/neo/Game/Light.java index bfe3c424..fe40ccf3 100644 --- a/src/main/java/neo/Game/Light.java +++ b/src/main/java/neo/Game/Light.java @@ -92,6 +92,7 @@ public static class idLight extends idEntity { // public CLASS_PROTOTYPE( idLight ); private static Map eventCallbacks = new HashMap<>(); static{ + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Light_SetShader, (eventCallback_t1) idLight::Event_SetShader); eventCallbacks.put(EV_Light_GetLightParm, (eventCallback_t1) idLight::Event_GetLightParm); eventCallbacks.put(EV_Light_SetLightParm, (eventCallback_t2) idLight::Event_SetLightParm); @@ -925,5 +926,10 @@ public idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Misc.java b/src/main/java/neo/Game/Misc.java index 004e22c7..4955199b 100644 --- a/src/main/java/neo/Game/Misc.java +++ b/src/main/java/neo/Game/Misc.java @@ -188,6 +188,7 @@ public static class idPlayerStart extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idPlayerStart::Event_TeleportPlayer); eventCallbacks.put(EV_TeleportStage, (eventCallback_t1) idPlayerStart::Event_TeleportStage); } @@ -367,6 +368,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -384,6 +390,7 @@ public static class idActivator extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idActivator::Event_Activate); } @@ -455,6 +462,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -475,6 +487,7 @@ public static class idPathCorner extends idEntity { // public CLASS_PROTOTYPE( idPathCorner ); private static Map eventCallbacks = new HashMap<>(); static{ + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(AI_RandomPath, (eventCallback_t0) idPathCorner::Event_RandomPath); } @@ -539,6 +552,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -562,6 +580,7 @@ public static class idDamagable extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idDamagable::Event_BecomeBroken); eventCallbacks.put(EV_RestoreDamagable, (eventCallback_t0) idDamagable::Event_RestoreDamagable); } @@ -697,6 +716,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -717,6 +741,7 @@ public static class idExplodable extends idEntity { // CLASS_PROTOTYPE( idExplodable ); private static Map eventCallbacks = new HashMap<>(); static{ + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idExplodable::Event_Explode); } @@ -762,6 +787,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -776,6 +806,7 @@ public static class idSpring extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_PostSpawn, (eventCallback_t0) idSpring::Event_LinkSpring); } @@ -881,6 +912,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -897,6 +933,7 @@ public static class idForceField extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idForceField::Event_Activate); eventCallbacks.put(EV_Toggle, (eventCallback_t0) idForceField::Event_Toggle); eventCallbacks.put(EV_FindTargets, (eventCallback_t0) idForceField::Event_FindTargets ); @@ -1007,6 +1044,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* =============================================================================== @@ -1026,6 +1068,7 @@ public static class idAnimated extends idAFEntity_Gibbable { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idAFEntity_Gibbable.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idAnimated::Event_Activate); eventCallbacks.put(EV_Animated_Start, (eventCallback_t0) idAnimated::Event_Start); eventCallbacks.put(EV_StartRagdoll, (eventCallback_t0) idAnimated::Event_StartRagdoll); @@ -1414,6 +1457,11 @@ private void Event_LaunchMissilesUpdate(idEventArg launchjoint, idEvent public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1430,6 +1478,7 @@ public static class idStaticEntity extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idStaticEntity::Event_Activate); } @@ -1654,6 +1703,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1668,6 +1722,7 @@ public static class idFuncEmitter extends idStaticEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idStaticEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idFuncEmitter::Event_Activate); } @@ -1735,6 +1790,11 @@ public void ReadFromSnapshot(final idBitMsgDelta msg) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1749,6 +1809,7 @@ public static class idFuncSmoke extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idFuncSmoke::Event_Activate); } @@ -1849,6 +1910,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1865,6 +1931,7 @@ public static class idFuncSplat extends idFuncEmitter { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idFuncEmitter.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idFuncSplat::Event_Activate); eventCallbacks.put(EV_Splat, (eventCallback_t0) idFuncSplat::Event_Splat); } @@ -1902,6 +1969,11 @@ private void Event_Splat() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -2058,6 +2130,7 @@ public static class idVacuumSeparatorEntity extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idVacuumSeparatorEntity::Event_Activate); } @@ -2119,6 +2192,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -2169,6 +2247,7 @@ public static class idBeam extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_PostSpawn, (eventCallback_t0) idBeam::Event_MatchTarget); eventCallbacks.put(EV_Activate, (eventCallback_t1) idBeam::Event_Activate); } @@ -2337,6 +2416,7 @@ public static class idLiquid extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Touch, (eventCallback_t2) idLiquid::Event_Touch); } @@ -2391,6 +2471,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -2405,6 +2490,7 @@ public static class idShaking extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idShaking::Event_Activate); } @@ -2484,6 +2570,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -2498,6 +2589,7 @@ public static class idEarthQuake extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idEarthQuake::Event_Activate); } @@ -2652,6 +2744,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -2667,6 +2764,7 @@ public static class idFuncPortal extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idFuncPortal::Event_Activate); } @@ -2723,6 +2821,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -2737,6 +2840,7 @@ public static class idFuncAASPortal extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idFuncAASPortal::Event_Activate); } @@ -2785,6 +2889,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -2799,6 +2908,7 @@ public static class idFuncAASObstacle extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idFuncAASObstacle::Event_Activate); } @@ -2846,6 +2956,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* =============================================================================== @@ -2861,6 +2976,7 @@ public static class idFuncRadioChatter extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idFuncRadioChatter::Event_Activate); eventCallbacks.put(EV_ResetRadioHud, (eventCallback_t1) idFuncRadioChatter::Event_ResetRadioHud); } @@ -2950,6 +3066,11 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -2965,6 +3086,7 @@ public static class idPhantomObjects extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idPhantomObjects::Event_Activate); } @@ -3223,5 +3345,10 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Moveable.java b/src/main/java/neo/Game/Moveable.java index 067469d5..89c0ded2 100644 --- a/src/main/java/neo/Game/Moveable.java +++ b/src/main/java/neo/Game/Moveable.java @@ -113,6 +113,7 @@ public static class idMoveable extends idEntity { // CLASS_PROTOTYPE( idMoveable ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idMoveable::Event_Activate); eventCallbacks.put(EV_BecomeNonSolid, (eventCallback_t0) idMoveable::Event_BecomeNonSolid); eventCallbacks.put(EV_SetOwnerFromSpawnArgs, (eventCallback_t0) idMoveable::Event_SetOwnerFromSpawnArgs); @@ -529,6 +530,11 @@ public void idEntity_Damage(idEntity inflictor, idEntity attacker, final idVec3 public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -549,12 +555,12 @@ public eventCallback_t getEventCallBack(idEventDef event) { public static class idBarrel extends idMoveable { // CLASS_PROTOTYPE( idBarrel ); - private float radius; // radius of barrel - private int barrelAxis; // one of the coordinate axes the barrel cylinder is parallel to - private idVec3 lastOrigin; // origin of the barrel the last think frame - private idMat3 lastAxis; // axis of the barrel the last think frame - private float additionalRotation; // additional rotation of the barrel about it's axis - private idMat3 additionalAxis; // additional rotation axis + private float radius; // radius of barrel + private int barrelAxis; // one of the coordinate axes the barrel cylinder is parallel to + private idVec3 lastOrigin; // origin of the barrel the last think frame + private idMat3 lastAxis; // axis of the barrel the last think frame + private float additionalRotation; // additional rotation of the barrel about it's axis + private idMat3 additionalAxis; // additional rotation axis // // @@ -720,6 +726,7 @@ public static class idExplodingBarrel extends idBarrel { // CLASS_PROTOTYPE( idExplodingBarrel ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idBarrel.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idExplodingBarrel::Event_Activate); eventCallbacks.put(EV_Respawn, (eventCallback_t0) idExplodingBarrel::Event_Respawn); eventCallbacks.put(EV_Explode, (eventCallback_t0) idExplodingBarrel::Event_Explode); @@ -740,16 +747,16 @@ protected enum explode_state_t { BURNEXPIRED, EXPLODING }; - private explode_state_t state; - private idVec3 spawnOrigin; - private idMat3 spawnAxis; + private explode_state_t state; + private idVec3 spawnOrigin; + private idMat3 spawnAxis; private int/*qhandle_t*/ particleModelDefHandle; private int/*qhandle_t*/ lightDefHandle; - private renderEntity_s particleRenderEntity; - private renderLight_s light; - private int particleTime; - private int lightTime; - private float time; + private renderEntity_s particleRenderEntity; + private renderLight_s light; + private int particleTime; + private int lightTime; + private float time; // // @@ -1131,5 +1138,10 @@ private void Event_TriggerTargets() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Mover.java b/src/main/java/neo/Game/Mover.java index 4ec322bd..990e9ef7 100644 --- a/src/main/java/neo/Game/Mover.java +++ b/src/main/java/neo/Game/Mover.java @@ -188,6 +188,7 @@ public static class idMover extends idEntity { // CLASS_PROTOTYPE( idMover ); private static Map eventCallbacks = new HashMap<>(); static{ + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_FindGuiTargets, (eventCallback_t0) idMover::Event_FindGuiTargets); eventCallbacks.put(EV_Thread_SetCallback, (eventCallback_t0) idMover::Event_SetCallback); eventCallbacks.put(EV_TeamBlocked, (eventCallback_t2) idMover::Event_TeamBlocked); @@ -1448,6 +1449,11 @@ private void Event_IsRotating() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1492,6 +1498,7 @@ public static class idElevator extends idMover { // CLASS_PROTOTYPE( idElevator ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idMover.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idElevator::Event_Activate); eventCallbacks.put(EV_TeamBlocked, (eventCallback_t2) idElevator::Event_TeamBlocked); eventCallbacks.put(EV_PartBlocked, (eventCallback_t1) idElevator::Event_PartBlocked); @@ -1912,6 +1919,11 @@ private void Event_PostFloorArrival() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1944,6 +1956,7 @@ public static class idMover_Binary extends idEntity { // CLASS_PROTOTYPE( idMover_Binary ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_FindGuiTargets, (eventCallback_t0) idMover_Binary::Event_FindGuiTargets); eventCallbacks.put(EV_Thread_SetCallback, (eventCallback_t0) idMover_Binary::Event_SetCallback); eventCallbacks.put(EV_Mover_ReturnToPos1, (eventCallback_t0) idMover_Binary::Event_ReturnToPos1); @@ -2851,6 +2864,11 @@ public idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -2866,6 +2884,7 @@ public eventCallback_t getEventCallBack(idEventDef event) { public static class idDoor extends idMover_Binary { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idMover_Binary.getEventCallBacks()); eventCallbacks.put(EV_TeamBlocked, (eventCallback_t2) idDoor::Event_TeamBlocked); eventCallbacks.put(EV_PartBlocked, (eventCallback_t1) idDoor::Event_PartBlocked); eventCallbacks.put(EV_Touch, (eventCallback_t2) idDoor::Event_Touch); @@ -3636,6 +3655,11 @@ protected void Event_ClosePortal() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -3649,6 +3673,7 @@ public static class idPlat extends idMover_Binary { // CLASS_PROTOTYPE( idPlat ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idMover_Binary.getEventCallBacks()); eventCallbacks.put(EV_Touch, (eventCallback_t2) idPlat::Event_Touch); eventCallbacks.put(EV_TeamBlocked, (eventCallback_t2) idPlat::Event_TeamBlocked); eventCallbacks.put(EV_PartBlocked, (eventCallback_t1) idPlat::Event_PartBlocked); @@ -3824,6 +3849,11 @@ private void Event_Touch(idEventArg _other, idEventArg trace) public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -3844,6 +3874,7 @@ public static class idMover_Periodic extends idEntity { // CLASS_PROTOTYPE( idMover_Periodic ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_TeamBlocked, (eventCallback_t2) idMover_Periodic::Event_TeamBlocked); eventCallbacks.put(EV_PartBlocked, (eventCallback_t1) idMover_Periodic::Event_PartBlocked); } @@ -3929,6 +3960,11 @@ public idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -3942,6 +3978,7 @@ public static class idRotater extends idMover_Periodic { // CLASS_PROTOTYPE( idRotater ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idMover_Periodic.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idRotater::Event_Activate); } @@ -4017,6 +4054,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -4132,6 +4174,7 @@ public static class idRiser extends idMover_Periodic { // CLASS_PROTOTYPE( idRiser ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idMover_Periodic.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idRiser::Event_Activate); } @@ -4178,5 +4221,10 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Player.java b/src/main/java/neo/Game/Player.java index ce1127cc..4ed14b17 100644 --- a/src/main/java/neo/Game/Player.java +++ b/src/main/java/neo/Game/Player.java @@ -1203,6 +1203,7 @@ public static class idPlayer extends idActor { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idActor.getEventCallBacks()); eventCallbacks.put(EV_Player_GetButtons, (eventCallback_t0) idPlayer::Event_GetButtons); eventCallbacks.put(EV_Player_GetMove, (eventCallback_t0) idPlayer::Event_GetMove); eventCallbacks.put(EV_Player_GetViewAngles, (eventCallback_t0) idPlayer::Event_GetViewAngles); @@ -8426,5 +8427,10 @@ private void Event_GetIdealWeapon() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Projectile.java b/src/main/java/neo/Game/Projectile.java index fb304ded..4054927a 100644 --- a/src/main/java/neo/Game/Projectile.java +++ b/src/main/java/neo/Game/Projectile.java @@ -136,6 +136,7 @@ public class Projectile { public static class idProjectile extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Explode, (eventCallback_t0) idProjectile::Event_Explode); eventCallbacks.put(EV_Fizzle, (eventCallback_t0) idProjectile::Event_Fizzle); eventCallbacks.put(EV_Touch, (eventCallback_t2) idProjectile::Event_Touch); @@ -1279,6 +1280,11 @@ private void Event_GetProjectileState() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1689,6 +1695,7 @@ public static class idBFGProjectile extends idProjectile { // CLASS_PROTOTYPE( idBFGProjectile ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idProjectile.getEventCallBacks()); eventCallbacks.put(EV_RemoveBeams, (eventCallback_t0) idBFGProjectile::Event_RemoveBeams); } @@ -2039,6 +2046,11 @@ public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + public static Map getEventCallBacks() { + return eventCallbacks; + } + + // private void ApplyDamage(); }; @@ -2053,6 +2065,7 @@ public static class idDebris extends idEntity { // CLASS_PROTOTYPE( idDebris ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Explode, (eventCallback_t0) idDebris::Event_Explode); eventCallbacks.put(EV_Fizzle, (eventCallback_t0) idDebris::Event_Fizzle); } @@ -2351,5 +2364,10 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Script/Script_Thread.java b/src/main/java/neo/Game/Script/Script_Thread.java index 48bf7f2c..f6fc4061 100644 --- a/src/main/java/neo/Game/Script/Script_Thread.java +++ b/src/main/java/neo/Game/Script/Script_Thread.java @@ -1107,6 +1107,11 @@ public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + public static Map getEventCallBacks() { + return eventCallbacks; + } + + @Override public void oSet(idClass oGet) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. diff --git a/src/main/java/neo/Game/SecurityCamera.java b/src/main/java/neo/Game/SecurityCamera.java index 020a31cf..bba6dd86 100644 --- a/src/main/java/neo/Game/SecurityCamera.java +++ b/src/main/java/neo/Game/SecurityCamera.java @@ -67,6 +67,7 @@ public class SecurityCamera { public static class idSecurityCamera extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_SecurityCam_ReverseSweep, (eventCallback_t0) idSecurityCamera::Event_ReverseSweep); eventCallbacks.put(EV_SecurityCam_ContinueSweep, (eventCallback_t0) idSecurityCamera::Event_ContinueSweep); eventCallbacks.put(EV_SecurityCam_Pause, (eventCallback_t0) idSecurityCamera::Event_Pause); @@ -551,5 +552,10 @@ private void Event_AddLight() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Sound.java b/src/main/java/neo/Game/Sound.java index 8525ee7f..dbef0869 100644 --- a/src/main/java/neo/Game/Sound.java +++ b/src/main/java/neo/Game/Sound.java @@ -93,6 +93,7 @@ static class soundShaderParms_t { public static class idSound extends idEntity { private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idSound::Event_Trigger); eventCallbacks.put(EV_Speaker_On, (eventCallback_t0) idSound::Event_On); eventCallbacks.put(EV_Speaker_Off, (eventCallback_t0) idSound::Event_Off); @@ -333,5 +334,10 @@ public Class.idClass CreateInstance() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Target.java b/src/main/java/neo/Game/Target.java index de99026c..2ba91db3 100644 --- a/src/main/java/neo/Game/Target.java +++ b/src/main/java/neo/Game/Target.java @@ -122,6 +122,7 @@ public static class idTarget_Remove extends idTarget { // CLASS_PROTOTYPE( idTarget_Remove ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_Remove::Event_Activate); } @@ -145,6 +146,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -159,6 +165,7 @@ public static class idTarget_Show extends idTarget { // CLASS_PROTOTYPE( idTarget_Show ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_Show::Event_Activate); } @@ -182,6 +189,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -196,6 +208,7 @@ public static class idTarget_Damage extends idTarget { // CLASS_PROTOTYPE( idTarget_Damage ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_Damage::Event_Activate); } @@ -218,6 +231,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -232,6 +250,7 @@ public static class idTarget_SessionCommand extends idTarget { // CLASS_PROTOTYPE(idTarget_SessionCommand ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SessionCommand::Event_Activate); } @@ -243,6 +262,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -258,6 +282,7 @@ public static class idTarget_EndLevel extends idTarget { // CLASS_PROTOTYPE( idTarget_EndLevel ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_EndLevel::Event_Activate); } @@ -296,6 +321,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -310,6 +340,7 @@ public static class idTarget_WaitForButton extends idTarget { // CLASS_PROTOTYPE( idTarget_WaitForButton ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_WaitForButton::Event_Activate); } @@ -344,6 +375,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -357,6 +393,7 @@ public static class idTarget_SetGlobalShaderTime extends idTarget { // CLASS_PROTOTYPE( idTarget_SetGlobalShaderTime ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetGlobalShaderTime::Event_Activate); } @@ -373,6 +410,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -387,6 +429,7 @@ public static class idTarget_SetShaderParm extends idTarget { // CLASS_PROTOTYPE( idTarget_SetShaderParm ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetShaderParm::Event_Activate); } @@ -431,6 +474,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -445,6 +493,7 @@ public static class idTarget_SetShaderTime extends idTarget { // CLASS_PROTOTYPE( idTarget_SetShaderTime ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetShaderTime::Event_Activate); } @@ -470,6 +519,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -483,6 +537,7 @@ public static class idTarget_FadeEntity extends idTarget { // CLASS_PROTOTYPE( idTarget_FadeEntity ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_FadeEntity::Event_Activate); } @@ -571,6 +626,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -584,6 +644,7 @@ public static class idTarget_LightFadeIn extends idTarget { // CLASS_PROTOTYPE( idTarget_LightFadeIn ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_LightFadeIn::Event_Activate); } @@ -618,6 +679,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -631,6 +697,7 @@ public static class idTarget_LightFadeOut extends idTarget { // CLASS_PROTOTYPE( idTarget_LightFadeOut ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_LightFadeOut::Event_Activate); } @@ -665,6 +732,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -678,6 +750,7 @@ public static class idTarget_Give extends idTarget { // CLASS_PROTOTYPE( idTarget_Give ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_Give::Event_Activate); } @@ -720,6 +793,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -734,6 +812,7 @@ public static class idTarget_GiveEmail extends idTarget { // CLASS_PROTOTYPE( idTarget_GiveEmail ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_GiveEmail::Event_Activate); } @@ -752,6 +831,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -765,6 +849,7 @@ public static class idTarget_SetModel extends idTarget { // CLASS_PROTOTYPE( idTarget_SetModel ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetModel::Event_Activate); } @@ -795,6 +880,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -808,6 +898,7 @@ public static class idTarget_SetInfluence extends idTarget { // CLASS_PROTOTYPE( idTarget_SetInfluence ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetInfluence::Event_Activate); eventCallbacks.put(EV_RestoreInfluence, (eventCallback_t0) idTarget_SetInfluence::Event_RestoreInfluence); eventCallbacks.put(EV_GatherEntities, (eventCallback_t0) idTarget_SetInfluence::Event_GatherEntities); @@ -1287,6 +1378,11 @@ public void Think() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -1301,6 +1397,7 @@ public static class idTarget_SetKeyVal extends idTarget { // CLASS_PROTOTYPE( idTarget_SetKeyVal ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetKeyVal::Event_Activate); } @@ -1344,6 +1441,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -1358,6 +1460,7 @@ public static class idTarget_SetFov extends idTarget { // CLASS_PROTOTYPE( idTarget_SetFov ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetFov::Event_Activate); } @@ -1418,6 +1521,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -1432,6 +1540,7 @@ public static class idTarget_SetPrimaryObjective extends idTarget { // CLASS_PROTOTYPE( idTarget_SetPrimaryObjective ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_SetPrimaryObjective::Event_Activate); } @@ -1447,6 +1556,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1460,6 +1574,7 @@ public static class idTarget_LockDoor extends idTarget { // CLASS_PROTOTYPE( idTarget_LockDoor ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_LockDoor::Event_Activate); } @@ -1486,6 +1601,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1499,6 +1619,7 @@ public static class idTarget_CallObjectFunction extends idTarget { // CLASS_PROTOTYPE( idTarget_CallObjectFunction ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_CallObjectFunction::Event_Activate); } @@ -1536,6 +1657,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -1550,6 +1676,7 @@ public static class idTarget_EnableLevelWeapons extends idTarget { // CLASS_PROTOTYPE( idTarget_EnableLevelWeapons ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_EnableLevelWeapons::Event_Activate); } @@ -1583,6 +1710,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1596,6 +1728,7 @@ public static class idTarget_Tip extends idTarget { // CLASS_PROTOTYPE( idTarget_Tip ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_Tip::Event_Activate); eventCallbacks.put(EV_TipOff, (eventCallback_t0) idTarget_Tip::Event_TipOff); eventCallbacks.put(EV_GetPlayerPos, (eventCallback_t0) idTarget_Tip::Event_GetPlayerPos); @@ -1656,6 +1789,11 @@ private void Event_GetPlayerPos() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1669,6 +1807,7 @@ public static class idTarget_GiveSecurity extends idTarget { // CLASS_PROTOTYPE( idTarget_GiveSecurity ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_GiveSecurity::Event_Activate); } @@ -1684,6 +1823,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -1698,6 +1842,7 @@ public static class idTarget_RemoveWeapons extends idTarget { // CLASS_PROTOTYPE( idTarget_RemoveWeapons ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_RemoveWeapons::Event_Activate); } @@ -1720,6 +1865,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -1734,6 +1884,7 @@ public static class idTarget_LevelTrigger extends idTarget { // CLASS_PROTOTYPE( idTarget_LevelTrigger );//TODO:understand this fucking macro private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_LevelTrigger::Event_Activate); } @@ -1751,6 +1902,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1764,6 +1920,7 @@ public static class idTarget_EnableStamina extends idTarget { // CLASS_PROTOTYPE( idTarget_EnableStamina ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_EnableStamina::Event_Activate); } @@ -1785,6 +1942,11 @@ private void Event_Activate(idEventArg activator) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -1798,6 +1960,7 @@ public static class idTarget_FadeSoundClass extends idTarget { // CLASS_PROTOTYPE( idTarget_FadeSoundClass ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTarget.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTarget_FadeSoundClass::Event_Activate); eventCallbacks.put(EV_RestoreVolume, (eventCallback_t0) idTarget_FadeSoundClass::Event_RestoreVolume); } @@ -1829,5 +1992,10 @@ private void Event_RestoreVolume() { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Trigger.java b/src/main/java/neo/Game/Trigger.java index 9bac0981..af578047 100644 --- a/src/main/java/neo/Game/Trigger.java +++ b/src/main/java/neo/Game/Trigger.java @@ -72,6 +72,7 @@ public static class idTrigger extends idEntity { // CLASS_PROTOTYPE( idTrigger ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Enable, (eventCallback_t0) idTrigger::Event_Enable); eventCallbacks.put(EV_Disable, (eventCallback_t0) idTrigger::Event_Disable); @@ -240,6 +241,11 @@ public void oSet(idClass oGet) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; /* @@ -253,6 +259,7 @@ public static class idTrigger_Multi extends idTrigger { // CLASS_PROTOTYPE( idTrigger_Multi ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTrigger.getEventCallBacks()); eventCallbacks.put(EV_Touch, (eventCallback_t2) idTrigger_Multi::Event_Touch); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTrigger_Multi::Event_Trigger); eventCallbacks.put(EV_TriggerAction, (eventCallback_t1) idTrigger_Multi::Event_TriggerAction); @@ -506,6 +513,11 @@ public void oSet(idClass oGet) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -520,6 +532,7 @@ public static class idTrigger_EntityName extends idTrigger { //CLASS_PROTOTYPE(idTrigger_EntityName ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTrigger.getEventCallBacks()); eventCallbacks.put(EV_Touch, (eventCallback_t2) idTrigger_EntityName::Event_Touch); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTrigger_EntityName::Event_Trigger); eventCallbacks.put(EV_TriggerAction, (eventCallback_t1) idTrigger_EntityName::Event_TriggerAction); @@ -688,6 +701,11 @@ public void oSet(idClass oGet) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -702,6 +720,7 @@ public static class idTrigger_Timer extends idTrigger { // CLASS_PROTOTYPE(idTrigger_Timer ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTrigger.getEventCallBacks()); eventCallbacks.put(EV_Timer, (eventCallback_t0) idTrigger_Timer::Event_Timer); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTrigger_Timer::Event_Use); } @@ -825,6 +844,11 @@ public void oSet(idClass oGet) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -839,6 +863,7 @@ public static class idTrigger_Count extends idTrigger { // CLASS_PROTOTYPE(idTrigger_Count ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTrigger.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTrigger_Count::Event_Trigger); eventCallbacks.put(EV_TriggerAction, (eventCallback_t1) idTrigger_Count::Event_TriggerAction); } @@ -911,6 +936,11 @@ public void oSet(idClass oGet) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -925,6 +955,7 @@ static class idTrigger_Hurt extends idTrigger { // CLASS_PROTOTYPE(idTrigger_Hurt ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTrigger.getEventCallBacks()); eventCallbacks.put(EV_Touch, (eventCallback_t2) idTrigger_Hurt::Event_Touch); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTrigger_Hurt::Event_Toggle); } @@ -1002,6 +1033,11 @@ public void oSet(idClass oGet) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -1016,6 +1052,7 @@ public static class idTrigger_Fade extends idTrigger { // CLASS_PROTOTYPE( idTrigger_Fade ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTrigger.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTrigger_Fade::Event_Trigger); } @@ -1043,6 +1080,11 @@ public void oSet(idClass oGet) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; @@ -1057,6 +1099,7 @@ public static class idTrigger_Touch extends idTrigger { // CLASS_PROTOTYPE( idTrigger_Touch ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idTrigger.getEventCallBacks()); eventCallbacks.put(EV_Activate, (eventCallback_t1) idTrigger_Touch::Event_Trigger); } @@ -1166,5 +1209,10 @@ public void oSet(idClass oGet) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/Weapon.java b/src/main/java/neo/Game/Weapon.java index 982de0dc..3fa7686c 100644 --- a/src/main/java/neo/Game/Weapon.java +++ b/src/main/java/neo/Game/Weapon.java @@ -194,6 +194,7 @@ public static class idWeapon extends idAnimatedEntity { // CLASS_PROTOTYPE( idWeapon ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idAnimatedEntity.getEventCallBacks()); eventCallbacks.put(EV_Weapon_Clear, (eventCallback_t0) idWeapon::Event_Clear); eventCallbacks.put(EV_Weapon_GetOwner, (eventCallback_t0) idWeapon::Event_GetOwner); eventCallbacks.put(EV_Weapon_State, (eventCallback_t2) idWeapon::Event_WeaponState); @@ -3010,5 +3011,10 @@ public void oSet(idClass oGet) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } diff --git a/src/main/java/neo/Game/WorldSpawn.java b/src/main/java/neo/Game/WorldSpawn.java index 7c5d2450..bf798749 100644 --- a/src/main/java/neo/Game/WorldSpawn.java +++ b/src/main/java/neo/Game/WorldSpawn.java @@ -44,6 +44,7 @@ public static class idWorldspawn extends idEntity { // CLASS_PROTOTYPE( idWorldspawn ); private static Map eventCallbacks = new HashMap<>(); static { + eventCallbacks.putAll(idEntity.getEventCallBacks()); eventCallbacks.put(EV_Remove, (eventCallback_t0) idWorldspawn::Event_Remove); eventCallbacks.put(EV_SafeRemove, (eventCallback_t0) idWorldspawn::Event_Remove); } @@ -137,5 +138,10 @@ public void oSet(idClass oGet) { public eventCallback_t getEventCallBack(idEventDef event) { return eventCallbacks.get(event); } + + public static Map getEventCallBacks() { + return eventCallbacks; + } + }; } From 789d4abc30d3b43011f7247a8702d5c599eda241 Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Mon, 23 May 2016 22:13:24 +0200 Subject: [PATCH 13/17] -lots of nullpointers and lazy init -we now get to see the spaceship in all it's glory, lights still funky, so it's too dark -ingame is still blank-ish --- src/main/java/neo/Game/AI/AI.java | 2 +- src/main/java/neo/Game/Camera.java | 14 +++---- src/main/java/neo/Game/GameSys/Class.java | 1 + src/main/java/neo/Game/Player.java | 6 +-- src/main/java/neo/Game/Script/idProgram.java | 12 +++--- src/main/java/neo/Renderer/Model_md5.java | 2 +- .../java/neo/Renderer/RenderSystem_init.java | 4 +- .../java/neo/Renderer/RenderWorld_local.java | 12 +++--- .../neo/Renderer/RenderWorld_portals.java | 9 ++-- src/main/java/neo/Renderer/tr_deform.java | 41 +++++++++++-------- src/main/java/neo/Renderer/tr_guisurf.java | 6 ++- src/main/java/neo/Renderer/tr_lightrun.java | 2 +- src/main/java/neo/Renderer/tr_local.java | 3 +- .../java/neo/Renderer/tr_stencilshadow.java | 25 ++++++----- .../neo/Tools/Compilers/DMap/shadowopt3.java | 2 +- .../neo/Tools/Compilers/DMap/usurface.java | 4 +- src/main/java/neo/idlib/math/Simd.java | 19 ++++++--- src/main/java/neo/idlib/math/Vector.java | 7 ++++ 18 files changed, 101 insertions(+), 70 deletions(-) diff --git a/src/main/java/neo/Game/AI/AI.java b/src/main/java/neo/Game/AI/AI.java index 4b964228..32d16f21 100644 --- a/src/main/java/neo/Game/AI/AI.java +++ b/src/main/java/neo/Game/AI/AI.java @@ -2688,7 +2688,7 @@ protected void PlayCinematic() { torsoAnim.animBlendFrames = 0; torsoAnim.lastAnimBlendFrames = 0; - ProcessEvent(AI_PlayAnim, ANIMCHANNEL_TORSO, animName); + ProcessEvent(AI_PlayAnim, ANIMCHANNEL_TORSO, animName[0]); // make sure our model gets updated animator.ForceUpdate(); diff --git a/src/main/java/neo/Game/Camera.java b/src/main/java/neo/Game/Camera.java index 594edbc7..e1dc6589 100644 --- a/src/main/java/neo/Game/Camera.java +++ b/src/main/java/neo/Game/Camera.java @@ -262,12 +262,12 @@ public static class idCameraAnim extends idCamera { } - private int threadNum; - private idVec3 offset; - private int frameRate; - private int starttime; - private int cycle; - private idList cameraCuts; + private int threadNum; + private idVec3 offset; + private int frameRate; + private int starttime; + private int cycle; + private idList cameraCuts; private idList camera; private idEntityPtr activator; // @@ -281,7 +281,7 @@ public idCameraAnim() { cycle = 1; cameraCuts = new idList<>(); camera = new idList<>(); - activator = null; + activator = new idEntityPtr<>(null); } //~idCameraAnim(); diff --git a/src/main/java/neo/Game/GameSys/Class.java b/src/main/java/neo/Game/GameSys/Class.java index ad02d013..c0364079 100644 --- a/src/main/java/neo/Game/GameSys/Class.java +++ b/src/main/java/neo/Game/GameSys/Class.java @@ -154,6 +154,7 @@ public static class idEventArg { public idEventArg(T data) { if(data instanceof Integer) type = D_EVENT_INTEGER; + else if(data instanceof Enum) type = D_EVENT_INTEGER; else if(data instanceof Float) type = D_EVENT_FLOAT; else if(data instanceof idVec3) type = D_EVENT_VECTOR; else if(data instanceof idStr) type = D_EVENT_STRING; diff --git a/src/main/java/neo/Game/Player.java b/src/main/java/neo/Game/Player.java index 4ed14b17..974d1d1a 100644 --- a/src/main/java/neo/Game/Player.java +++ b/src/main/java/neo/Game/Player.java @@ -1633,7 +1633,7 @@ public idPlayer() { hiddenWeapon = false; tipUp = false; objectiveUp = false; - teleportEntity = null; + teleportEntity = new idEntityPtr<>(null); teleportKiller = -1; respawning = false; ready = false; @@ -2742,7 +2742,7 @@ public void Init() { hiddenWeapon = false; tipUp = false; objectiveUp = false; - teleportEntity = null; + teleportEntity.oSet(null); teleportKiller = -1; leader = false; @@ -8388,7 +8388,7 @@ private void Event_ExitTeleporter() { // kill anything that would have waited at teleport exit gameLocal.KillBox(this); } - teleportEntity = null; + teleportEntity.oSet(null); } private void Event_HideTip() { diff --git a/src/main/java/neo/Game/Script/idProgram.java b/src/main/java/neo/Game/Script/idProgram.java index 1fe3a7b5..e30c6a9f 100644 --- a/src/main/java/neo/Game/Script/idProgram.java +++ b/src/main/java/neo/Game/Script/idProgram.java @@ -1042,26 +1042,26 @@ public int GetReturnedInteger() { } public void ReturnFloat(float value) { - returnDef.value.floatPtr[0] = value; + returnDef.value = new varEval_s(value); } public void ReturnInteger(int value) { - returnDef.value.intPtr[0] = value; + returnDef.value = new varEval_s(value); } public void ReturnVector(idVec3 vec) { - returnDef.value.vectorPtr[0] = (vec); + returnDef.value = new varEval_s(vec); } public void ReturnString(final String string) { - returnStringDef.value.stringPtr[0] = string;//idStr.Copynz(returnStringDef.value.stringPtr, string, MAX_STRING_LEN); + returnStringDef.value = new varEval_s(string);//idStr.Copynz(returnStringDef.value.stringPtr, string, MAX_STRING_LEN); } public void ReturnEntity(idEntity ent) { if (ent != null) { - returnDef.value.entityNumberPtr[0] = ent.entityNumber + 1; + returnDef.value = new varEval_s(ent.entityNumber + 1); } else { - returnDef.value.entityNumberPtr[0] = 0; + returnDef.value = new varEval_s(0); } } diff --git a/src/main/java/neo/Renderer/Model_md5.java b/src/main/java/neo/Renderer/Model_md5.java index 413dff99..1e466225 100644 --- a/src/main/java/neo/Renderer/Model_md5.java +++ b/src/main/java/neo/Renderer/Model_md5.java @@ -244,7 +244,7 @@ public void ParseMesh(idLexer parser, int numJoints, final idJointMat[] joints) num = firstWeightForVertex.oGet(i); for (j = 0; j < numWeightsForVertex.oGet(i); j++, num++, count++) { scaledWeights[count] = new idVec4(); - scaledWeights[count].ToVec3().oSet(tempWeights.oGet(num).offset.oMultiply(tempWeights.oGet(num).jointWeight)); + scaledWeights[count].oSet(tempWeights.oGet(num).offset.oMultiply(tempWeights.oGet(num).jointWeight)); scaledWeights[count].w = tempWeights.oGet(num).jointWeight; weightIndex[count * 2 + 0] = tempWeights.oGet(num).joint /* sizeof( idJointMat )*/; } diff --git a/src/main/java/neo/Renderer/RenderSystem_init.java b/src/main/java/neo/Renderer/RenderSystem_init.java index f453114b..c52914e1 100644 --- a/src/main/java/neo/Renderer/RenderSystem_init.java +++ b/src/main/java/neo/Renderer/RenderSystem_init.java @@ -452,8 +452,8 @@ public class RenderSystem_init { r_showTrace = new idCVar("r_showTrace", "0", CVAR_RENDERER | CVAR_INTEGER, "show the intersection of an eye trace with the world", new idCmdSystem.ArgCompletion_Integer(0, 2)); r_showIntensity = new idCVar("r_showIntensity", "0", CVAR_RENDERER | CVAR_BOOL, "draw the screen colors based on intensity, red = 0, green = 128, blue = 255"); r_showImages = new idCVar("r_showImages", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = show all images instead of rendering, 2 = show in proportional size", 0, 2, new idCmdSystem.ArgCompletion_Integer(0, 2)); - r_showSmp = new idCVar("r_showSmp", "0", CVAR_RENDERER | CVAR_BOOL, "show which end =new idCVar(front or back) is blocking"); - r_showLights = new idCVar("r_showLights", "2", CVAR_RENDERER | CVAR_INTEGER, "1 = just print volumes numbers, highlighting ones covering the view, 2 = also draw planes of each volume, 3 = also draw edges of each volume", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); + r_showSmp = new idCVar("r_showSmp", "0", CVAR_RENDERER | CVAR_BOOL, "show which end (front or back) is blocking"); + r_showLights = new idCVar("r_showLights", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = just print volumes numbers, highlighting ones covering the view, 2 = also draw planes of each volume, 3 = also draw edges of each volume", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); r_showShadows = new idCVar("r_showShadows", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = visualize the stencil shadow volumes, 2 = draw filled in", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); r_showShadowCount = new idCVar("r_showShadowCount", "0", CVAR_RENDERER | CVAR_INTEGER, "colors screen based on shadow volume depth complexity, >= 2 = print overdraw count based on stencil index values, 3 = only show turboshadows, 4 = only show static shadows", 0, 4, new idCmdSystem.ArgCompletion_Integer(0, 4)); r_showLightScissors = new idCVar("r_showLightScissors", "0", CVAR_RENDERER | CVAR_BOOL, "show light scissor rectangles"); diff --git a/src/main/java/neo/Renderer/RenderWorld_local.java b/src/main/java/neo/Renderer/RenderWorld_local.java index 2a3de102..0d53a796 100644 --- a/src/main/java/neo/Renderer/RenderWorld_local.java +++ b/src/main/java/neo/Renderer/RenderWorld_local.java @@ -176,10 +176,10 @@ public class RenderWorld_local { public static class portal_s { - int intoArea; // area this portal leads to - idWinding w; // winding points have counter clockwise ordering seen this area - idPlane plane; // view must be on the positive side of the plane to cross - portal_s next; // next portal of the area + int intoArea; // area this portal leads to + idWinding w; // winding points have counter clockwise ordering seen this area + idPlane plane; // view must be on the positive side of the plane to cross + portal_s next; // next portal of the area doublePortal_s doublePortal; public portal_s(){ @@ -2435,7 +2435,7 @@ public void FloodViewThroughArea_r(final idVec3 origin, int areaNum, final porta // make sure the portal isn't in our stack trace, // which would cause an infinite loop for (check = ps; check != null; check = check.next) { - if (check.p.equals(p)) { + if (p.equals(check.p)) { break; // don't recursively enter a stack } } @@ -2456,7 +2456,7 @@ public void FloodViewThroughArea_r(final idVec3 origin, int areaNum, final porta } // clip the portal winding to all of the planes - w = (idFixedWinding) p.w; + w = new idFixedWinding(p.w); for (j = 0; j < ps.numPortalPlanes; j++) { if (!w.ClipInPlace(ps.portalPlanes[j].oNegative(), 0)) { break; diff --git a/src/main/java/neo/Renderer/RenderWorld_portals.java b/src/main/java/neo/Renderer/RenderWorld_portals.java index b188fa23..6a1ab6e5 100644 --- a/src/main/java/neo/Renderer/RenderWorld_portals.java +++ b/src/main/java/neo/Renderer/RenderWorld_portals.java @@ -27,16 +27,17 @@ public class RenderWorld_portals { static class portalStack_s { - portal_s p; + portal_s p; portalStack_s next; // - idScreenRect rect; + idScreenRect rect; // - int numPortalPlanes; - idPlane[] portalPlanes = Stream.generate(idPlane::new).limit(MAX_PORTAL_PLANES + 1).toArray(idPlane[]::new); + int numPortalPlanes; + idPlane[] portalPlanes = Stream.generate(idPlane::new).limit(MAX_PORTAL_PLANES + 1).toArray(idPlane[]::new); // positive side is outside the visible frustum public portalStack_s() { + p = new portal_s(); rect = new idScreenRect(); } diff --git a/src/main/java/neo/Renderer/tr_deform.java b/src/main/java/neo/Renderer/tr_deform.java index 6431f5c3..08d8ef25 100644 --- a/src/main/java/neo/Renderer/tr_deform.java +++ b/src/main/java/neo/Renderer/tr_deform.java @@ -202,11 +202,9 @@ public static void R_TubeDeform(drawSurf_s surf) { newTri.numVerts = tri.numVerts; newTri.numIndexes = tri.numIndexes; newTri.indexes = new int[newTri.numIndexes];// R_FrameAlloc(newTri.numIndexes); -// memcpy( newTri.indexes, tri.indexes, newTri.numIndexes * sizeof( newTri.indexes[0] ) ); - System.arraycopy(tri.indexes, 0, newTri.indexes, 0, newTri.numIndexes); + System.arraycopy(tri.indexes, 0, newTri.indexes, 0, newTri.numIndexes);//memcpy( newTri.indexes, tri.indexes, newTri.numIndexes * sizeof( newTri.indexes[0] ) ); - idDrawVert[] ac = new idDrawVert[newTri.numVerts]; -// memset( ac, 0, sizeof( idDrawVert ) * newTri.numVerts ); + idDrawVert[] ac = Stream.generate(idDrawVert::new).limit(newTri.numVerts).toArray(idDrawVert[]::new);//memset( ac, 0, sizeof( idDrawVert ) * newTri.numVerts ); // this is a lot of work for two triangles... // we could precalculate a lot if it is an issue, but it would mess up @@ -246,9 +244,10 @@ public static void R_TubeDeform(drawSurf_s surf) { v1 = tri.verts[tri.indexes[i + edgeVerts[nums[j]][0]]]; v2 = tri.verts[tri.indexes[i + edgeVerts[nums[j]][1]]]; - mid[j].oSet(0, 0.5f * (v1.xyz.oGet(0) + v2.xyz.oGet(0))); - mid[j].oSet(1, 0.5f * (v1.xyz.oGet(1) + v2.xyz.oGet(1))); - mid[j].oSet(2, 0.5f * (v1.xyz.oGet(2) + v2.xyz.oGet(2))); + mid[j] = new idVec3( + 0.5f * (v1.xyz.oGet(0) + v2.xyz.oGet(0)), + 0.5f * (v1.xyz.oGet(1) + v2.xyz.oGet(1)), + 0.5f * (v1.xyz.oGet(2) + v2.xyz.oGet(2))); } // find the vector of the major axis @@ -591,9 +590,8 @@ public static void R_FlareDeform(drawSurf_s surf) { color = 255; } for (j = 0; j < newTri.numVerts; j++) { - ac[j].color[0] - = ac[j].color[1] - = ac[j].color[2] = (short) color; + ac[j] = new idDrawVert(); + ac[j].color[0] = ac[j].color[1] = ac[j].color[2] = (short) color; ac[j].color[3] = 255; } @@ -617,15 +615,18 @@ public static void R_FlareDeform(drawSurf_s surf) { idVec3 d1 = tri.verts[indexes[(i + 1) % 4]].xyz.oMinus(localViewer); d1.Normalize(); + edgeDir[i][1] = new idVec3(); edgeDir[i][1].Cross(toEye, d1); edgeDir[i][1].Normalize(); edgeDir[i][1] = getVec3_origin().oMinus(edgeDir[i][1]); idVec3 d2 = tri.verts[indexes[(i + 3) % 4]].xyz.oMinus(localViewer); d2.Normalize(); + edgeDir[i][0] = new idVec3(); edgeDir[i][0].Cross(toEye, d2); edgeDir[i][0].Normalize(); + edgeDir[i][2] = new idVec3(); edgeDir[i][2] = edgeDir[i][0].oPlus(edgeDir[i][1]); edgeDir[i][2].Normalize(); } @@ -838,10 +839,15 @@ public static void R_TurbulentDeform(drawSurf_s surf) { static class eyeIsland_t { - int[] tris = new int[MAX_EYEBALL_TRIS]; - int numTris; + int[] tris = new int[MAX_EYEBALL_TRIS]; + int numTris; idBounds bounds; - idVec3 mid; + idVec3 mid; + + public eyeIsland_t() { + bounds = new idBounds(); + mid = new idVec3(); + } }; public static void AddTriangleToIsland_r(final srfTriangles_s tri, int triangleNum, boolean[] usedList, eyeIsland_t island) { @@ -911,6 +917,7 @@ public static void R_EyeballDeform(drawSurf_s surf) { // memset( triUsed, 0, sizeof( triUsed ) ); for (numIslands = 0; numIslands < MAX_EYEBALL_ISLANDS; numIslands++) { + islands[numIslands] = new eyeIsland_t(); islands[numIslands].numTris = 0; islands[numIslands].bounds.Clear(); for (i = 0; i < numTri; i++) { @@ -937,13 +944,13 @@ public static void R_EyeballDeform(drawSurf_s surf) { newTri.numVerts = tri.numVerts; newTri.numIndexes = tri.numIndexes; newTri.indexes = new int[tri.numIndexes]; - idDrawVert[] ac = new idDrawVert[tri.numVerts]; + idDrawVert[] ac = Stream.generate(idDrawVert::new).limit(tri.numVerts).toArray(idDrawVert[]::new); newTri.numIndexes = 0; // decide which islands are the eyes and points for (i = 0; i < numIslands; i++) { - islands[i].mid = islands[i].bounds.GetCenter(); + islands[i].mid.oSet(islands[i].bounds.GetCenter()); } for (i = 0; i < numIslands; i++) { @@ -995,7 +1002,7 @@ public static void R_EyeballDeform(drawSurf_s surf) { v2.Normalize(); // texVec[0] will be the normal to the origin triangle - idVec3[] texVec = new idVec3[2]; + idVec3[] texVec = {new idVec3(), new idVec3()}; texVec[0].Cross(v1, v2); @@ -1014,7 +1021,7 @@ public static void R_EyeballDeform(drawSurf_s surf) { index = tri.indexes[index + k]; newTri.indexes[newTri.numIndexes++] = index; - ac[index].xyz = tri.verts[index].xyz; + ac[index].xyz.oSet(tri.verts[index].xyz); idVec3 local = tri.verts[index].xyz.oMinus(origin); diff --git a/src/main/java/neo/Renderer/tr_guisurf.java b/src/main/java/neo/Renderer/tr_guisurf.java index f7d0a138..348b91b6 100644 --- a/src/main/java/neo/Renderer/tr_guisurf.java +++ b/src/main/java/neo/Renderer/tr_guisurf.java @@ -2,6 +2,8 @@ import neo.Renderer.Model.srfTriangles_s; import neo.Renderer.tr_local.drawSurf_s; + +import static neo.Renderer.RenderSystem_init.r_skipGuiShaders; import static neo.Renderer.tr_local.tr; import static neo.Renderer.tr_main.myGlMultMatrix; import neo.framework.CmdSystem.cmdFunction_t; @@ -117,10 +119,10 @@ public static void R_SurfaceToTextureAxis(final srfTriangles_s tri, idVec3 origi */ public static void R_RenderGuiSurf(idUserInterface gui, drawSurf_s drawSurf) { idVec3 origin = new idVec3(); - idVec3[] axis = new idVec3[3]; + idVec3[] axis = {new idVec3(), new idVec3(), new idVec3()}; // for testing the performance hit - if (RenderSystem_init.r_skipGuiShaders.GetInteger() == 1) { + if (r_skipGuiShaders.GetInteger() == 1) { return; } diff --git a/src/main/java/neo/Renderer/tr_lightrun.java b/src/main/java/neo/Renderer/tr_lightrun.java index c9915db2..bf2d8209 100644 --- a/src/main/java/neo/Renderer/tr_lightrun.java +++ b/src/main/java/neo/Renderer/tr_lightrun.java @@ -287,7 +287,7 @@ public static void R_SetLightProject(idPlane[] lightProject/*[4]*/, final idVec3 lightProject[1].oSet(3, -(origin.oMultiply(lightProject[1].Normal()))); // now offset to center - targetGlobal.ToVec3().oSet(target.oPluSet(origin)); + targetGlobal.oSet(target.oPluSet(origin)); targetGlobal.oSet(3, 1); ofs = 0.5f - (targetGlobal.oMultiply(lightProject[0].ToVec4())) / (targetGlobal.oMultiply(lightProject[2].ToVec4())); lightProject[0].ToVec4().oPluSet(lightProject[2].ToVec4().oMultiply(ofs)); diff --git a/src/main/java/neo/Renderer/tr_local.java b/src/main/java/neo/Renderer/tr_local.java index d17b435c..3e174fbf 100644 --- a/src/main/java/neo/Renderer/tr_local.java +++ b/src/main/java/neo/Renderer/tr_local.java @@ -38,6 +38,7 @@ import neo.idlib.math.Vector.idVec2; import neo.idlib.math.Vector.idVec3; import neo.idlib.math.Vector.idVec4; +import org.lwjgl.BufferUtils; import java.io.IOException; import java.nio.ByteBuffer; @@ -2379,7 +2380,7 @@ public void CaptureRenderToFile(String fileName, boolean fixAlpha) { // include extra space for OpenGL padding to word boundaries int c = (rc.width + 3) * rc.height; - ByteBuffer data = ByteBuffer.allocate(c * 3);// R_StaticAlloc(c * 3); + ByteBuffer data = BufferUtils.createByteBuffer(c * 3);// R_StaticAlloc(c * 3); qglReadPixels(rc.x, rc.y, rc.width, rc.height, GL_RGB, GL_UNSIGNED_BYTE, data); diff --git a/src/main/java/neo/Renderer/tr_stencilshadow.java b/src/main/java/neo/Renderer/tr_stencilshadow.java index e5db4e35..efd17acf 100644 --- a/src/main/java/neo/Renderer/tr_stencilshadow.java +++ b/src/main/java/neo/Renderer/tr_stencilshadow.java @@ -1,6 +1,8 @@ package neo.Renderer; import java.util.Arrays; +import java.util.stream.Stream; + import static neo.Renderer.Interaction.R_CalcInteractionFacing; import neo.Renderer.Interaction.srfCullInfo_t; import neo.Renderer.Model.silEdge_t; @@ -173,7 +175,7 @@ static boolean POINT_CULLED(final int p1, final int[] pointCull) { static int numShadowIndexes; static int/*glIndex_t*/[] shadowIndexes = new int[MAX_SHADOW_INDEXES]; static int numShadowVerts; - static final idVec4[] shadowVerts = new idVec4[MAX_SHADOW_VERTS]; + static final idVec4[] shadowVerts = Stream.generate(idVec4::new).limit(MAX_SHADOW_VERTS).toArray(idVec4[]::new); static boolean overflowed; // static final idPlane[][] pointLightFrustums/*[6][6]*/ = { @@ -239,7 +241,7 @@ static class indexRef_t { int silStart; int end; }; - static indexRef_t[] indexRef = new indexRef_t[6]; + static indexRef_t[] indexRef = Stream.generate(indexRef_t::new).limit(6).toArray(indexRef_t[]::new); static int indexFrustumNumber; // which shadow generating side of a light the indexRef is for // /* @@ -327,7 +329,7 @@ public static void R_ProjectPointsToFarPlane(final idRenderEntityLocal ent, fina final idPlane lightPlaneLocal, int firstShadowVert, int numShadowVerts) { idVec3 lv = new idVec3(); - idVec4[] mat = new idVec4[4]; + idVec4[] mat = Stream.generate(idVec4::new).limit(4).toArray(idVec4[]::new); int i; int in; @@ -483,7 +485,7 @@ public static int R_ChopWinding(clipTri_t[] clipTris/*[2]*/, int inNum, final id public static boolean R_ClipTriangleToLight(final idVec3 a, final idVec3 b, final idVec3 c, int planeBits, final idPlane[] frustum/*[6] */) { int i; int base; - clipTri_t[] pingPong = new clipTri_t[2]; + clipTri_t[] pingPong = {new clipTri_t(), new clipTri_t()}; clipTri_t ct; int p; @@ -514,7 +516,7 @@ public static boolean R_ClipTriangleToLight(final idVec3 a, final idVec3 b, fina base = numShadowVerts; for (i = 0; i < ct.numVerts; i++) { - shadowVerts[ base + i * 2].ToVec3().oSet(ct.verts[i]); + shadowVerts[base + i * 2].oSet(ct.verts[i]); } numShadowVerts += ct.numVerts * 2; @@ -773,7 +775,7 @@ public static void R_AddSilEdges(final srfTriangles_s tri, int[] pointCull, fina ================ */ public static void R_CalcPointCull(final srfTriangles_s tri, final idPlane[] frustum/*[6]*/, int[] pointCull) { - byte i; + int i; int frontBits; float[] planeSide; byte[] side1, side2; @@ -810,8 +812,8 @@ public static void R_CalcPointCull(final srfTriangles_s tri, final idPlane[] fru } SIMDProcessor.Dot(planeSide, frustum[i], tri.verts, tri.numVerts); - SIMDProcessor.CmpLT(side1, i, planeSide, LIGHT_CLIP_EPSILON, tri.numVerts); - SIMDProcessor.CmpGT(side2, i, planeSide, -LIGHT_CLIP_EPSILON, tri.numVerts); + SIMDProcessor.CmpLT(side1, (byte) i, planeSide, LIGHT_CLIP_EPSILON, tri.numVerts); + SIMDProcessor.CmpGT(side2, (byte) i, planeSide, -LIGHT_CLIP_EPSILON, tri.numVerts); } for (i = 0; i < tri.numVerts; i++) { pointCull[i] |= side1[i] | (side2[i] << 6); @@ -893,17 +895,17 @@ public static void R_CreateShadowVolumeInFrustum(final idRenderEntityLocal ent, if (!POINT_CULLED(i1, pointCull) && remap[i1] == -1) { remap[i1] = numShadowVerts; - shadowVerts[numShadowVerts].ToVec3().oSet(tri.verts[i1].xyz); + shadowVerts[numShadowVerts].oSet(tri.verts[i1].xyz); numShadowVerts += 2; } if (!POINT_CULLED(i2, pointCull) && remap[i2] == -1) { remap[i2] = numShadowVerts; - shadowVerts[numShadowVerts].ToVec3().oSet(tri.verts[i2].xyz); + shadowVerts[numShadowVerts].oSet(tri.verts[i2].xyz); numShadowVerts += 2; } if (!POINT_CULLED(i3, pointCull) && remap[i3] == -1) { remap[i3] = numShadowVerts; - shadowVerts[numShadowVerts].ToVec3().oSet(tri.verts[i3].xyz); + shadowVerts[numShadowVerts].oSet(tri.verts[i3].xyz); numShadowVerts += 2; } @@ -1312,6 +1314,7 @@ public static srfTriangles_s R_CreateShadowVolume(final idRenderEntityLocal ent, // the cull test is redundant for a single shadow frustum projected light, because // the surface has already been checked against the main light frustums for (j = 0; j < frust.numPlanes; j++) { + frustum[j] = new idPlane(); R_GlobalPlaneToLocal(ent.modelMatrix, frust.planes[j], frustum[j]); // try to cull the entire surface against this frustum diff --git a/src/main/java/neo/Tools/Compilers/DMap/shadowopt3.java b/src/main/java/neo/Tools/Compilers/DMap/shadowopt3.java index e605fabb..f194743d 100644 --- a/src/main/java/neo/Tools/Compilers/DMap/shadowopt3.java +++ b/src/main/java/neo/Tools/Compilers/DMap/shadowopt3.java @@ -1176,7 +1176,7 @@ public static void CleanupOptimizedShadowTris(srfTriangles_s tri) { } tri.numVerts = numUniqued; for (i = 0; i < tri.numVerts; i++) { - tri.shadowVertexes[i].xyz.ToVec3().oSet(uniqued[i]); + tri.shadowVertexes[i].xyz.oSet(uniqued[i]); tri.shadowVertexes[i].xyz.oSet(3, 1); } diff --git a/src/main/java/neo/Tools/Compilers/DMap/usurface.java b/src/main/java/neo/Tools/Compilers/DMap/usurface.java index 2d024278..f6fadf93 100644 --- a/src/main/java/neo/Tools/Compilers/DMap/usurface.java +++ b/src/main/java/neo/Tools/Compilers/DMap/usurface.java @@ -153,14 +153,14 @@ static void TexVecForTri(textureVectors_t texVec, mapTri_s tri) { temp.oSet(1, (d0.oGet(1) * d1.oGet(4) - d0.oGet(4) * d1.oGet(1)) * inva); temp.oSet(2, (d0.oGet(2) * d1.oGet(4) - d0.oGet(4) * d1.oGet(2)) * inva); temp.Normalize(); - texVec.v[0].ToVec3().oSet(temp); + texVec.v[0].oSet(temp); texVec.v[0].oSet(3, tri.v[0].xyz.oMultiply(texVec.v[0].ToVec3()) - tri.v[0].st.oGet(0)); temp.oSet(0, (d0.oGet(3) * d1.oGet(0) - d0.oGet(0) * d1.oGet(3)) * inva); temp.oSet(1, (d0.oGet(3) * d1.oGet(1) - d0.oGet(1) * d1.oGet(3)) * inva); temp.oSet(2, (d0.oGet(3) * d1.oGet(2) - d0.oGet(2) * d1.oGet(3)) * inva); temp.Normalize(); - texVec.v[1].ToVec3().oSet(temp); + texVec.v[1].oSet(temp); texVec.v[1].oSet(3, tri.v[0].xyz.oMultiply(texVec.v[0].ToVec3()) - tri.v[0].st.oGet(1)); } diff --git a/src/main/java/neo/idlib/math/Simd.java b/src/main/java/neo/idlib/math/Simd.java index 3b5164d0..29f9f378 100644 --- a/src/main/java/neo/idlib/math/Simd.java +++ b/src/main/java/neo/idlib/math/Simd.java @@ -2,7 +2,10 @@ import java.nio.FloatBuffer; import java.util.Arrays; + +import neo.Renderer.Model; import neo.Renderer.Model.dominantTri_s; +import neo.Renderer.Model.shadowCache_s; import neo.TempDump.TODO_Exception; import neo.framework.CmdSystem; import neo.framework.CmdSystem.cmdFunction_t; @@ -361,6 +364,12 @@ public idSIMDProcessor() { public abstract void /*VPCALL*/ Memcpy(Object[] dst, final Object[] src, final int count); + public void /*VPCALL*/ Memcpy(shadowCache_s[] dst, final idVec4[] src, final int count) { + for (int i = 0; i < count; i++) { + dst[i].xyz.oSet(src[i]); + } + } + public void /*VPCALL*/ Memcpy(Object dst, final Object src, final int count) { throw new TODO_Exception(); } @@ -489,7 +498,7 @@ public void Memset(byte[] cullBits, int i, int numVerts) { } public void Memset(int[] cullBits, int i, int numVerts) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + Arrays.fill(cullBits, 0, numVerts, i); } public void CmpGE(byte[] facing, float[] planeSide, float f, int numFaces) { @@ -505,12 +514,12 @@ public void CmpGE(byte[] facing, float[] planeSide, float f, int numFaces) { } } - public void Memcpy(int[] indexes, int[] tempIndexes, int numShadowIndexes) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public void Memcpy(int[] dst, int[] src, int count) { + Memcpy(dst, 0, src, 0, count); } - public void Memcpy(int[] indexes, int indexOffset, int[] tempIndexes, int tempOffset, int numShadowIndexes) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public void Memcpy(int[] dst, int dstOffset, int[] src, int srcOffset, int count) { + System.arraycopy(src, srcOffset, dst, dstOffset, count); } }; diff --git a/src/main/java/neo/idlib/math/Vector.java b/src/main/java/neo/idlib/math/Vector.java index 3654c730..91da9033 100644 --- a/src/main/java/neo/idlib/math/Vector.java +++ b/src/main/java/neo/idlib/math/Vector.java @@ -1402,6 +1402,13 @@ public idVec4 oSet(final idVec4 a) { return this; } + public idVec4 oSet(final idVec3 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + return this; + } + @Override public float oGet(final int i) {//TODO:rename you lazy ass switch (i) { From c9156bc9ab10142b77f1afc94cdd9c0fa92d117c Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Wed, 25 May 2016 20:49:39 +0200 Subject: [PATCH 14/17] =?UTF-8?q?-still=20too=20dark,=20but=20ingame=20is?= =?UTF-8?q?=20no=20longer=20blank...=20=20=20\(=CB=86=CB=9A=CB=86)/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/neo/Game/Player.java | 4 ++-- src/main/java/neo/Renderer/RenderSystem_init.java | 2 +- src/main/java/neo/Renderer/qgl.java | 2 ++ src/main/java/neo/idlib/math/Angles.java | 9 +++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/neo/Game/Player.java b/src/main/java/neo/Game/Player.java index 974d1d1a..83528ce4 100644 --- a/src/main/java/neo/Game/Player.java +++ b/src/main/java/neo/Game/Player.java @@ -4138,10 +4138,10 @@ public void GetViewPos(idVec3 origin, idMat3 axis) { axis.oSet(angles.ToMat3());//TODO:null check origin.oSet(GetEyePosition()); } else { - origin = GetEyePosition().oPlus(viewBob); + origin.oSet(GetEyePosition().oPlus(viewBob)); angles = viewAngles.oPlus(viewBobAngles).oPlus(playerView.AngleOffset()); - axis = angles.ToMat3().oMultiply(physicsObj.GetGravityAxis()); + axis.oSet(angles.ToMat3().oMultiply(physicsObj.GetGravityAxis())); // adjust the origin based on the camera nodal distance (eye distance from neck) origin.oPluSet(physicsObj.GetGravityNormal().oMultiply(g_viewNodalZ.GetFloat())); diff --git a/src/main/java/neo/Renderer/RenderSystem_init.java b/src/main/java/neo/Renderer/RenderSystem_init.java index c52914e1..42ce49c7 100644 --- a/src/main/java/neo/Renderer/RenderSystem_init.java +++ b/src/main/java/neo/Renderer/RenderSystem_init.java @@ -462,7 +462,7 @@ public class RenderSystem_init { r_showInteractionScissors = new idCVar("r_showInteractionScissors", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = show screen rectangle which contains the interaction frustum, 2 = also draw construction lines", 0, 2, new idCmdSystem.ArgCompletion_Integer(0, 2)); r_showLightCount = new idCVar("r_showLightCount", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = colors surfaces based on light count, 2 = also count everything through walls, 3 = also print overdraw", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); r_showViewEntitys = new idCVar("r_showViewEntitys", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = displays the bounding boxes of all view models, 2 = print index numbers"); - r_showTris = new idCVar("r_showTris", "1", CVAR_RENDERER | CVAR_INTEGER, "enables wireframe rendering of the world, 1 = only draw visible ones, 2 = draw all front facing, 3 = draw all", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); + r_showTris = new idCVar("r_showTris", "3", CVAR_RENDERER | CVAR_INTEGER, "enables wireframe rendering of the world, 1 = only draw visible ones, 2 = draw all front facing, 3 = draw all", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); r_showSurfaceInfo = new idCVar("r_showSurfaceInfo", "0", CVAR_RENDERER | CVAR_BOOL, "show surface material name under crosshair"); r_showNormals = new idCVar("r_showNormals", "0", CVAR_RENDERER | CVAR_FLOAT, "draws wireframe normals"); r_showMemory = new idCVar("r_showMemory", "0", CVAR_RENDERER | CVAR_BOOL, "print frame memory utilization"); diff --git a/src/main/java/neo/Renderer/qgl.java b/src/main/java/neo/Renderer/qgl.java index 1ee769eb..823bd98f 100644 --- a/src/main/java/neo/Renderer/qgl.java +++ b/src/main/java/neo/Renderer/qgl.java @@ -18,6 +18,7 @@ import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.NVRegisterCombiners; +import org.lwjgl.opengl.Util; /** * so yeah, it's easier to use this class as an interface. rather than refactor @@ -1805,6 +1806,7 @@ public static void qglVertexPointer(int size, int type, int stride, float[] poin private static void DEBUG_printName(final String functionName) { if (GL_DEBUG) { System.out.println(functionName); + Util.checkGLError(); } } diff --git a/src/main/java/neo/idlib/math/Angles.java b/src/main/java/neo/idlib/math/Angles.java index 317bdca7..d45a6dea 100644 --- a/src/main/java/neo/idlib/math/Angles.java +++ b/src/main/java/neo/idlib/math/Angles.java @@ -457,6 +457,15 @@ public String ToString(int precision) { return idStr.FloatArrayToString(ToFloatPtr(), GetDimension(), precision); } + @Override + public String toString() { + return "idAngles{" + + "pitch=" + pitch + + ", yaw=" + yaw + + ", roll=" + roll + + '}'; + } + @Override public ByteBuffer AllocBuffer() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. From d39ae5b2d6ca07caeef2b18a975df24d9ad17007 Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Wed, 25 May 2016 20:49:39 +0200 Subject: [PATCH 15/17] =?UTF-8?q?-still=20too=20dark,=20but=20ingame=20is?= =?UTF-8?q?=20no=20longer=20blank...=20=20=20\(=CB=86=CB=9A=CB=86)/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/neo/Game/Player.java | 4 +-- .../java/neo/Renderer/RenderSystem_init.java | 2 +- src/main/java/neo/Renderer/draw_arb2.java | 30 ++++++++++--------- src/main/java/neo/Renderer/draw_common.java | 9 +++--- src/main/java/neo/Renderer/qgl.java | 11 ++++--- src/main/java/neo/idlib/math/Angles.java | 9 ++++++ 6 files changed, 39 insertions(+), 26 deletions(-) diff --git a/src/main/java/neo/Game/Player.java b/src/main/java/neo/Game/Player.java index 974d1d1a..83528ce4 100644 --- a/src/main/java/neo/Game/Player.java +++ b/src/main/java/neo/Game/Player.java @@ -4138,10 +4138,10 @@ public void GetViewPos(idVec3 origin, idMat3 axis) { axis.oSet(angles.ToMat3());//TODO:null check origin.oSet(GetEyePosition()); } else { - origin = GetEyePosition().oPlus(viewBob); + origin.oSet(GetEyePosition().oPlus(viewBob)); angles = viewAngles.oPlus(viewBobAngles).oPlus(playerView.AngleOffset()); - axis = angles.ToMat3().oMultiply(physicsObj.GetGravityAxis()); + axis.oSet(angles.ToMat3().oMultiply(physicsObj.GetGravityAxis())); // adjust the origin based on the camera nodal distance (eye distance from neck) origin.oPluSet(physicsObj.GetGravityNormal().oMultiply(g_viewNodalZ.GetFloat())); diff --git a/src/main/java/neo/Renderer/RenderSystem_init.java b/src/main/java/neo/Renderer/RenderSystem_init.java index c52914e1..42ce49c7 100644 --- a/src/main/java/neo/Renderer/RenderSystem_init.java +++ b/src/main/java/neo/Renderer/RenderSystem_init.java @@ -462,7 +462,7 @@ public class RenderSystem_init { r_showInteractionScissors = new idCVar("r_showInteractionScissors", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = show screen rectangle which contains the interaction frustum, 2 = also draw construction lines", 0, 2, new idCmdSystem.ArgCompletion_Integer(0, 2)); r_showLightCount = new idCVar("r_showLightCount", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = colors surfaces based on light count, 2 = also count everything through walls, 3 = also print overdraw", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); r_showViewEntitys = new idCVar("r_showViewEntitys", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = displays the bounding boxes of all view models, 2 = print index numbers"); - r_showTris = new idCVar("r_showTris", "1", CVAR_RENDERER | CVAR_INTEGER, "enables wireframe rendering of the world, 1 = only draw visible ones, 2 = draw all front facing, 3 = draw all", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); + r_showTris = new idCVar("r_showTris", "3", CVAR_RENDERER | CVAR_INTEGER, "enables wireframe rendering of the world, 1 = only draw visible ones, 2 = draw all front facing, 3 = draw all", 0, 3, new idCmdSystem.ArgCompletion_Integer(0, 3)); r_showSurfaceInfo = new idCVar("r_showSurfaceInfo", "0", CVAR_RENDERER | CVAR_BOOL, "show surface material name under crosshair"); r_showNormals = new idCVar("r_showNormals", "0", CVAR_RENDERER | CVAR_FLOAT, "draws wireframe normals"); r_showMemory = new idCVar("r_showMemory", "0", CVAR_RENDERER | CVAR_BOOL, "print frame memory utilization"); diff --git a/src/main/java/neo/Renderer/draw_arb2.java b/src/main/java/neo/Renderer/draw_arb2.java index 9c00665a..f570f2e0 100644 --- a/src/main/java/neo/Renderer/draw_arb2.java +++ b/src/main/java/neo/Renderer/draw_arb2.java @@ -9,7 +9,6 @@ import static neo.Renderer.RenderSystem_init.r_useScissor; import static neo.Renderer.RenderSystem_init.r_useShadowVertexProgram; import static neo.Renderer.VertexCache.vertexCache; -import neo.Renderer.draw_arb2.R_ReloadARBPrograms_f; import static neo.Renderer.draw_common.RB_StencilShadowPass; import static neo.Renderer.qgl.qglActiveTextureARB; import static neo.Renderer.qgl.qglBindProgramARB; @@ -63,6 +62,8 @@ import static neo.Renderer.tr_local.program_t.FPROG_GLASSWARP; import static neo.Renderer.tr_local.program_t.FPROG_INTERACTION; import static neo.Renderer.tr_local.program_t.FPROG_TEST; +import static neo.Renderer.tr_local.program_t.PROG_INVALID; +import static neo.Renderer.tr_local.program_t.PROG_USER; import static neo.Renderer.tr_local.program_t.VPROG_AMBIENT; import static neo.Renderer.tr_local.program_t.VPROG_BUMPY_ENVIRONMENT; import static neo.Renderer.tr_local.program_t.VPROG_ENVIRONMENT; @@ -81,7 +82,6 @@ import static neo.Renderer.tr_render.RB_DrawElementsWithCounters; import static neo.TempDump.NOT; import neo.TempDump.TODO_Exception; -import static neo.TempDump.etoi; import static neo.TempDump.isNotNullOrEmpty; import neo.framework.CmdSystem.cmdFunction_t; import static neo.framework.Common.common; @@ -417,19 +417,22 @@ && NOT(vLight.translucentInteractions[0])) { //=================================================================================== static class progDef_t { - int target; - program_t ident; - // char name[64]; - String name; + int target; + int ident; + String name;// char name[64]; - public progDef_t(int target, program_t ident, String name) { + progDef_t(int target, program_t ident, String name) { + this(target, ident.ordinal(), name); + } + + progDef_t(int target, int ident, String name) { this.target = target; this.ident = ident; this.name = name; } }; static final int MAX_GLPROGS = 200; -// a single file can have both a vertex program and a fragment program + // a single file can have both a vertex program and a fragment program static progDef_t[] progs = new progDef_t[MAX_GLPROGS]; static { @@ -491,10 +494,9 @@ public static void R_LoadARBProgram(int progIndex) { // // submit the program string at start to GL // - if (etoi(progs[progIndex].ident) == 0) { + if (progs[progIndex].ident == PROG_INVALID.ordinal()) { // allocate a new identifier for this program - throw new TODO_Exception(); -// progs[progIndex].ident = PROG_USER + progIndex; + progs[progIndex].ident = PROG_USER.ordinal() + progIndex; } // vertex and fragment programs can both be present in a single file, so @@ -576,7 +578,7 @@ public static int R_FindARBProgram( /*GLenum */int target, final String program) compare.StripFileExtension(); if (NOT(idStr.Icmp(stripped, compare))) { - return etoi(progs[i].ident); + return progs[i].ident; } } @@ -585,11 +587,11 @@ public static int R_FindARBProgram( /*GLenum */int target, final String program) } // add it to the list and load it - progs[i] = new progDef_t(target, FPROG_TEST, program);// will be gen'd by R_LoadARBProgram + progs[i] = new progDef_t(target, PROG_INVALID, program);// will be gen'd by R_LoadARBProgram R_LoadARBProgram(i); - return etoi(progs[i].ident); + return progs[i].ident; } /* diff --git a/src/main/java/neo/Renderer/draw_common.java b/src/main/java/neo/Renderer/draw_common.java index 6f7ea641..5c3c9915 100644 --- a/src/main/java/neo/Renderer/draw_common.java +++ b/src/main/java/neo/Renderer/draw_common.java @@ -155,7 +155,6 @@ import neo.idlib.geometry.DrawVert.idDrawVert; import neo.idlib.math.Math_h.idMath; import neo.idlib.math.Plane.idPlane; -import neo.idlib.math.Vector; import neo.idlib.math.Vector.idVec3; import neo.idlib.math.Vector.idVec4; import org.lwjgl.BufferUtils; @@ -1264,11 +1263,11 @@ void run(final drawSurf_s surf) { // set the light position if we are using a vertex program to project the rear surfaces if (tr.backEndRendererHasVertexPrograms && r_useShadowVertexProgram.GetBool() && surf.space != backEnd.currentSpace) { - idVec4 localLight = new Vector.idVec4(); - FloatBuffer lightBuffer = (FloatBuffer) BufferUtils.createFloatBuffer(4).put(localLight.ToFloatPtr()).rewind(); + idVec4 localLight = new idVec4(); + FloatBuffer lightBuffer = BufferUtils.createFloatBuffer(4); - R_GlobalPointToLocal(surf.space.modelMatrix, backEnd.vLight.globalLightOrigin, localLight.ToVec3()); - localLight.w = 0.0f; + R_GlobalPointToLocal(surf.space.modelMatrix, backEnd.vLight.globalLightOrigin, localLight); + lightBuffer.put(localLight.ToFloatPtr()).rewind();//localLight.w = 0.0f; qglProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, PP_LIGHT_ORIGIN, lightBuffer); } diff --git a/src/main/java/neo/Renderer/qgl.java b/src/main/java/neo/Renderer/qgl.java index 1ee769eb..ca8024f9 100644 --- a/src/main/java/neo/Renderer/qgl.java +++ b/src/main/java/neo/Renderer/qgl.java @@ -18,6 +18,7 @@ import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.NVRegisterCombiners; +import org.lwjgl.opengl.Util; /** * so yeah, it's easier to use this class as an interface. rather than refactor @@ -25,9 +26,10 @@ */ public class qgl { - static final boolean qGL_FALSE = false; - static final boolean qGL_TRUE = true; - private static final boolean GL_DEBUG = false; + private static final boolean GL_DEBUG = true; + + static final boolean qGL_FALSE = false; + static final boolean qGL_TRUE = true; // // // multitexture @@ -793,7 +795,7 @@ public static int qglGenLists(Enum range) { throw new UnsupportedOperationException("Not supported yet."); } - public static int qglGetError() {DEBUG_printName("glGetError"); + public static int qglGetError() {//DEBUG_printName("glGetError"); return GL11.glGetError(); } @@ -1804,6 +1806,7 @@ public static void qglVertexPointer(int size, int type, int stride, float[] poin private static void DEBUG_printName(final String functionName) { if (GL_DEBUG) { + Util.checkGLError(); System.out.println(functionName); } } diff --git a/src/main/java/neo/idlib/math/Angles.java b/src/main/java/neo/idlib/math/Angles.java index 317bdca7..d45a6dea 100644 --- a/src/main/java/neo/idlib/math/Angles.java +++ b/src/main/java/neo/idlib/math/Angles.java @@ -457,6 +457,15 @@ public String ToString(int precision) { return idStr.FloatArrayToString(ToFloatPtr(), GetDimension(), precision); } + @Override + public String toString() { + return "idAngles{" + + "pitch=" + pitch + + ", yaw=" + yaw + + ", roll=" + roll + + '}'; + } + @Override public ByteBuffer AllocBuffer() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. From 4bb017d3c22ef587e0d4cba2c6dc2f0582a43e22 Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Thu, 26 May 2016 12:09:20 +0200 Subject: [PATCH 16/17] Release prep. --- README.md | 17 +++++++++++++++-- src/main/java/neo/Renderer/qgl.java | 3 +-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 786d75b8..943498ff 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,19 @@ #djoom3 - a Doom 3 Java port. +####23-05-16 +Version 0.0.6 + +ingame BANZAI! + +Too dark, and lots and LOTS of graphics bugs though, but who cares. + +Check the 2nd half of the video for the wireframe rendering, to see what's actually going on. + +[http://www.youtube.com/watch?v=vudRn5F0Z3w](http://www.youtube.com/watch?v=vudRn5F0Z3w) +[![Screenshot](http://img.youtube.com/vi/vudRn5F0Z3w/0.jpg)](http://www.youtube.com/watch?v=vudRn5F0Z3w"djoom3 0.0.6") + + ####23-03-16 Version 0.0.5 @@ -20,9 +33,9 @@ Version 0.0.4 ####05-02-15: -Initial non playable release. -![http://wiki.djoom3.googlecode.com/git/init_menus.png](http://wiki.djoom3.googlecode.com/git/init_menus.png) +![https://raw.githubusercontent.com/blackbeard334/djoom3/wiki/init_menus.png](https://raw.githubusercontent.com/blackbeard334/djoom3/wiki/init_menus.png) -![http://wiki.djoom3.googlecode.com/git/title.png](http://wiki.djoom3.googlecode.com/git/title.png) +![https://raw.githubusercontent.com/blackbeard334/djoom3/wiki/title.png](https://raw.githubusercontent.com/blackbeard334/djoom3/wiki/title.png) diff --git a/src/main/java/neo/Renderer/qgl.java b/src/main/java/neo/Renderer/qgl.java index 76e545b5..3ae3ec47 100644 --- a/src/main/java/neo/Renderer/qgl.java +++ b/src/main/java/neo/Renderer/qgl.java @@ -26,7 +26,7 @@ */ public class qgl { - private static final boolean GL_DEBUG = true; + private static final boolean GL_DEBUG = false; static final boolean qGL_FALSE = false; static final boolean qGL_TRUE = true; @@ -1808,7 +1808,6 @@ private static void DEBUG_printName(final String functionName) { if (GL_DEBUG) { Util.checkGLError(); System.out.println(functionName); - Util.checkGLError(); } } From 486bee67b2ed9be4c1d5fdf064ed96b82bc9cc21 Mon Sep 17 00:00:00 2001 From: blackbeard334 Date: Thu, 26 May 2016 12:09:20 +0200 Subject: [PATCH 17/17] Release prep. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 943498ff..1a82a283 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ ####23-05-16 Version 0.0.6 -ingame BANZAI! +**ingame BANZAI!** Too dark, and lots and LOTS of graphics bugs though, but who cares. Check the 2nd half of the video for the wireframe rendering, to see what's actually going on. -[http://www.youtube.com/watch?v=vudRn5F0Z3w](http://www.youtube.com/watch?v=vudRn5F0Z3w) +[http://www.youtube.com/watch?v=vudRn5F0Z3w](http://www.youtube.com/watch?v=vudRn5F0Z3w) [![Screenshot](http://img.youtube.com/vi/vudRn5F0Z3w/0.jpg)](http://www.youtube.com/watch?v=vudRn5F0Z3w"djoom3 0.0.6")