Commit Graph

785 Commits

Author SHA1 Message Date
helixhorned 260bbc1f92 cleanup:
- 'whitecol' was defined in the engine and in build.c, use only the engine one
 - make cachesize, artsize, artversion static in engine.c
 - undo some formatting havoc presumably done by astyle

git-svn-id: https://svn.eduke32.com/eduke32@2260 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-15 22:39:38 +00:00
helixhorned 340b2f7647 Increase the number of maximum art files from 64 to 256 and tweak loadpics().
It is likely that this is the value it used to have at some point, because
the MAXTILEFILES macro equals 256 and is as old as the Duke3D source.
loadpics() now refuses to load an ART file with localtilestart or localtileend
out of bounds, or if localtileend<=localtilestart (i.e. no tiles in ART file, or
nonsense). Also, on 'invalid art file version', continue instead of returning.

Note: this does not increase the maximum number of tiles, which is still 15360,
it only gives a bit more freedom to arrange them (well, into more art files).
Also, I don't see what anyone keeps off from packing any number of tiles (from
1 to 15360) into an art file. Old EDITART limits?

git-svn-id: https://svn.eduke32.com/eduke32@2259 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-15 22:39:10 +00:00
helixhorned 480690aa1d Fix the Polymer hitches first encountered with Parkade.
The cause was a combination of many factors. First, Polymer requires the
start-drawing position to be inside the sector to draw (deviations lead to
incorrect drawing).  This was violated by the game, because it interpolated
the current and next tic position without updating the sectnum, leading to
inconsistencies especially when passing through narrow sectors.  Polymer
worked around it by doing an updatesector() each frame, however this works
poorly for maps with overlapping geometry such as SoS or RoR.

The solution to this is to add a new engine function,
updatesector_onlynextwalls(), which searches the sectors (via nextsector)
in breadth-first fashion instead of from 0 to numsectors-1, like updatesector
does when it fails for the *immediate* nextwall neighbors.

Internally, the breadt-first search helpers are moved into the engine.

git-svn-id: https://svn.eduke32.com/eduke32@2256 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-14 14:48:30 +00:00
helixhorned 87ac6b8406 winlayer.c: in WM_PALETTECHANGED handling code ("someone stole the palette
so try and steal it back"), prevent calling IDirectDrawSurface_SetPalette()
with NULL arguments, causing a crash.  It's happened for me on Vista, when
initially changing from 8-bit to 32-bit mode.

git-svn-id: https://svn.eduke32.com/eduke32@2255 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-12 20:49:50 +00:00
helixhorned a57b566c0b Add Makefile option to use the DMALLOC (debug malloc) library.
I didn't have much success in finding bugs using it, but it works
out-of-the-box on my setup, so it may be useful in the future.

git-svn-id: https://svn.eduke32.com/eduke32@2254 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-12 20:49:34 +00:00
helixhorned 300fee62da sdlayer.c: formatting of preprocessor lines
git-svn-id: https://svn.eduke32.com/eduke32@2253 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-12 20:49:15 +00:00
helixhorned 9617227a87 Support for the first "thumb" mouse button, called MOUSE4 in the menu.
The second one is passed to the 'mouseb' variable, but the game currently
can't map it since ud.config.MouseFunctions[] would have to be enlarged,
breaking savegame compatibility.
Works both for the Windows and SDL layers. For the latter, instead of using
the SDL_BUTTON_X1/X2 macro constants, I'm using 8 and 9, since that is what
SDL (and incidentally or not, xev) gives me for those buttons.

git-svn-id: https://svn.eduke32.com/eduke32@2252 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-12 20:48:57 +00:00
helixhorned 80949930bd Temporarily disable the 'model thinning-out' feature intended to save memory.
It turns out that with model interpolation, out-of-bounds frame numbers may
be generated with thinned out models, so disable it until I can sort out
what's wrong with it.
Also, minor code cleanup.

git-svn-id: https://svn.eduke32.com/eduke32@2251 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-12 20:48:38 +00:00
helixhorned 5f50c30ac2 polymer.c: "Compiling GPU program with bits (octal) %o" for easier reading.
Also, for debugging builds, show this message from verbosity level 1 on.

git-svn-id: https://svn.eduke32.com/eduke32@2250 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-12 20:48:17 +00:00
helixhorned 7e6f712ad1 more internal cleanup...
the only visible change is that polymost_trytexcache (formerly two
instances of nearly duplicate code) now prints a diagnostic after
a cache miss.  The one that one is most likely to encounter is
"r_downsize doesn't match", meaning that this setting likely differs
between Mapster and the game.

git-svn-id: https://svn.eduke32.com/eduke32@2248 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-12 20:47:41 +00:00
helixhorned e3150b2801 a couple more trivial tweaks
git-svn-id: https://svn.eduke32.com/eduke32@2247 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:45:34 +00:00
helixhorned fa6f2d9ca2 md4.c/h: add consts to appropriate arguments
git-svn-id: https://svn.eduke32.com/eduke32@2246 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:45:08 +00:00
helixhorned 3095b09773 trivial formatting / removing of old cruft / adding comments
git-svn-id: https://svn.eduke32.com/eduke32@2244 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:44:35 +00:00
helixhorned 6a37636bb0 Possibility of specifying sounds for a VPX anim-replacement via DEF.
The syntax is as follows:
  animsounds <anim> { frame1 sound1  frame2 sound2 ... }

<anim> has to be one of the tokens: cineov2, cineov3, RADLOGO, DUKETEAM,
logo, vol41a, vol42a, vol4e1, vol43a, vol4e2, or vol4e3, corresponding
to hard-coded Duke3D anims.

The frameN's (1-based frame numbers) have to be in ascending order (but not
necessarily strictly ascending, so that a frame may have more than one sound).

