Commit Graph

332 Commits

Author SHA1 Message Date
helixhorned 031da6280d Remove the allocache() allocation type for 'intptr_t *lookups'.
Always malloc that buffer.  This allows us to remove suckcache() from
cache1d.c, which I believe to be buggy (see comments in the source).

git-svn-id: https://svn.eduke32.com/eduke32@2261 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-15 22:39:59 +00:00
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 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 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 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 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 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 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 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 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 775d652d7d Lunatic: more Makefile tweaks; spriteext
git-svn-id: https://svn.eduke32.com/eduke32@2148 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-04 18:09:50 +00:00
helixhorned bbc6db465e Mapster32: new cfg var 'glusememcache', the same as r_memcache cvar.
git-svn-id: https://svn.eduke32.com/eduke32@2145 1a8010ca-5511-0410-912e-c29ae57300e0
2011-12-03 13:13:28 +00:00
helixhorned 45bcc11f46 Batch-insertion of many points at once using line drawing and ENTER.
When having drawn N new points (and having one 'free') and pressing
ENTER, the N line segments between the new points are checked one by
one for intersection with every non-grayed-out wall and a wall vertex
is inserted at every intersecting point.  This may be viewed as a
prerequisite for a 'cutter' style tool.

git-svn-id: https://svn.eduke32.com/eduke32@2125 1a8010ca-5511-0410-912e-c29ae57300e0
2011-11-25 09:51:53 +00:00
helixhorned 39314586ac Somewhat largish commit with various keyboard tinkering for Mapster.
The main change consist of adding a key press (and release) callback
whose only purpose is to be used from m32script as EVENT_KEYPRESS.
When entering that event, the RETURN variable will be set to the
keystatus code of the key, and whether it was pressed or released can
be checked by looking at keystatus[] at that code (ifholdkey and
ifhitkey do this). The purpose of this, then, is to be able to remap
keys in a more general (and complicated) fashion than is possible with
the mapster32.cfg 'remap' option. Various other additions build around
this central one:

- add an example EVENT_KEYPRESS to a.m32, among other things emulating
  the keypad arrows with Alt-<normal arrows> for notebook convenience;
  disabled initially
- a.m32: set 'owner' with Alt-KP2: now Alt-Shift-KP2, because of
  collision with the above
- new m32script command: setkey <keycode>, setting keystatus[<keycode>]
  to 1 (note: may be restricted to use in EVENT_KEYPRESS only in the
  future)
- fix indexing an m32script array with a defined label, there used to
  be a 'not a gamevar' error instead
- add the following constant labels for some key codes:
  KEY_SCROLL, KEY_F1 .. KEY_F12

git-svn-id: https://svn.eduke32.com/eduke32@2122 1a8010ca-5511-0410-912e-c29ae57300e0
2011-11-25 09:51:06 +00:00
helixhorned 57e132a044 Remove after_handleevents_hook and its only user, the keystatus-level clearing
of SPACE and C when in side-view mode. Now, this is accomplished by checking
directly in the overheadeditor code.

git-svn-id: https://svn.eduke32.com/eduke32@2119 1a8010ca-5511-0410-912e-c29ae57300e0
2011-11-25 09:50:07 +00:00
helixhorned 997b3426b5 Remove the -nopause switch of r2108, since it didn't help at all.
git-svn-id: https://svn.eduke32.com/eduke32@2114 1a8010ca-5511-0410-912e-c29ae57300e0
2011-11-17 21:09:49 +00:00
helixhorned b2d789731a A couple of Mapster changes related to saving.
- new mapster32.cfg and OSD variable 'fixmaponsave_sprites', telling the
  editor whether to 'fix' the sprite sectnums on saving and entering 3D
  mode. Note that a) sprite sectnums are never fixed when 'script_expertmode'
  is enabled, as before, and b) sprites that have out-of-bounds sectnums
  are still fixed if a proper sector is found
- if saving and some sprite sectnums have thus been tweaked, inform the
  mapper on the status line and print the changes in the OSD
- fix update issue similar to an earlier one: when 'saving as', the astub.c-
  based file name is now updated too, so saving with Ctrl-S now saves into
  the one save with 'save as' (and not the old one)
- don't attempt to recheck wall pointers from scratch (when saving and running
  with -check) if it's a TROR map

git-svn-id: https://svn.eduke32.com/eduke32@2110 1a8010ca-5511-0410-912e-c29ae57300e0
2011-11-11 20:05:29 +00:00
helixhorned e18ef2ccc8 Oops. Revert the *alloc wrapping to catch them being called with bad values.
This was meant for debugging only.

