From a145cc93bce9d2d7bde94c04efc32c1eba143745 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Tue, 6 Sep 2011 17:45:21 +0000 Subject: [PATCH] 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 --- polymer/eduke32/build/include/polymer.h | 3 +++ polymer/eduke32/build/src/engine.c | 3 +++ polymer/eduke32/source/actors.c | 33 ++++++++++++++++--------- polymer/eduke32/source/astub.c | 5 ++++ 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/polymer/eduke32/build/include/polymer.h b/polymer/eduke32/build/include/polymer.h index ffeb0f433..0667543fd 100644 --- a/polymer/eduke32/build/include/polymer.h +++ b/polymer/eduke32/build/include/polymer.h @@ -287,6 +287,9 @@ typedef struct s_pranimatespritesinfo { int32_t x, y, a, smoothratio; } _pranimatespritesinfo; +// this one has to be provided by the application +extern void G_Polymer_UnInit(void); + // EXTERNAL FUNCTIONS int32_t polymer_init(void); void polymer_uninit(void); diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index c6a4a68ba..c2446efa8 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -15698,7 +15698,10 @@ int32_t setrendermode(int32_t renderer) renderer = 3; } else if (rendmode==4) // going from Polymer to another renderer + { + G_Polymer_UnInit(); polymer_uninit(); + } # else else renderer = 3; # endif diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 606b5314e..9f895d92e 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -484,6 +484,23 @@ ACTOR_INLINE int32_t A_SetSprite(int32_t i,uint32_t cliptype) int32_t block_deletesprite = 0; +#ifdef POLYMER +static void A_DeletePolymerLight(int32_t s) +{ + polymer_deletelight(actor[s].lightId); + actor[s].lightId = -1; + actor[s].lightptr = NULL; +} + +void G_Polymer_UnInit(void) +{ + int32_t i; + + for (i=0; i