Changes in Q2Java 0.9.7

It's been a long time since the previous version, and this one contains many minor bugfixes and tweaks, along with some big reorganizations that made things cleaner and clearer.

The damage event system was reworked to also function for non-Player objects. Everything that was named *PlayerDamage* was renamed to just *Damage*. All fields and methods that were geared to the Player class were changed to work for the more general GameObject class. A huge number of classes were affected by these changes but for the most part, they were of the search-and-replace type of thing that can be fixed in a matter of minutes. The q2java.baseq2.Player class in particular had a slew of "PlayerDamage" fields and methods that were for the most part simply renamed.

As part of the damage-system change, all objects had their damage() methods replaced with versions that take a single DamageEvent object, instead of a slew of parameters. The GameObject class still has a method for initiating damage with a slew of parameters, but that simply creates a DamageEvent object and passes it on through the new event-system.

The q2java.baseq2.GenericItem class had a nice overhaul, simplifying its internal structure greatly, and removing any potential conflicts with its subclasses that wanted to receive ServerFrameListener.runFrame() calls (which the old GenericItem class also wanted to do).

Changes to DLL
Fix Barry | Fixed a pretty serious problem in the native implementation of Engine.getRadiusEntities() where if there were more than 32 "hits", you overran a buffer and potentially could crash the game. Even if you don't want to adopt the new Java code in this version, at least use the new DLL so you can avoid this problem.
Changes in Java Classes
q2java.NativeEntity
Added Barry | getMaxPlayers() to find out what is the max number of players the server is configured for.
Added Barry | isValid() for finding out whether a NativeEntity is actually bound to the underlying engine, or has been freed and is kind of a ghost.
q2java.baseq2.DamageObject
Removed Barry | This class was no longer being used, it was replaced back around version 0.9.0, but I guess I forgot to delete this file.
q2java.baseq2.DropHelper
Added Barry | This is a new class, basically the code from GenericItem that caused items to fall to the ground, separated out so it can be used by other classes.
Added Barry | I messed around with the dropping code a bit, trying to make it a bit more realistic when you drop items into water. I tried to add some splashing, slow down the item when it hit the surface, and caused it to sink slower when in water. This changes things a bit from stock Q2, but should be easy to take out if it's a problem.
q2java.baseq2.GenericGrenade
Added Barry | Another variation of the toss() method was added, to make it easy for non-Player objects to toss Grenades.
q2java.baseq2.GenericItem
Change Barry | This class was heavily reworked, making it much easier to understand and maintain. Basically, all code relating to time was stripped out and moved to helper classes, such as the DropHelper mentioned above, and some inner classes. Previously an elaborate finite-state-machine managed a complex system of animations, drop timeouts, and (re)spawning timers - but that's all gone now. This class no longer implements ServerFrameListener, which means that subclasses that implement that interface don't have to worry anymore about conflicting with this parent class (the powerups such as the Quad and rebreather are examples of those subclasses).
Added Barry | Added a "droppable" property to the class, with a setDroppable() method. Previously there was an isDroppable() method that always returned true, but was overridden by some items such as the plain blaster and CTF grapple. Now, those classes just call setDroppable(false) in their constructors, and don't override isDroppable(). This made it easy for a mod to make -all- weapons non-droppable, without having to change each weapon's code. (this is one of those improvements where you wonder what the hell you were thinking when you wrote the old code).
q2java.baseq2.GenericWeapon
Added Barry | Added isAutoSwitch() and setAutoSwitch() to control whether or not a weapon automatically switches away when ammo runs out (the default is "true").
q2java.baseq2.InventoryList
Fix Barry | addAfterIndex() wasn't calling Engine.setConfigString(), which meant additions weren't showing up on the clients if they didn't happen at a certain time. Reworked that method, and also changed addBeforeIndex() to be just about identical.
q2java.baseq2.InventoryPack
Change Barry | Changed field declarations to "public", used to be just default.
q2java.baseq2.MiscUtil
Added Barry | Added an explode() method, for a convenient way to make things go "boom".
Change Barry | radiusDamage() takes a NativeEntity instead of a GameObject for its "ignore" parameter
Fix Barry | radiusDamage() now causes damage to all types of GameObjects, not just players
q2java.baseq2.Player
Added Barry | playerJumped() is now called when players jump - making it easy for subclasses to do different things when players jump, without having to futz with playerThink()
Fix Barry | cmd_drop() prints a warning if an argument is not supplied (used to throw an exception)
Change Barry | The "health" property was changed from an integer to a floating-point value - making it easy to make fractional changes to health.
Added Barry | The player class now keeps copies of the last forwardMove, sideMove, and upMove values from playerThink() - so other methods in Player and its subclasses can check on how the player is moving.
q2java.baseq2.event.PlayerStateListener
Change Barry | stateChanged() renamed to playerStateChanged(), for consistency and clarity. A large number of classes had to be tweaked to use the new method name.
q2java.baseq2.gui.PlayerMenu
Fix Barry | The commandIssued() method was not consuming commands, which meant that in menus such as in CTF, the TAB key wasn't causing the menu to disappear (actually it was disappearing and instantly being brought back up again).
q2java.baseq2.spawn.item_*
Change Barry | Any classes such as the Quad, that implement ServerFrameListener, now do so by themselves without any interference from their parent "GenericItem" class.
q2java.baseq2.spawn.weapon_*
Change Barry | Most weapons now check their new "autoSwitch" property when they run out of ammo, before initiating a weapon-switch.
q2java.core.Game
Change Barry | The "status" document now includes the name of the map and the name of the server.
q2java.core.XMLTools
Change Barry | another version of writeXMLDocument() takes a third parameter to give a hint about how you want the output document formatted, XMLTools.OUTPUT_PRETTY for nice-looking docs, or XMLTools.OUTPUT_COMPACT for ones where you don't want extra whitespace.
q2java.core.(Open)XMLFactory
Change Barry | XMLFactory interface and OpenXMLFactory class altered to take the third output format hint mentioned above.
q2java.ctf.(Techs + GenericFlag)
Change Barry | The CTF techs and Flags also benefited from the changes to q2java.baseq2.GenericItem in that they no longer have to worry runFrame() calls intended for their superclass.
q2java.ctf.CTF
Fix Barry | The HUD string is now set during the Game.POSTSPAWN phase instead of PRESPAWN, so it's not overriden by the plain Deathmatch HUD.

Q2Java homepage