Commit Graph

1617 Commits

Author SHA1 Message Date
helixhorned edb110b692 More rebust (and "correct"/expected) decimal number parsing in CON.
The replacement of atoi with strtol in r2374 had the side-effect that numbers
out of the range of a 32-bit integer were being returned as LONG_MAX/LONG_MIN
instead of being converted by taking the bits and re-interpreting them (note
that it was a coincidence that atoi behaved that way; to be strict, the
behavior was undefined and there is no regression).

Now, we implement parsing decimal integers using strtoll (with assuming
"long long" being the same as int64_t) and check in which range the number
falls.  If it's in the range (INT32_MAX <= x <= UINT32_MAX), issue a warning;
if it's not in (INT32_MIN <= x <= UINT32_MAX), warn too (though this better
ought to be an error?).  In each case, the bit representation is converted to
the CON number type (int32 to assume maximum portability) by re-interpreting
the bits [this is the same as an int/int cast, with GCC at least; more
generally, it's implementation-defined per C99].

git-svn-id: https://svn.eduke32.com/eduke32@2392 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-29 15:27:40 +00:00
helixhorned 925b27e3cd Try to find another mirror wall if the assigned one breaks.
This fixes mirrors consisting of more than one walls not drawing when the
first assigned mirror wall breaks. It still does not let you have more
than one mirror (i.e. mirror sectors) showing up at the same time in
the scene.  Affects classic and Polymost only.

git-svn-id: https://svn.eduke32.com/eduke32@2387 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-25 15:59:44 +00:00
helixhorned 0175562e1f Do bound check for "quick" sector/wall accesses from CON, i.e. in getvarvar.
This was causing oob sector accesses with code like this:
    getwall[hitwall].nextsector temp
    ifvarvare sector[temp].floorz sector[temp].ceilingz setvar tempb 1
(from DT's HYPERCORE).

Also validate quote indices passed to CON's quote and userquote commands at
runtime.

git-svn-id: https://svn.eduke32.com/eduke32@2381 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-24 19:51:54 +00:00
helixhorned 668774c12e Fix user quotes colored with a 2-digit number being wrongly x-aligned.
Such game text was shown starting from about the center of the screen.
The reason for the bug was this code:
  t += 1 + isdigit(*(t+2));
The sequence points here are at the beginning and end of this assignment
expression, and the updating of t may happen anywhere between these (C99
6.5.16 #3).  Please don't write such code.  When in doubt, and assignment
and reference to the same object should be split!

git-svn-id: https://svn.eduke32.com/eduke32@2380 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-24 19:51:37 +00:00
helixhorned 0919c186ba Pull the 'for (' ... ')' out of the TRAVERSE_{CONNECT,SPRITE_*} macros.
This plays more nicely with automatic formatters.  Also indent accordingly.

git-svn-id: https://svn.eduke32.com/eduke32@2379 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-21 19:33:33 +00:00
helixhorned 0309ba3141 QUOTE_NVG_OFF-p->heat_on --> QUOTE_NVG_OFF-!!p->heat_on in sector.c.
Because: 1) It used to be like this; 2) guard against bad CON input.

git-svn-id: https://svn.eduke32.com/eduke32@2378 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-21 19:33:09 +00:00
helixhorned 0f933a8522 Fix potential (certain?) oob access with ST28/SE21.
Encountered with Scent.map.  Since the SE21 are deleted after they have
been used, the search for them in the ST28 code in sector.c may come up
empty, in which case sector[-1] would be accessed.

git-svn-id: https://svn.eduke32.com/eduke32@2377 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-21 19:32:55 +00:00
helixhorned cf9e0490a2 Uncomment "CrosshairColor" parsing code in config.c.
Untested, but LeoD says it works.

git-svn-id: https://svn.eduke32.com/eduke32@2375 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-20 21:18:57 +00:00
helixhorned 8b7a4dab9b Define Batoi/Batol to strtol(...) in compat.h and use these when necessary.
That is, everyplace a user input is to be converted.  The only remaining
instance of atoi() is now atoi(s_buildDate).

git-svn-id: https://svn.eduke32.com/eduke32@2374 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-20 21:17:39 +00:00
helixhorned 80bd1bb4e4 engine: make neartag accept a sprite-blacklist function and use it in sector.c.
Internally, the last argument to neartag is now a pointer to a function
  int32_t (*blacklist_sprite_func)(int32_t i),
which is supposed to return 1 if sprite[i] should NOT be considered for hitting.

This is now used in the hard-coded neartag() calls in sector.c, but not in any
way in CON (there's neither a C blacklist function provided, nor is there a
possibility to define one in CON).  There, all sprites with picnums >=1 and <=10
(i.e. the effectors) will be blacklisted.  This remedies problems where such
sprites would get in the way of switches.

Note that a whitelist approach (only consider a predefined set, namely those
picnums which will be checked afterwards) has back-compatibility implications
since people may have used e.g. lotagged window sprites to cover a switch.

Also, the >=1 to <=10 range is [sic] (the static, not dynamic values are used),
since anyone redefining effector picnums is clearly out of their mind.

git-svn-id: https://svn.eduke32.com/eduke32@2373 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-20 19:54:24 +00:00
helixhorned be0d5a7885 Use maps selector: draw files found in ZIPs with pal 8.
git-svn-id: https://svn.eduke32.com/eduke32@2370 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-20 19:53:07 +00:00
helixhorned 97ebb029d6 Make compiler happy: remove 'may be used uninitialized' warning in multivoc.c.
I'm not getting this warning (synthesis is) but I think it's justified because
the VOC block parsing code isn't terribly validating...

git-svn-id: https://svn.eduke32.com/eduke32@2364 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-18 22:15:35 +00:00
helixhorned 103a6e76f9 constify various cache1d and pragmas functions, some copybuf* -> memcpy/move.
The following functions have const qualifiers attached for the 'destination'
arguments: kdfwrite, dfwrite in cache1d.c and copybuf{byte,reverse,} in the
pragmas source or headers.  A couple uses of the latter ones were replaced
with calls to standard library functions.

git-svn-id: https://svn.eduke32.com/eduke32@2361 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-18 22:14:45 +00:00
helixhorned 1ad110ff6a menus.c: rename _bar to sliderbar.
git-svn-id: https://svn.eduke32.com/eduke32@2359 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-18 17:56:52 +00:00
helixhorned 079056df67 Menus: make aspect ratio also control r_usenewaspect.
- RENDERER SETUP is now also accessible from classic, with only 2 options:
  'aspect ratio' and 'ambient light level'
- remove the latter option from the VIDEO SETUP menu
- When compiled with OpenGL, the aspect ratio option cycles between 3 states:
  r_usenewaspect=1 (the modern way), and r_usenewaspect=0 but r_widescreen=0/1.
  In non-GL builds, there are only 2 states.
- don't display black translucent overlay in COLOR CORRECTION menu

git-svn-id: https://svn.eduke32.com/eduke32@2358 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-18 17:56:39 +00:00
helixhorned e14b2808ef Fix non-OpenGL build.
git-svn-id: https://svn.eduke32.com/eduke32@2357 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-18 17:56:26 +00:00
helixhorned 0ef1721955 Mapster32: Fix extended ceiling/floor picnums taking on picnum 0 in Polymer.
The reason was that drawmasks(), which was where the resetting of the fake
RoR textures happened under Polymer, can be called from polymer_displayrooms()
when mirrors are present. I was assuming that drawmasks() was only ever called
after the 'main' drawrooms and that hence the sequence of fake RoR tile tweaking
was set, reset, set, reset, ... which it was not.
Now, do the resetting explicitly after every drawmasks() in the editor.

git-svn-id: https://svn.eduke32.com/eduke32@2350 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-16 19:25:42 +00:00
helixhorned ebbf4d79ce Clean up VOC in-memory block type parsing.
- Maintain a position relative to the start of the data. VOC doesn't
  mandate an EOF marker (blocktype 0). If we go over the end, fake
  that marker, so as to restart a looping sound or stop a one-shot one.
  This fixes an uninitialized mem access with the corrupt SNAKRM.VOC.
- When encountering the EOF marker, don't read the 3 bytes of block size,
  since they may not be there.
- Read blocksize by ORing and shifting the 3 bytes, not with *(int32_t *)...

git-svn-id: https://svn.eduke32.com/eduke32@2346 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-16 19:24:28 +00:00
helixhorned 17ba2664f9 Mapster32: don't use lazy tile loading with r_hightile=0.
git-svn-id: https://svn.eduke32.com/eduke32@2345 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-16 19:24:09 +00:00
helixhorned b04e743236 Fix use of an uninitialized variable in P_FindWall->FindDistance2D with noclip.
git-svn-id: https://svn.eduke32.com/eduke32@2344 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-14 23:14:07 +00:00
helixhorned 53d9264f92 Fix a couple of out-of-bounds accesses when roaming around with noclip.
- guard cansee() against negative sectnums (return 0 immediately), since
  it's often called with the player sectnum as one argument
- in resetpspritevars(), don't inset APLAYER sprite if sectnum < 0, which
  can happen if a map is started in void space accidentally (e.g. from
  the editor)
- two checks before accessing sector[] with a player sectnum

git-svn-id: https://svn.eduke32.com/eduke32@2342 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-14 23:13:38 +00:00
helixhorned f89d73504d Draw HANDHOLDINGLASER and ~ACCESS with guniqhud=200 and 201, respectively.
This fixes updateanimation picking up foreign (and thus potentially oob)
frame numbers at "3: c > n".

git-svn-id: https://svn.eduke32.com/eduke32@2339 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-13 21:38:00 +00:00
helixhorned 5f23cb6bcd Debugging helper disabling a.nasm calls with OpenGL renderers.
Uncomment #define DEBUG_VALGRIND_NO_SMC in duke3d.h to be able to
 valgrind --smc-check=none (or the default stack-only)
with Polymost and Polymer renderers.

git-svn-id: https://svn.eduke32.com/eduke32@2337 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-12 13:47:33 +00:00
helixhorned 8ab0fbf7f4 Patch up out-of-bounds access (r/w) when mixing 16-bit stereo *source* data.
... by allocating two bytes more for the mixing buffers.

git-svn-id: https://svn.eduke32.com/eduke32@2336 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-12 13:47:15 +00:00
helixhorned 09addc955c jmact/control.c: rewrite strange looking loop.
git-svn-id: https://svn.eduke32.com/eduke32@2334 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-11 11:52:33 +00:00
helixhorned f872d556d8 Draw translucent black background only when playing (back a demo or oneself).
git-svn-id: https://svn.eduke32.com/eduke32@2333 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-11 11:52:19 +00:00
helixhorned ca30952b21 Fix menu text not drawing when not playing (back), introduced in r2326.
git-svn-id: https://svn.eduke32.com/eduke32@2332 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-11 11:51:48 +00:00
helixhorned 15532fa96a Remove a couple of redundant declarations.
git-svn-id: https://svn.eduke32.com/eduke32@2330 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-09 22:45:38 +00:00
helixhorned ebd7fc402b Lunatic: interface to events.
git-svn-id: https://svn.eduke32.com/eduke32@2329 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-09 22:45:18 +00:00
helixhorned 4a00423c89 Add some #includes to gameexec.h and sector.h so that they can be included directly
git-svn-id: https://svn.eduke32.com/eduke32@2328 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-09 22:44:45 +00:00
helixhorned aee01a4958 Use a tokenlist for the event names and add tokenlist typedef to gamedef.h.
git-svn-id: https://svn.eduke32.com/eduke32@2327 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-09 22:44:26 +00:00
helixhorned 1ada6d0529 Make r_maxfps functional in demo playback.
git-svn-id: https://svn.eduke32.com/eduke32@2326 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-09 22:44:09 +00:00
helixhorned 968a999356 Coalescle codes for dnkroz and dncgs cheats.
git-svn-id: https://svn.eduke32.com/eduke32@2325 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-09 22:43:55 +00:00
helixhorned 3f2c54d9e8 Factor out identical (except for params) pieces of code of G_CheatGetInv().
git-svn-id: https://svn.eduke32.com/eduke32@2324 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-09 22:43:40 +00:00
helixhorned 75436815c3 Revert r2303 functionality ("Don't wait for pain tinting to subside...")
It was causing update issues when many tints were applied simultaneously,
like being shot and spit at by enforcers while being on rails barefeet.
Also, the GL modes were calling gltexinvalidate8() when picking up goodies
or being hurt with that change, so it needs much more thought.

git-svn-id: https://svn.eduke32.com/eduke32@2322 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-09 22:43:06 +00:00
helixhorned 34000a9ed0 Factor out two pieces of identical code in actors.c into A_HandleBeingSpitOn().
This fixes a bug in passing: 'int32_t j' was assigned to as a temporary inside
one instance of the code, but used as if it were the previous sprite index
further on.  Would only happen with projectiles that "work like" both SPIT
and RPG_IMPACT.

git-svn-id: https://svn.eduke32.com/eduke32@2321 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-09 22:42:51 +00:00
helixhorned 5846d73d30 Probably fix crash when reaching light count limit in G_MoveEffectors SE50 code.
git-svn-id: https://svn.eduke32.com/eduke32@2320 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-08 11:01:03 +00:00
helixhorned 997375bd20 Lunatic: use enum constants
git-svn-id: https://svn.eduke32.com/eduke32@2319 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-08 11:00:48 +00:00
helixhorned 103ee7a40b rotatesprite(..., windowx1,windowy1,windowx2,windowy2) --> rotatesprite_win
git-svn-id: https://svn.eduke32.com/eduke32@2318 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-04 21:35:00 +00:00
helixhorned 43c5fc2f34 Lunatic: a bit rearrangement, getbunch.
git-svn-id: https://svn.eduke32.com/eduke32@2317 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-04 21:34:39 +00:00
helixhorned 00b4dadd98 game.c: trivial tweaks to reduce code duplication (which is hard on the eyes)
git-svn-id: https://svn.eduke32.com/eduke32@2316 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-04 21:34:22 +00:00
helixhorned 1d0cb07167 Factor out four instances of identical code into M32_DrawRoomsAndMasks().
git-svn-id: https://svn.eduke32.com/eduke32@2314 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-04 21:33:52 +00:00
helixhorned a04e15082b EDuke32: Various menu tweaks and one fix.
- make PGUP/PGDN and HOME/END behave as expected across all menus
- in keyboard/mouse button mapping menu, draw function names that have been given
  custom names via CON with pal 8 for easier recognition
- fix tinting of function names in mouse button mapping menu

git-svn-id: https://svn.eduke32.com/eduke32@2313 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-04 14:30:54 +00:00
helixhorned 00b852fe37 EDuke32: When in menus, always draw a black (33%) translucent background.
Internally, there's a new function fade_screen_black() that implements the
fading more efficiently than calling rotatesprite for classic, and uses
tile 0 (assumed to have at least 64x32 size) in the GL modes.

The black background of the user map selector is still done with rotatesprite
and tile BLANK in every renderer.

git-svn-id: https://svn.eduke32.com/eduke32@2312 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-04 14:30:39 +00:00
helixhorned 7b09accdce Check 'bpp' parameter to vidmode OSD command in EDuke32.
So that the game won't exit if you write 'vidmode 4' when intending
'setrendermode 4'.

git-svn-id: https://svn.eduke32.com/eduke32@2311 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-04 14:30:17 +00:00
helixhorned e59e7f0f3c Lunatic: fix interface when compiled with 'pointered' main arrays. Argh!
git-svn-id: https://svn.eduke32.com/eduke32@2310 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-04 14:29:59 +00:00
helixhorned 6ca24a0543 Fix not-initialized variable warning in 'soundanims' CON token parser.
git-svn-id: https://svn.eduke32.com/eduke32@2309 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-04 14:29:41 +00:00
helixhorned 99e08bf441 legibility improvements: rotatesprite(..., 0,0,xdim-1,ydim-1) -> rotatesprite_fs
git-svn-id: https://svn.eduke32.com/eduke32@2308 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-02 17:35:05 +00:00
helixhorned 55699e1240 Fix an update issue with the recent screen tint retaining on palette change.
git-svn-id: https://svn.eduke32.com/eduke32@2307 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-02 17:34:30 +00:00
helixhorned 15c7460059 When loading a map and in a few other places, reset screen tinting.
git-svn-id: https://svn.eduke32.com/eduke32@2306 1a8010ca-5511-0410-912e-c29ae57300e0
2012-02-02 17:34:16 +00:00