Example: for Duke3D's XBLA nuke logo animation (IVF extracted from nuke.webm),
the following definition overlays the video with a sound sequence similar
(identical save for timing) to the original nuke animation:

// frame 1: FLY_BY, frame 64: PIPEBOMB_EXPLODE
animsounds logo { 1 244  64 14 }

git-svn-id: https://svn.eduke32.com/eduke32@2242 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:54 +00:00
helixhorned a86dfe661b maint: make the following static in polymost.c:
- texcacheindex *firstcacheindex, *curcacheindex
 - trytexcache(), gloadtile_cached()
- Factor out duplicated code into clear_cache_internal()

git-svn-id: https://svn.eduke32.com/eduke32@2240 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-10 23:43:18 +00:00
helixhorned 114d8e4a36 When defining a model with the 'model' token and there were errors, don't
let it hang around causing trouble later on; delete it right now and inform
the user.
Add a couple of 'static's to some functions and file scope data in mdsprite.c

git-svn-id: https://svn.eduke32.com/eduke32@2237 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-07 17:48:55 +00:00
helixhorned b926e2a496 - When saving game, clear all polymer lights before. Not doing this makes
the SE ones douple, triple, ... after each save.  Maphack lights are reloaded
with polymer_resetlights() (though I've had them disappearing after load, I
couldn't reproduce it afterwards).
- in debugging builds, print a message when polymer_resetlight is called on a
nonexistent one.  The problem is not so much the call itself (it's guarded),
but the fact that resources on the caller side may not have been freed if it
thinks that those lights do in fact exist. Right now, it's not the case though.
- add 'loaded map hack' messages after some other successful loadmaphack calls

git-svn-id: https://svn.eduke32.com/eduke32@2236 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-05 21:58:23 +00:00
helixhorned 76d210c4b8 Patch up access of malloc'd buffer one byte beyond its size in kplib's
JPEG decoder (unearthed by valgrind).

git-svn-id: https://svn.eduke32.com/eduke32@2231 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-03 19:55:55 +00:00
hendricks266 e9aec2a65b Comment ldcty[12] array from kpegrend() to remove last of set-but-unused warnings. I don't see any reason to leave this alone.
git-svn-id: https://svn.eduke32.com/eduke32@2228 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-01 04:12:37 +00:00
helixhorned 8ec15480c0 Besides the performance issues, there's another reason why changing the palette
'frequently' isn't such a good idea.  Assume an actor constantly changes the
palette to some value and you're attacked by a newbeast at the same time. Then
the pain tinting would be reset each time the actor's code is run.  This commit
adds a new flag 16 to setbrightness(), meaning "don't reset the fade tinting".
Its only use right now is from CON's setgamepalette command (and there, always).
The change is done in the engine and thus affects all platforms.

git-svn-id: https://svn.eduke32.com/eduke32@2225 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-28 20:36:01 +00:00
helixhorned d5a934f9ba Trivial tweaks of setbrightness. Add an assertion that bits 1 and 4 are clear,
mainly.  Also remove setvgapalette() from source.

git-svn-id: https://svn.eduke32.com/eduke32@2224 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-28 20:35:44 +00:00
helixhorned 92e5d8214d SDL layer: don't call SDL_SetGammaRamp() if there would be no change.
This is in the similar vein as the set-palette deferring and it's this
that fixes the low FPS in the radioactively contaminated area in AMC TC:
Megabase (since setgamma() is called from setbrightness()).

Again, update issues might be expected, but changing focus between EDuke32
and the desktop and back seems to restore the gamma settings properly on
Kubuntu. Looks like X (or whatever above handles this stuff) maintains it
on a per-application basis.

git-svn-id: https://svn.eduke32.com/eduke32@2222 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-28 20:34:57 +00:00
helixhorned 4ae50ef22a SDL layer: in 8-bit mode, defer setting the palette until showing the next frame.
CON code sometimes uses 'setgamepalette' from withing actors, which is a bit too
frequent.  Deferring the actual palette updating means that multiple requests in
between two screen redraws are coalesced into one, which is desirable for
performance reasons and for the reduction of 'tearing' artefacts (but not
prevention, since the drawing isn't synced to the screen refresh rate with
vsync off).

(Did-not-)update issues might be introduced.

Windows isn't touched because
 - I expect it to be more brittle, especially in light of the ATI HW gamma
   problems.
 - I haven't tested whether the particular performance penalty that lead to this
   change ('gas' in AMC TC) exists there too

git-svn-id: https://svn.eduke32.com/eduke32@2221 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-28 20:34:41 +00:00
helixhorned 9e1399ec14 screenshots: remove the old inversion and PCX code from the source
git-svn-id: https://svn.eduke32.com/eduke32@2220 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-28 20:34:26 +00:00
helixhorned 98bcc0e60c screenshots: if compiled with USE_LIBPNG, always use PNG, even for
color-inversed shots. For both PNG and TGA, change the way they're
done in 8-bit mode: instead of XORing every byte with 15, save the
inverse palette (each component taken 255-x).

git-svn-id: https://svn.eduke32.com/eduke32@2219 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-28 20:34:10 +00:00
helixhorned 7c245875cb engine: make smoststart[] (which saves starting "smostcnt"s) an array of int32's
instead of shorts. This fixes their values' overflow in AMC TC megabase and
probably a couple of other large maps.

git-svn-id: https://svn.eduke32.com/eduke32@2216 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-27 14:22:45 +00:00
helixhorned b30711586b patch up another out-of-bounds access in the voxel drawing code, though
I'm not sure whether the increased array size is enough.

git-svn-id: https://svn.eduke32.com/eduke32@2213 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-26 15:44:09 +00:00
helixhorned b3474c75b2 Rewrite the savegame format in terms of the generic saving/loading system.
This makes savegames practically the same as the initial snapshot of a demo.
Saves are now named 'dukesavX.esv' (demos: 'edemoX.edm').
Additionally, many changes that couldn't/needn't be cleanly separated are added
with this commit:
 - make spriteext_t have the same size across 32/64 bit platforms (actor_t partially)
 - prevent saving/loading in MP games (it certainly didn't work and still doesn't)
 - it's time we start using assertions! Define NDEBUG for releasse builds.
 - reset savegame major and minor versions (we have a new magic string, so no conflict)

git-svn-id: https://svn.eduke32.com/eduke32@2207 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-25 15:34:06 +00:00
helixhorned 9f2153d0ea Beauty tweaks; revert s_buildDate since we don't want windows builds to pull
snapshots in the current development state now.

git-svn-id: https://svn.eduke32.com/eduke32@2205 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-25 15:33:24 +00:00
helixhorned 664e0dcb9b Fix non-TROR build and add a warning that such a build is only useful for
debugging, i.e. savegames and the like will break.

git-svn-id: https://svn.eduke32.com/eduke32@2204 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-25 15:33:02 +00:00
helixhorned 60fa7d9f00 Remove a few unused variables from global.[ch], update build date string.
git-svn-id: https://svn.eduke32.com/eduke32@2196 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-25 15:30:50 +00:00
helixhorned 2f7851336b Fix out-of-bounds write when passing a map filename to Mapster32.
git-svn-id: https://svn.eduke32.com/eduke32@2194 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-21 18:43:24 +00:00
helixhorned 6b913a39aa some more clearbuf -> memset in gamedef.c plus add a forgotten keystatus
reset in the editor

git-svn-id: https://svn.eduke32.com/eduke32@2191 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-21 18:42:32 +00:00
helixhorned 8e54a3febf Preliminary commoning of actor[].t_data[10] to an array of int32's on both
32- and 64-bit platforms. Also, make struct type actor_t also have a common
size of 128 bytes. New code currently disabled and #ifdef'd for comparison.

This requires certain t_data[] entries ([1]: move ptr, [4]: action ptr and
[5]: ai ptr with actors) to be converted to script offsets instead of pointers,
breaking savegame and net packet compatibility (we could in theory try hard not
to, but it would be too much trouble).

git-svn-id: https://svn.eduke32.com/eduke32@2185 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-21 18:40:47 +00:00
helixhorned 9b0ea0366e Add new actor[].flags flag 2048 (SPRITE_NOCLIP), for 'spriteflags' CON usage.
Actors are always moved such that _they_ clip against blocking sprites, even
if their blocking bit is clear. Setting the new bit make them not clip against
anything.  The promary use of this is for decorative moving sprites that are
spawned in masses, such as rain or snow.

git-svn-id: https://svn.eduke32.com/eduke32@2184 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-17 18:51:50 +00:00
helixhorned 60bb16693b engine.c, in engine_addtsprite: if we can't add more tsprites because we
already have MAXSPRITESONSCREEN of them, return 1 to signal that the caller
should break out of the loop.

git-svn-id: https://svn.eduke32.com/eduke32@2183 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-17 18:51:29 +00:00
helixhorned 8f92cb024d Tweaks to compile the release build with clang. Now if it only would not
generate curious code like this one (Ubuntu 11.10's clang 2.9 on i386):

   0x080a57ea <+538>:   xor    %al,%al
   0x080a57ec <+540>:   test   %al,%al
   0x080a57ee <+542>:   jnz    0x80a57f2 <initgroupfile+546>
=> 0x080a57f0 <+544>:   jmp    0x80a57f0 <initgroupfile+544>
   0x080a57f2 <+546>:   shl    $0x4,%edi

git-svn-id: https://svn.eduke32.com/eduke32@2182 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-15 22:43:01 +00:00
helixhorned df94c55eab Patch up out-of-bounds access in some voxel drawing code.
git-svn-id: https://svn.eduke32.com/eduke32@2181 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-15 22:42:42 +00:00
helixhorned 84867ee620 Mapster32: Rudimentary support for auto-aligning along TROR nextwalls.
Usage: press the ['] (quote) modifier together with the PERIOD key.
Aligns only the immediate upper and lower neighbors of each wall that got
aligned by following point2s or nextwalls.  Doesn't play well with Alt
(carry over xrepeat) yet, might need two subsequent alignment passes.

git-svn-id: https://svn.eduke32.com/eduke32@2178 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-12 23:18:35 +00:00
helixhorned 2f14c6dbed checkdefs.sh script: hackish support for CON files, only 'include *.con' and
'definesound ... *.(voc|wav|ogg)' commands (missing: 'music', something else?).

git-svn-id: https://svn.eduke32.com/eduke32@2176 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-12 23:18:00 +00:00
helixhorned 3ca41992dd Fix sintable[] access with out-of-bounds values in core engine functions
(getzrange, hitscan, clipmove, drawmapview).
They're reproducible with DNE1.3D;  Since these angle values most likely come
from CON code, my suggestion would be to bit-and all values representing angles
with 2047 when setting the from CON, but I'd have to think about potential
side-effects of doing this.

git-svn-id: https://svn.eduke32.com/eduke32@2170 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-09 19:11:47 +00:00
helixhorned 151287168c - Fix invalid polymer light array access originating from game's cleanup
callback 'G_Polymer_UnInit'.
- In astub.c, reset spritelightid to -1 when nulling the spritelightptr of
  a sprite  (no crashes observed, just precaution)
- In sdlayer.c, catch SIGILLs with our signal handler too, since illegal
  instructions are what the instrumented debug builds will execute when
  attempting to carry out an undefined (per C) operation.

git-svn-id: https://svn.eduke32.com/eduke32@2169 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-09 19:11:31 +00:00
helixhorned 20d303ed15 engine.c: fix shift by negative value in parascan().
git-svn-id: https://svn.eduke32.com/eduke32@2168 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-09 19:11:08 +00:00
helixhorned b85b4d7b7c polymer.c: fix out-of-bounds picanm[] read.
git-svn-id: https://svn.eduke32.com/eduke32@2167 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-09 19:10:51 +00:00
helixhorned b7aacd242a Fix shift by values greater than 31 in some voxel loading code.
git-svn-id: https://svn.eduke32.com/eduke32@2165 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-09 19:10:21 +00:00
helixhorned f39429fa96 kplib.c: patch up negative array access, dunno how to really fix this at
the root.

git-svn-id: https://svn.eduke32.com/eduke32@2164 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-09 19:10:03 +00:00
helixhorned a950232046 Mapster32: fix AWFUL out-of-bounds WRITE with sector highlighting.
How in the name of hell this could pass undetected for so long is a
mystery to me.

git-svn-id: https://svn.eduke32.com/eduke32@2163 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-09 19:09:45 +00:00
helixhorned c7aa4592c2 polymost_printext256: fix oob read when passing negative 'col' or 'backcol'
values;  check the color index that is potentially gotten from the string to
be printed.

git-svn-id: https://svn.eduke32.com/eduke32@2162 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-09 19:09:29 +00:00
helixhorned 6dc17eec1b Makefiles: disable a few warning categories and other switches when compiling
with clang to prevent spamming the output.

git-svn-id: https://svn.eduke32.com/eduke32@2159 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-09 19:08:47 +00:00
helixhorned 6fc7e5b683 Remove some warnings with clang, code-side changes.
git-svn-id: https://svn.eduke32.com/eduke32@2158 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-09 19:08:29 +00:00