git-svn-id: https://svn.eduke32.com/eduke32@2109 1a8010ca-5511-0410-912e-c29ae57300e0
2011-11-10 21:47:42 +00:00
helixhorned a67af55153 On Windows, add command-line switch -nopause, disabling the pause key.
Hopefully this fixes the periodic pausing/unpausing that a few people
have been experiencing.
Also fix build with GCC 3.

git-svn-id: https://svn.eduke32.com/eduke32@2108 1a8010ca-5511-0410-912e-c29ae57300e0
2011-11-10 21:47:26 +00:00
helixhorned 3690f25944 Fix the 'displayrandvar{var}' CON and m32script commands for environments
with RAND_MAX > 32767 (everything except Windows?). The 'displayrand' command
now returns values from 0 to 32767 inclusive, across all platforms.

git-svn-id: https://svn.eduke32.com/eduke32@2105 1a8010ca-5511-0410-912e-c29ae57300e0
2011-11-05 12:13:50 +00:00
plagman 9018359a9e glbuild: tell gl.h not to include the system's glext.h
We pack our own copy of glext.h to avoid build breakages on older environments,
and having gl.h include its own was defeating all that.

git-svn-id: https://svn.eduke32.com/eduke32@2080 1a8010ca-5511-0410-912e-c29ae57300e0
2011-10-23 05:02:57 +00:00
helixhorned 9196bdbd81 fix osx build: looks like it doesn't have the GL debugging functions
git-svn-id: https://svn.eduke32.com/eduke32@2073 1a8010ca-5511-0410-912e-c29ae57300e0
2011-10-11 16:52:53 +00:00
plagman f08610b6c8 Polymer: support for creating a debugging context in winlayer
This also fixes a warning when building for Windows.

git-svn-id: https://svn.eduke32.com/eduke32@2067 1a8010ca-5511-0410-912e-c29ae57300e0
2011-10-03 00:14:56 +00:00
plagman 93b4d6182e Polymer: preliminary support for GL_ARB_debug_output
This won't actually do anything until the a debug bit is added when
creating the context, but that requires support for GLX_create_context
which SDL doesn't support. I'll add support for WGL_create_context to
winlayer in a bit as a stopgap.

Also updates our local copy of glext.h with a fresh one from the
Khronos registry.

git-svn-id: https://svn.eduke32.com/eduke32@2056 1a8010ca-5511-0410-912e-c29ae57300e0
2011-10-02 05:56:35 +00:00
plagman a6d349c90a Polymer: account for model flipping for backface culling.
The winding order of faces is different if only flipping about X or Y,
and we were unconditionally culling CW faces.

git-svn-id: https://svn.eduke32.com/eduke32@2052 1a8010ca-5511-0410-912e-c29ae57300e0
2011-10-02 00:32:00 +00:00
helixhorned bb72f803c4 Two tweaks to make the precaching more efficient/less redundant in the game.
First, if we're in Polymer, don't precache tinted tiles that have a highpal
for that certain pal.  Second, don't precache tiles for palnum 251 (the last
non-reserved one, which is used as a crosshair pal). Assuming that there are
no other tints, this cuts the initial precache time and cache size on disk in
half.

git-svn-id: https://svn.eduke32.com/eduke32@2045 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-28 20:30:24 +00:00
plagman 03429e8f2e Polymer: sanitize backface culling
Keep track of which side is getting culled, swap around mirrors, swap
around model drawing.

