P_RandomChance is now a macro for something that should happen a
certain percentage of time.
P_SignedRandom was moved to a macro. Nobody cared.
# Conflicts:
# src/p_inter.c
This actually passes most diehard tests, as opposed to the old RNG.
It's also similarly fast.
Internally the PRNG generates a fixed point number from [0,1) now,
which makes P_RandomKey and P_RandomRange much easier to
calculate. P_Random is just a simple shift, as well.
Also, the lack of floating point math in P_RandomKey and
P_RandomRange now is probably for the best.
Also makes comptime.bat work with git if able.
Development builds will now show the branch and the SHA1 hash of the revision. Also been tested to work with subversion, where it displays "Subversion r####". You know, just in case.
There is a caveat to this: The first time EvalMath is used, a
deprecated function warning will be shown to the user that tells
them to use _G[] instead.
This reverts commit 9d36cf37bd.
This appears to fix a few holes that have been known to appear with FOF slopes sometimes, dunno how they actually came about exactly but this apparently sorts them out
Lua sector lines
Adds support for "sector.lines" in Lua, an array containing all the linedefs in a particular sector variable:
#sector.lines returns the number of lines in the sector.
sector.lines\[ _i_ \] (e.g. sector.lines[0], sector.lines[1], sector.lines[2], etc ....) gives you individual linedefs in the sector. If the number you supply is equal to or greater than #sector.lines, this returns nil.
Test script for your benefit: (see comments)
Type "luatest" in console in any level and you'll get a few print messages that tests these features for sectors[0]
See merge request !32
SOC_**** lump name support
Exactly what it says on the tin: lumps with "SOC_" prefix now are read as SOC lumps like with MAINCFG/OBJCTCFG. Go nuts.
As a bonus, I've changed things with SOC lump detection so MAINCFG, OBJCTCFG and the new SOC_**** lumps are loaded in the order you find them in WAD files (rather than an arbitrary load-MAINCFG-then-load-OBJCTCFG thing as before). All of these are still loaded after Lua scripts though, mind.
See merge request !38
Lua video lib expansion
New video/drawer library functions for hud.add to use:
v.width() and v.height() return the screen width and height respectively (in other words you get the screen resolution), while v.renderer() returns the string for the renderer used ("software", "opengl", or "none").
Possibly add more stuff later, but for now these things at the least can be merged in next
See merge request !40
Add PlayerSpawn hook to Lua
I don't know how I did this but I did. Something about staring at code from 3AM till 5AM...
Here's a test script too:
```Lua
addHook("PlayerSpawn", function(player) player.health = 99 end)
```
See merge request !48
Version constants for Lua
Pretty simple thing. Allows scripters to use VERSION, SUBVERSION, and VERSIONSTRING to check the game's version and potentially futureproof scripts. Have tested and confirmed working on my end.
See merge request !55
BACKPORT: removal of music slots
Relevant commits cherry-picked. Basically everything except the internal music track name switches.
See merge request !43
The funny thing is you really can't see ANY change here unless you have a sloped FOF intersecting a sector floor/ceiling (and a second FOF on the other side), which has other problems anyway lol
BACKPORT: FF_ANIMATE simplistic state animations
this is a lot more complex due to the need to remove the dispoffset related code as well as a lot of the redefinitions; combined with the code changes due to the sprite2 system in internal master.
~~BEFORE ACCEPTING THIS: get sryder to look at and fix any possible brokenness with OpenGL MD2s~~
See merge request !45
Fof flag change hotfix
This fixes rendering issues caused by changing FOF flags mid-level via Lua or linedef type 445. Everything else that toggles FF_EXISTS already had this fix it turns out.
Not sure if this is safe for master too, could someone check that for me?
See merge request !53
This fixes how removing certain flags (such as FF_EXISTS) from FOFs can cause HOMs on walls bordering their target sectors. Also fixes how the force-FOF-to-vanish linedef special can leave behind the FOF's shadow
Fix chain launching
Basically you're not allowed to launch off a chain the frame you touch it anymore.
Coincidentally the changes here allow you to actually use PF_*STASIS in a Lua script now and have it work as you'd expect it to (it lasts for a tic).
See merge request !49
cpuaffinity/sdl_mixer changes
Hopefully this will alleviate SDL2 sound issues.
If not, hopefully this will give us info on what the hell is going on.
See merge request !51
(No, game, you can't allocate a map header for the credits, why were you doing that before and how did it not break anything??)
(cherry picked from commit e1f9a01229)
Use whatever names you want for your music. So long as you prefix the lumps with O_ or D_, it doesn't matter anymore.
DISCLAIMER: Linedef type 413 (change music) and Lua scripting is not tested.
(cherry picked from commit 025ca413a2)
# Conflicts:
# src/p_user.c
Travis-CI builds
Merge support to build SRB2 for Linux system via Travis-Ci
This will build SRB2 with GCC and Clang to make sure we do not break Linux/GNU builds
See merge request !41
Monster Iestyn's Miscellaneous (netplay-compatible) changes
Just cleaning up some unused or unnecessary things left in the source code, see the commits for exact changes made if you like.
May add more stuff to this branch later, there's no rush really.
See merge request !39
Diagonal spring rings tweak
If you didn't know before, those special placement ring lines for diagonal springs only use multiples of 45 for their angles in-game. In other words, they only face any of the 8 basic cardinal directions (N, S, E, W, NE, NW, etc). Considering that springs themselves don't follow the above behaviour, you can probably work out that's a bad thing.
This branch changes that of course, if you couldn't guess from context. Diagonal spring rings can now be placed with any angles like most thing types already could!
See merge request !37
some of the mess in here really bothers me
(cherry-picking this commit of mine from next since it only fixes a small oversight with compiling and adds a comment)
the screen texture does not need an alpha channel.
the fact that it had one made OGL copy the topmost pixel of the screen texture's alpha channel.
which, naturally results in the screen becoming partially transparent and letting you see the working texture in the background.
g_game.c: In function 'G_CheckDemoStatus':
g_game.c:5588:22: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
if (!modeattacking == ATTACKING_RECORD)
^
This is not how you use pushlstring! This is actually sending uninitialized memory to Lua, which is making scripts have inconsistent results (duh?)
c/o JTE: "Tell Red they're a doofus."
Admittedly I knew of this particular method from the start but wanted to avoid it in favour of a less-hacky looking method of getting sector.lines' size ...but there was none to be found at all.
Coloropposite hotfix
Quick fix to prevent ColorOpposite(MAXSKINCOLORS) or higher input from giving results out of the actual array's bounds. In other words, preventing it from giving you nonsense values or something.
I created the function for Lua to begin with, so clearly this is 100% my fault once again. Welp.
See merge request !31
Objectplace reallocates the mapthings list to add one more mapthing. By itself there's no problem with this.
But, mobj->spawnpoint is a pointer to the mapthing's location in the mapthings list.
So by reallocating the mapthings list, all references to mobj->spawnpoints point to freed memory.
... Oops.
Now when objectplace reallocates the mapthings list it actually corrects the locations of all mobj's spawnpoints to point to the new list.
Hooray, you can use NiGHTS objectplace again if you really want to.
The point here is ColorOpposite(MAXSKINCOLORS) would have given an actual result of its own since MAXSKINCOLORS & MAXSKINCOLORS is still MAXSKINCOLORS. This shouldn't happen though, as both Color_Opposite[MAXSKINCOLORS*2] and Color_Opposite[MAXSKINCOLOR*2+1] aren't defined.
Note: polyobj_t's "translucency" is apparently a SIGNED integer, so in theory it's possible to get polyobj flats to use the "spanfunc = splatfunc" line using negative values. If this is not meant to happen, this should probably be fixed asap
Conflicts:
src/f_wipe.c
Also makes comptime.bat work with git if able.
Development builds will now show the branch and the SHA1 hash of the revision. Also been tested to work with subversion, where it displays "Subversion r####". You know, just in case.
more detailed description: vissprites now store dispoffset in a separate variable from (y)scale, and uses it to influence order between sprites without it affecting the actual drawing of the sprites themselves
Fix md2s
shoutouts to MI for breaking them accidentally
I was about to just commit this straight to next but it's the perfect reason of why code review is beneficial and I'd be a hypocrite to point that out and then skip the process
See merge request !28
Apparently all parts of the source code that require GLPatch_t are themselves used only if HWRENDER is defined. Do I need to say more?
Not sure if this will fix Wolfy's latest problem or not though
Basically, Wolfy's linux (non-CMake) compiling apparently fails here, and config.in.h actually lives outside of the sdl folder. Blame a particular someone for blindly copy+pasting these includes in this file without considering the consequences when adding support for CMake everywhere.
Apparently all parts of the source code that require GLPatch_t are themselves used only if HWRENDER is defined. Do I need to say more?
Not sure if this will fix Wolfy's latest problem or not though
Basically, Wolfy's linux (non-CMake) compiling apparently fails here, and config.in.h actually lives outside of the sdl folder. Blame a particular someone for blindly copy+pasting these includes in this file without considering the consequences when adding support for CMake everywhere.
Compiling errors fixed in this commit:
* Various cases of mixed declaration and statement code
* Implicit declaration of slope functions (read: you forgot to put "include "p_slopes.h" in MORE than a few places)
* an odd case of a bad fixed_t to float typecase, cause by using P_GetZAt directly inside FIXED_TO_FLOAT
* a few minor cases of bad unsigned-signed comparisons
* no prototypes for some of the new slope functions. For goodness sake Red, this is basic stuff!
Actions tweaks
This just rewrites the action A_SetTargetsTarget currently, dunno if I'll bother to tweak any more actions in the near future \*shrugs\*
That said, PLEASE check whether the action works properly before accepting the merge. It's been a while since I last did anything with this branch, so I forget entirely whether I tested it or not.
See merge request !27
Slopes and stuff
Adds support for slopes, slopes on FOFs, slopes on translucent FOFs, slopes on FOFs with holes in the flat, slope physics, dynamic slopes, vertex slopes, dynamic vertex slopes, and a ham sandwich to the game. Only for software mode right now, though. (OGL still gets the physics and the sandwich.) Some things still need to be done, but for now this can be merged in to be finished later.
Please make sure nothing in the vanilla game breaks before giving the thumbs up for this merge.
Since this doesn't merge automatically, if the code review turns out positive and nobody else has done it, I'll handle the merging.
See merge request !22
To be specific: when a sector had a sloped ceiling and a colormap was
placed above it, the colormap wouldn't fill anything above where the
ceiling height is at the sector's midpoint. This is fixed.
Tweaks to R_PointToAngle and R_PointToAngle2
Exactly what it says in the title! See commit description for more information on what I did, since I'm too lazy to write it all up a second time. =P
Could someone check that these changes don't cause anything else in particular to go wrong in the game or source code? I haven't checked myself that much yet, mostly because I totally forgot about this thing until now, lol.
See merge request !19
Note: Before this change, North and West directions would be returned as ANGLE_90-1 and ANGLE_180-1. This caused the pusher polyobjects in THZ2 to slowly move sideways as a side-effect (and probably caused similar bugs in the past too, these functions have barely been touched in a decade it turns out.)
Goo Water (THZ Goop) adjustements
At Nev3r's request:
Adjusted goop so that you spend less time bouncing around in it. The goop will become a walkable surface with a higher velocity threshold.
The actual goop physics haven't been altered as far as the initial entrance and underwater time is concerned, only leaving goop and subsequent bounces has been dampened significantly.
See merge request !7
finesine table
I pasted in finesine from #11 and made a merge request.
This has been lightly tested to ensure the renderer doesn't immediately break. No ill effects have been observed so far.
See merge request !17
A_SetObjectFlags tweak
Only reset the sector/blockmap links on an object calling A_SetObjectFlags if the MF_NOSECTOR|MF_NOBLOCKMAP flags change. Fixes a freeze related to LD442 demonstrated in MascaraSnake's example WAD at https://dl.dropboxusercontent.com/u/27962790/statetest.wad .
See merge request !11
Re-add/fix broken platform momz mobj code.
The changes in this branch re-add the platform's momentum to players and mobjs which leave the platform (eg. by jumping) so that they move with relative velocity as expected. This behavior was unintentionally broken in SRB2 2.0, which adds a lot of artificial difficulty to certain segments of the levels, where you have to jump between high velocity moving platforms which seemingly cut your jump height to nothing.
Not only has the behavior been fixed, but it has now been enhanced to move the camera while free-falling between platforms as well, completing the illusion of full relative velocity with minimal hiccups. [Observe.](http://i.imgur.com/zmSfUyp.gifv)
See merge request !14
Miscellanous fixes to merge
These are the commits from the "miscellanous-fixes" branch that are okay to merge in.
Bugs fixed include the following:
* CTF flags respawning incorrectly: they cannot z position themselves correctly, and they cannot flip themselves.
* The weird "jumping" spring/monitor effect: this is the result of an internal mobj_t pointer (tmfloorthing, specifically) not resetting itself to NULL for the next object's thinker, resulting in Z movement code thrusting the object vertically at tmfloorthing->momz.
See merge request !18
... because some things (Lua. custom header entries) move it.
https://mb.srb2.org/showthread.php?t=40580
(Technically breaks netgame compatibility for Lua-heavy mods, so in next.)
That's supposed to be run once a frame, not once per hook
per mobj per frame you moron. If you just run it seven
thousand times a frame, of course your framerate will drop.
Dummy, what do you think you're doing? If you
just push mobjs and players into Lua all willy-
nilly everywhere, you'll wind up generating
tons of metatables and stuff you arne't even
gonna use!
Oh. Thanks me, I'm really smart.
This _should_ solve some significant performance
issues Lua experiences. If not, I will be very
upset for having wasted so much time and effort.
There will be bugs, this kind of thing needs to
be thuroughly tested and this is just the first
iteration of it.
Assume that every frame the player is on the ground, their pmomz will
be re-set properly if the floor is moving, therefore if the platform
STOPS, we need this to set it to 0.
This fixes the issue with upside-down springs shooting downwards if you touch another of its kind. Also fixes one of the issues with monitors in Icicle Falls (after you phase inside the East-most float-bob FOF's monitor via the other bug and jump up to break it while there, the NEXT monitor moves upwards too)
Here's how it works: When a player walks off the
moving platform, it applies their pmomz once, and
then _keeps pmomz set_ so that the camera still
adds pmomz to its movements until they hit another
floor. This way, the camera doesn't jerk around.
Also gain velocity from walking off an "up" elevator normally?
This _looks_ incorrect because the camera stops matching
the platform movement the moment you step off, but I
assure you it is a correct and accurate movement.
(Try it with chasecam off.)
Now players will apply platform movement when jumping,
but only if the platform is moving the same direction
as their jump is, and all other objects will have an
appropriate pmomz in reverse gravity FOF situations.
These functions were already here before, and I /swear/ the slope
physics became slightly less glitchy after switching to them...
Only issue is the slope plane mapping code hasn't been properly
converted yet, so they don't render properly for now.
tmthing must not be set outside of P_MapStart and P_MapEnd
or the game will fail a sanity check which ensures that
mobj references are not persistent across frames and crash.
Angles now go from 0 to 0xFFFF (360 degrees == FRACUNIT) instead
of using a full UINT32. Lua only has one number type, so signedness
gets in the way of using angle_t directly. This handling of angles
matches up with how ZDoom ACS scripting and the like does it.
I also changed all the integer casts and pushes of fixed_t to
their own macro in preperation for possible future seperation.
EvalMath is for SOC only.
It spawns an entirely seperate instance of Lua and requires
uppercase-only strings, and it's ability to parse strings to
enums is redundant to Lua's _G table (try using
_G["MT_BLUECRAWLA"] for instance)