git-svn-id: https://svn.eduke32.com/eduke32@2032 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-18 07:18:50 +00:00
helixhorned 9b1d384723 Three-way clipping in Mapster32 (still toggled with 'N): on and off as
before, and additionally a mode that doesn't clip against masked walls
and sprites.

git-svn-id: https://svn.eduke32.com/eduke32@2028 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-16 19:17:48 +00:00
helixhorned 7582b86237 Add high-resolution timers C API for profiling. The functions are called
uint64_t gethiticks() and gethitickspersec().  For SDL 1.2, the timer
has the same resolution as getticks (1000 Hz). For Windows and SDL 1.3,
the resolution of the underlying perf-timers is used.  The only user of
these functions right now is some TROR on-screen debugging code.

Revert an earlier change regarding r_preview_mouseaim.  We can't do the
check because editstatus is set later.

git-svn-id: https://svn.eduke32.com/eduke32@2026 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-15 17:05:00 +00:00
helixhorned 2415b03c79 Support for drawing 'island sectors' for TROR/classic (and with limited
functionality, Polymost).

The new feature can be enabled/disabled with the 'r_tror_nomaskpass' cvar.

The basic idea is that when drawing lower or upper levels, a first pass
is performed that ignores all red walls for which the TROR nextwall link
'towards' the viewer arrives at a red wall.  Thus, in the worst case, there
can be up to twice as many rendering passes now (when it is discovered that
the no-mask-pass isn't different that what would be drawn with the ordinary
one, the latter is skipped, since we've already drawn all needed geometry).

Hovever, this kind of multi-pass splitting is only suitable for simple scenes,
like the upper subway in the TROR test map.  In particular, multiple islands
shouldn't 'see' each other.

Two issues are worth mentioning: first, care needs to be taken for translucent
ceilings or floors, since drawing them twice isn't the same as drawing them
once. This is done for classic, but not for Polymost.  Second, sprites (which
are always drawn _after_ the geometry for a given pass) are still clipped to
the geometry of the ordinary pass, resulting in their disappearance from
certain angles.
--

Additionaly, a change made it into this commit that fixes redundant collection
of sprites in TROR:classic/Polymost.

git-svn-id: https://svn.eduke32.com/eduke32@2024 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-15 17:04:14 +00:00
helixhorned 701c69fecc misc. cleanup:
- remove 'imageSize' global which was always yres*bytesperline and only used once
- some clearbuf() -> Bmemset() because I find the latter easier to read
- remove some clearbufs to 0 of some global arrays on init

git-svn-id: https://svn.eduke32.com/eduke32@2023 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-15 17:03:50 +00:00
helixhorned 7f1133a493 Engine: add funtion 'yax_vnextsec(wall, cf)' to C API. It's often useful when
dealing with sectors on the two sides of a bunch.  Make yax_globallev and
yax_globalbunch variables non-static.
Rewrite a TROR-related bit in the engine code using the new function.

git-svn-id: https://svn.eduke32.com/eduke32@2018 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-15 17:02:12 +00:00
helixhorned 01676d7431 A couple of trivial/cleanup changes. setvgapalette() is removed from the
engine, since it had no users.

git-svn-id: https://svn.eduke32.com/eduke32@2014 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-10 15:44:53 +00:00
helixhorned 727be94eb5 Tweak the source so that it can be built by clang. The only necessary change
is to remove a couple of 'inline's for functions with external linkage, which
seems to be a GCC convenience.

git-svn-id: https://svn.eduke32.com/eduke32@2008 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-06 17:46:00 +00:00
helixhorned a145cc93bc Make Polymer declare a callback function G_Polymer_UnInit() that is called
whenever we change to another renderer etc. and define it for the game and
editor.  The purpose of the function is to clean up references to Polymer
resources like lights.
This fixes 1) all lights becoming spot lights in the game and 2)
an issue with maphack lights in the editor (can't recall which exactly).

git-svn-id: https://svn.eduke32.com/eduke32@2006 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-06 17:45:21 +00:00
helixhorned b3d3fd9a39 Better handling of tsprites that are duplicated through TROR portals.
Specifically, now also consider the sprite tile's yoffset, and fix an
issue when a tsprite got duplicated 'toward' the viewer. Also add a
couple of tests in trueror1.map.

git-svn-id: https://svn.eduke32.com/eduke32@2004 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-04 19:44:51 +00:00
helixhorned 962910ce32 Move the fixspritesectors call and the start sector updating into ExtPreSaveMap().
This makes the latter also correct when testing a map from the editor.

git-svn-id: https://svn.eduke32.com/eduke32@2001 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-04 19:43:48 +00:00
plagman 8250e5f3e8 Polymer: add preliminary support for sector masks.
When walking the sectors in displayrooms, detect floor/sector masks to
place them in a mask queue. The queues are allocated on the heap, but
a stack pointer is maintained by the displayrooms to allow it to play
nice with mirror recursion.

Right now the masks are drawn after all of drawmasks is finished; that
means you can see sprites and wall masks through sector masks, but not
the opposite. There is a slight attempt at blending far to near, but
nothing too conclusive yet; that means that in some cases some sector
masks won't be visible through other sector masks, but it should work
for trivial cases.

The next step would be to copy all the drawmasks logic into Polymer
and have it (attempt to) properly interleave sector masks where they
belong in the blending order.

git-svn-id: https://svn.eduke32.com/eduke32@1980 1a8010ca-5511-0410-912e-c29ae57300e0
2011-08-20 21:05:38 +00:00
plagman 6de59ef085 Polymer skeleton cleanup.
Reorganize polymer.c a bit to match the order of prototypes from the
header, move macros from the middle into the header.

git-svn-id: https://svn.eduke32.com/eduke32@1974 1a8010ca-5511-0410-912e-c29ae57300e0
2011-08-20 21:04:28 +00:00
helixhorned c8bf3682e0 disable undo/redo editor feature until I can debug the disappearing sprites
git-svn-id: https://svn.eduke32.com/eduke32@1973 1a8010ca-5511-0410-912e-c29ae57300e0
2011-08-20 11:54:16 +00:00
helixhorned 5262a0f24c Various cleanup work:
- fix an earlier 'oops': make highpals load correctly again
 - maphack lights shouldn't be double-loaded now
 - slight tweak to the loading screen fadein/out timing
 - two bound checks
 - make some variables static in engine.c

git-svn-id: https://svn.eduke32.com/eduke32@1969 1a8010ca-5511-0410-912e-c29ae57300e0
2011-08-17 18:52:54 +00:00
helixhorned 5d79003e60 Take a stab at hidden model switch handling. There are at least two ways by
which switches have been hidden in the original and user maps. One is to make
it face a wall, and another is to 'embed' it in e.g. the floor, like the
monitor with the burning fuse in E4L1. Both kinds show up when the switches
are rendered as models, revealing the secrets that the mapper sought to hide.
My proposal, implemented in this commit, is to apply a heuristic for such
switches at premap and make them invisible (set cstat bit 32768). The
conditions are re-checked during the game in case there is a switch coming
out of the floor, for example. A new spriteext bit is used for this feature.

git-svn-id: https://svn.eduke32.com/eduke32@1968 1a8010ca-5511-0410-912e-c29ae57300e0
2011-08-17 18:52:16 +00:00
helixhorned 13dde60ccd More fog/visibility tweaking. This makes Polymost's not depend on the screen width.
git-svn-id: https://svn.eduke32.com/eduke32@1944 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-24 18:40:10 +00:00
helixhorned 7e9b2eae0f * Clean up after myself. It seems that Polymost isn't very clean with handling texture IDs sometimes, so switching between the two GL renderers could mess them up with the last revision. This is fixed now by always uninitializing Polymer when changing from it to another renderer.
* New shade/visibility calculation code, which is activated with 'r_usenewshading' (on by default), and is closer to the classic look. Also tweak the FOGSCALE macro to have approximately the same fog distance with all renderers.

* Mapster32: END modifier to RShift. If it's pressed when RShift is released, sprites which are in grayed out sectors are also selected;  Make changing shade affect all highlighted sprites in 3D mode (when aiming at one of them).

* some debug code to watch out for suspicious glGenTexture/glDeleteTextures calls, not active.


git-svn-id: https://svn.eduke32.com/eduke32@1943 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-24 15:15:57 +00:00
helixhorned 793aadebc5 Janitorial work part 2, perfect for a rainy day. This fixes a lot of leaks, both on the client side as well as for memory allocated by OpenGL. If you had crashes after a few times of restartvid'ing in Polymer, this should fix it.
git-svn-id: https://svn.eduke32.com/eduke32@1942 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-22 22:00:53 +00:00
hendricks266 8b5761c14d My first commit!
The main feature is the addition of -mx and -mh command-line parameters to EDuke32 and Mapster32. These parameters include a con and def "module" respectively. This translates into essentially including the file from the bottom of the compiled script.

I fixed the classic buggy behavior of the BROKEHYDROPLANT and REACTOR2 sprites.

I also fixed a small, long-standing bug where FRAMEEFFECT1 blurs are not affected by sector floorpal. You can see one example of this by shrinking the Enforcer on the upper inside of the toppled building in E3L11: Freeway.

I tweaked the Makefile so that it would automatically regenerate the keep.me files in the $(OBJ) and $(EOBJ) directories after they are deleted for cleaning.

One final change is a slight positioning cleanup of both programs' --help dialog boxes.

git-svn-id: https://svn.eduke32.com/eduke32@1937 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-21 22:39:29 +00:00
helixhorned 563d42856e Build fix for OSX/PowerPC
git-svn-id: https://svn.eduke32.com/eduke32@1935 1a8010ca-5511-0410-912e-c29ae57300e0
2011-07-20 23:04:20 +00:00