Community
Message Board

Chat room - users
Game Over
( 394431 downloads)
Work In Progress
( 523201 downloads)
Links

Code Exchange
Downloads
Tutorials
Add to Favourites

Submit news

DIV ARENA FORUMS
Not logged in [Login - Register]
Go To Bottom

Printable Version  
Author: Subject: Are get_sector_texture/get_wall_texture faulty - or is it my code... ?
BreadCaster
Loyalty Card Holder
******


Avatar


Posts: 321
Registered: 2-3-2016
Member Is Offline


[*] posted on 18-1-2018 at 05:44 PM
Are get_sector_texture/get_wall_texture faulty - or is it my code... ?


Hello hello :)

So as you all know, ive been starting to make a Mode 8 survival horror style game, and while doing so I decided that I should recode the function for blinking/flickering lights.

The new concept I had for the flickering light function is that there should be a global struct of walls, sectors, what light values they should have, etc, and each time the light is set to "blink" it should read and save wall textures, floor textures, ceiling textures, wall luminosity and sector luminosity into private variables, and then switch the environment temporarily to the global variables. Then, a few frames later, it should reset the environment (walls/sectors) back to the original saved private variables.

I figured the best way to do this would be to use For loops - however, the code I managed to come up with has some issues and I'm unsure if its to do with my programming or if maybe theres a problem with the get_sector_texture & get_wall_texture commands?

What happens at the moment is that the process will make the sector/walls will "light up", switching to the correct textures & luminositys, but then when resetting they either change to the wrong texture and the wrong luminosity (far too bright) or they simply just switch to the wrong luminosity.

Then, after they then blink again, they revert to the correct luminosity & texture. I can't seem to work out why this is happening, I've been working on this bug for the best part of a week and I can't see what I'm doing wrong - is it my code, or is it the get_sector_texture/get_wall_texture functions just being buggy? :( :(

Code:
Global STRUCT light_fx_data[2]; light_sector_A; // Each light effect will need at least one sector that lights up, this is that light_sector_A_offlumo; light_sector_A_onlumo; light_sector_A_floortex; sector_list_A[49]; // all sector numbers wall_list_A[49]; // all wall numbers sector_lumo_A; // the lumo to set sectors to wall_lumo_A; // the lumo to set walls to o modify_sectorstex_A; // simple off/on - if set to 1, use below arrays (otherwise, ignore) modify_wallstex_A; // simple off/on - if set to 1, use below arrays (otherwise, ignore) modifyto_floortexture_sectors_A[49]; // list of "lit up" floor textures for sectors, corresponds with above array modifyto_rooftexture_sectors_A[49]; // list of "lit up" roof textures for sectors, corresponds with above array modifyto_texture_wall_A[49]; // list of "lit up" textures for walls, corresponds with above array End ... anim_light(1, 0, 20044, 15048); light_fx_data[0].light_sector_A=111; light_fx_data[0].light_sector_A_onlumo=8; light_fx_data[0].light_sector_A_offlumo=11; light_fx_data[0].light_sector_A_floortex=1; light_fx_data[0].sector_lumo_A=8; // the lumo to set sectors to light_fx_data[0].wall_lumo_A=11; // the lumo to set walls to light_fx_data[0].modify_sectorstex_A=1; light_fx_data[0].modify_wallstex_A=1; // SECTORS // Sector list A light_fx_data[0].sector_list_A[0]=58; light_fx_data[0].sector_list_A[1]=112; (etc etc, all the values are set in a list) ... Process anim_light(flickertype, lightnum, x, y); Private Lc; Lc_limit; orig_lc_limit; set_save_arrays; rand_lc_val; double_flicker_chance; orig_double_flicker_chance; modify_sect_c; modify_wall_c; sectorsA_saved_lumos[50]; sectorsA_saved_floor_textures[50]; sectorsA_saved_roof_textures[50]; wallsA_saved_lumos[50]; wallsA_saved_textures[50]; Begin SWITCH (flickertype); // Set flicker/blink patterns CASE 0: orig_lc_limit=90; rand_lc_val=20; END CASE 1: orig_lc_limit=150; rand_lc_val=35; END END lc_limit=orig_lc_limit; Loop; if (KEY(_T)); debug; end Lc++; If (lc==lc_limit-5); play_3dsound(x, y, sfx_flickerlight[rand(0, 2)], 0, 0, 4, 0); // Actual light sector set_sector_texture(light_fx_data[lightnum].light_sector_A, light_fx_data[lightnum].light_sector_A_floortex, 97, light_fx_data[lightnum].light_sector_A_onlumo); // LIGHTS SWITCH 1 - switch to light_fx_data state (usually, lights on) For(modify_sect_c=0;modify_sect_c<49;modify_sect_c++); // Sectors... If (light_fx_data[lightnum].sector_list_A[modify_sect_c]==0); // Works fine Break; End get_sector_texture(light_fx_data[lightnum].sector_list_A[modify_sect_c], OFFSET sectorsA_saved_floor_textures[modify_sect_c], OFFSET sectorsA_saved_roof_textures[modify_sect_c], OFFSET sectorsA_saved_lumos[modify_sect_c]); // SAVES env info to private arrays If (light_fx_data[lightnum].modify_sectorstex_A==1); set_sector_texture(light_fx_data[lightnum].sector_list_A[modify_sect_c], light_fx_data[lightnum].modifyto_floortexture_sectors_A[modify_sect_c], light_fx_data[lightnum].modifyto_rooftexture_sectors_A[modify_sect_c], light_fx_data[lightnum].sector_lumo_A); // CHANGES env textures & lumo ELSE set_sector_texture(light_fx_data[lightnum].sector_list_A[modify_sect_c], -1, -1, light_fx_data[lightnum].sector_lumo_A); // CHANGES env lumo End End For(modify_wall_c=0;modify_wall_c<49;modify_wall_c++); // Walls... If (light_fx_data[lightnum].wall_list_A[modify_wall_c]==0); // Works fine Break; End get_wall_texture(light_fx_data[lightnum].wall_list_A[modify_wall_c], OFFSET wallsA_saved_textures[modify_wall_c], OFFSET wallsA_saved_lumos[modify_wall_c]); // SAVES env info to private If (light_fx_data[lightnum].modify_wallstex_A==1); set_wall_texture(light_fx_data[lightnum].wall_list_A[modify_wall_c], light_fx_data[lightnum].modifyto_texture_wall_A[modify_wall_c], light_fx_data[lightnum].wall_lumo_A); // CHANGES env lumo & texture ELSE set_wall_texture(light_fx_data[lightnum].wall_list_A[modify_wall_c], -1, light_fx_data[lightnum].wall_lumo_A); // CHANGES env lumo End End End if (lc=>lc_limit); // Actual light sector set_sector_texture(light_fx_data[lightnum].light_sector_A, -1, 38, light_fx_data[lightnum].light_sector_A_offlumo); // LIGHTS SWITCH 2 - switch back to original state (usually, lights off) // SECTORS For(modify_sect_c=0;modify_sect_c<49;modify_sect_c++); If (light_fx_data[lightnum].sector_list_A[modify_sect_c]==0); // Works fine Break; End If (light_fx_data[lightnum].modify_sectorstex_A==1); set_sector_texture(light_fx_data[lightnum].sector_list_A[modify_sect_c], sectorsA_saved_floor_textures[modify_sect_c], sectorsA_saved_roof_textures[modify_sect_c], sectorsA_saved_lumos[modify_sect_c]); ELSE set_sector_texture(light_fx_data[lightnum].sector_list_A[modify_sect_c], -1, -1, sectorsA_saved_lumos[modify_sect_c]); End End // END SECTORS // WALLS For(modify_wall_c=0;modify_wall_c<49;modify_wall_c++); // Walls... If (light_fx_data[lightnum].wall_list_A[modify_wall_c]==0); // Works fine Break; End If (light_fx_data[lightnum].modify_wallstex_A==1); set_wall_texture(light_fx_data[lightnum].wall_list_A[modify_wall_c], wallsA_saved_textures[modify_wall_c], wallsA_saved_lumos[modify_wall_c]); ELSE set_wall_texture(light_fx_data[lightnum].wall_list_A[modify_wall_c], -1, wallsA_saved_lumos[modify_wall_c]); End End // END WALLS lc=0; End // END SWITCH 2 CODE Frame; End End


Any help would be greatly appriciated - maybe you can see something here that I dont??

- BC

[Edited on 18-1-2018 by BreadCaster]




~*~ Princess of Pies and Pastries ~*~
View user's profile View All Posts By User
CicTec
DIV Pro
******




Posts: 433
Registered: 6-8-2016
Member Is Offline


[*] posted on 18-1-2018 at 09:14 PM


Hi BreadCaster,

Apparently everything seems ok, unfortunately it is difficult to establish something without actually trying it.

You should try to mount a small example, a single room with 4 walls, floor and ceil, set up lights, etc ... and then carry the code to test it.

If everything works fine, it's probably a problem in the game somewhere, if it does not work, then it's your routine or some DIV functions to revise.
View user's profile View All Posts By User
BreadCaster
Loyalty Card Holder
******


Avatar


Posts: 321
Registered: 2-3-2016
Member Is Offline


[*] posted on 19-1-2018 at 05:22 PM


Ok, I mounted a small example. It still doesnt work properly and I can't see why! This is really frustrating :(

https://www.sendspace.com/file/s8pmfh (i had to upload it on sendspace because for some reason it wouldnt upload on here?)

[Edited on 19-1-2018 by BreadCaster]




~*~ Princess of Pies and Pastries ~*~
View user's profile View All Posts By User
CicTec
DIV Pro
******




Posts: 433
Registered: 6-8-2016
Member Is Offline


[*] posted on 19-1-2018 at 05:49 PM


Quote: Originally posted by BreadCaster  
Ok, I mounted a small example. It still doesnt work properly and I can't see why! This is really frustrating :(

Ok I've downloaded the example, I'll try it tomorrow or Sunday and I'll try to give you info on what could be happening.

Quote: Originally posted by BreadCaster  

https://www.sendspace.com/file/s8pmfh (i had to upload it on sendspace because for some reason it wouldnt upload on here?)

[Edited on 19-1-2018 by BreadCaster]

You probably exceeded the size limits for attachments, I see that the file weighs 11MB and also includes DIV. :)

[Edited on 19-1-2018 by CicTec]
View user's profile View All Posts By User
BreadCaster
Loyalty Card Holder
******


Avatar


Posts: 321
Registered: 2-3-2016
Member Is Offline


[*] posted on 19-1-2018 at 07:12 PM


Quote: Originally posted by CicTec  
Quote: Originally posted by BreadCaster  
Ok, I mounted a small example. It still doesnt work properly and I can't see why! This is really frustrating :(

Ok I've downloaded the example, I'll try it tomorrow or Sunday and I'll try to give you info on what could be happening.

Quote: Originally posted by BreadCaster  

https://www.sendspace.com/file/s8pmfh (i had to upload it on sendspace because for some reason it wouldnt upload on here?)

[Edited on 19-1-2018 by BreadCaster]

You probably exceeded the size limits for attachments, I see that the file weighs 11MB and also includes DIV. :)

[Edited on 19-1-2018 by CicTec]


wonderfull, thank you CicTec! Ive spent at least two weeks on this bug now and its really annoying - I just want to work on the rest of the game and get it released, since I think people are really likely to enjoy it :)




~*~ Princess of Pies and Pastries ~*~
View user's profile View All Posts By User
CicTec
DIV Pro
******




Posts: 433
Registered: 6-8-2016
Member Is Offline


[*] posted on 20-1-2018 at 01:27 PM


Hi BreadCaster,

I'm analyzing your example, I think there are some mistakes, and some things are not clear:

1) lamp_off_roof_tex is set to 12, I think it should be set to 43 or am I wrong?

2) Opening the WLD file in the editor, I see that the texture of the lamp is set to 43 by default, this I think should be correct if the lamp is off initially and the room environment must be dark, otherwise it should be 38.

3) If you temporarily replenish your lighting routine with the following (after changing lamp_off_roof_tex to 43):
Code:
Process anim_light(flickertype, lightnum); Private Lc; Lc_limit; orig_lc_limit; rand_lc_val; modify_sect_c; modify_wall_c; sectorsA_saved_lumos[50]; sectorsA_saved_floor_textures[50]; sectorsA_saved_roof_textures[50]; wallsA_saved_lumos[50]; wallsA_saved_textures[50]; floor_, roof_, luminosity_; Begin SWITCH (flickertype); // Set flicker/blink patterns CASE 0: orig_lc_limit=90; END CASE 1: orig_lc_limit=150; END END lc_limit=orig_lc_limit; write_int(0, 30, 10, 3, &floor_); write_int(0, 30, 20, 3, &roof_); write_int(0, 30, 30, 3, &luminosity_); Loop; get_sector_texture(light_fx_data[lightnum].light_sector_A, &floor_, &roof_, &luminosity_); if (KEY(_T)); debug; end if(key(_1)) set_sector_texture(light_fx_data[lightnum].light_sector_A, -1, lamp_on_roof_tex, light_fx_data[lightnum].light_sector_A_onlumo); end if(key(_2)) set_sector_texture(light_fx_data[lightnum].light_sector_A, -1, lamp_off_roof_tex, light_fx_data[lightnum].light_sector_A_offlumo); end Frame; End End

You will notice that when the room is rendered initially it is as if it were on, but the lamp I think is off.
If you try to press keys 1 and 2, the lighting / texture should change correctly, or am I wrong?



[Edited on 20-1-2018 by CicTec]
View user's profile View All Posts By User
BreadCaster
Loyalty Card Holder
******


Avatar


Posts: 321
Registered: 2-3-2016
Member Is Offline


[*] posted on 22-1-2018 at 02:56 PM


Hi Cictec - sorry for the delay on getting back to you on this! yeah everything you said is correct, lamp_off_roof_tex should be set to 43. I changed the roof texture of the lamp to 43 aswell. My apologies, all this attempts at fixing this thing has left me a little bit rattled and easily confused :p

I've replenished the code on my end with the process that you posted - it does indeed work fine when pressing keys 1/2, and the roof/lumo variables do update correctly...




~*~ Princess of Pies and Pastries ~*~
View user's profile View All Posts By User
CicTec
DIV Pro
******




Posts: 433
Registered: 6-8-2016
Member Is Offline


[*] posted on 22-1-2018 at 03:02 PM


Hi BreadCaster,

No problem, so it was just a code problem ?, does it work all the way it should in the game / lighting algorithm?
View user's profile View All Posts By User
BreadCaster
Loyalty Card Holder
******


Avatar


Posts: 321
Registered: 2-3-2016
Member Is Offline


[*] posted on 22-1-2018 at 03:11 PM


hmm, it must be a code issue, yeah. Ill try coding it again from scratch but I cant see how it could be having problems, it all looks fine :S



~*~ Princess of Pies and Pastries ~*~
View user's profile View All Posts By User
CicTec
DIV Pro
******




Posts: 433
Registered: 6-8-2016
Member Is Offline


[*] posted on 22-1-2018 at 03:20 PM


Try the system first in the small example:
1) Set correctly all the initial textures and lights of the WLD environment (WLD file).
2) Make simple mode8 function calls by pressing the keys, to change the ambient lighting.
3) So try more complex code to debug error.
4) When everything works in the small example, bring the code to your game and try, so you can see if everything works ok, or if there are other problems in the code of the game.

If you have any other problem or other, do not doubt in pointing it out.
View user's profile View All Posts By User
BreadCaster
Loyalty Card Holder
******


Avatar


Posts: 321
Registered: 2-3-2016
Member Is Offline


[*] posted on 22-1-2018 at 05:03 PM


ok so, i tried something.

firstly i added these lines:

Code:
light_fx_data[0].sector_list_A[3]=-1; light_fx_data[0].wall_list_A[15]=-1;


to the light_fx_data bit just to signal when the list of walls and sectors has ended.

I then updated the anim_light process, however there is a strange glitch again, and it might be with set_sector_texture. (I have not tried set_wall_texture yet, as I wanted to get the sector lighting working okay first!)

Now, when pressing 1, the light sector is set correctly as before, and the process then runs through a FROM loop to save the environmental info - lumonisities, textures, etc. I checked using debug; and it DOES save the luminosities into sectorsA_saved_lumos[0 to 2] - all 3 slots are set to a value of 5. There is then a FROM loop to set the sector textures to appear lit up. Then, when pressing 2, there is another FROM loop to set the textures back to their original luminosities, floor textures & roof textures.

However, when trying this code, it's visible that they are not set to the same lumonisity as the light sector. I've even put a get_sector_texture for sector 2 & a new set of write_ints in the code to double check (sector 2 is the sector that surrounds the light sector), and the program SAYS that it's lumonsity is set to 5 - but it clearly isnt!

This keeps getting weirder and weirder, you really have to see it to believe it... :fake sniffle:

Code:
Process anim_light(flickertype, lightnum); Private Lc; Lc_limit; orig_lc_limit; rand_lc_val; sectorsA_saved_lumos[50]; sectorsA_saved_floor_textures[50]; sectorsA_saved_roof_textures[50]; wallsA_saved_lumos[50]; wallsA_saved_textures[50]; floor_, roof_, luminosity_; sector2_floor_, sector2_roof_, sector2_luminosity_; save_env_c; set_env_c; light_info_stored; Begin SWITCH (flickertype); // Set flicker/blink patterns CASE 0: orig_lc_limit=90; END CASE 1: orig_lc_limit=150; END END lc_limit=orig_lc_limit; write_int(0, 30, 10, 3, &floor_); write_int(0, 30, 20, 3, &roof_); write_int(0, 30, 30, 3, &luminosity_); write_int(0, 60, 10, 3, &sector2_floor_); write_int(0, 60, 20, 3, &sector2_roof_); write_int(0, 60, 30, 3, &sector2_luminosity_); Loop; get_sector_texture(light_fx_data[lightnum].light_sector_A, &floor_, &roof_, &luminosity_); get_sector_texture(2, &sector2_floor_, &sector2_roof_, &sector2_luminosity_); if (KEY(_T)); debug; end if (key(_1)); set_sector_texture(light_fx_data[lightnum].light_sector_A, -1, lamp_on_roof_tex, light_fx_data[lightnum].light_sector_A_onlumo); // SAVE env start If (light_info_stored==0); // Only gets the info first time FROM save_env_c = 0 to 49; // Sectors If (light_fx_data[lightnum].sector_list_A[save_env_c]==-1); light_info_stored=1; // So it doesnt try to save again Break; End get_sector_texture(light_fx_data[lightnum].sector_list_A[save_env_c], &sectorsA_saved_floor_textures[save_env_c], &sectorsA_saved_roof_textures[save_env_c], &sectorsA_saved_lumos[save_env_c]); End End // SAVE env end // SET env start FROM set_env_c = 0 to 49; If (light_fx_data[lightnum].sector_list_A[set_env_c]==-1); Break; End if (light_fx_data[lightnum].modify_sectorstex_A==1); set_sector_texture(light_fx_data[lightnum].sector_list_A[set_env_c], light_fx_data[lightnum].modifyto_floortexture_sectors_A[set_env_c], light_fx_data[lightnum].modifyto_rooftexture_sectors_A[set_env_c], light_fx_data[lightnum].sector_lumo_A); Else set_sector_texture(light_fx_data[lightnum].sector_list_A[set_env_c], -1, -1, light_fx_data[lightnum].sector_lumo_A); End End // SET env end end if(key(_2) and light_info_stored==1) set_sector_texture(light_fx_data[lightnum].light_sector_A, -1, lamp_off_roof_tex, light_fx_data[lightnum].light_sector_A_offlumo); FROM set_env_c = 0 to 49; If (light_fx_data[lightnum].sector_list_A[set_env_c]==-1); Break; End if (light_fx_data[lightnum].modify_sectorstex_A==1); set_sector_texture(light_fx_data[lightnum].sector_list_A[set_env_c], sectorsA_saved_floor_textures[set_env_c], sectorsA_saved_roof_textures[set_env_c], sectorsA_saved_lumos[set_env_c]); Else set_sector_texture(light_fx_data[lightnum].sector_list_A[set_env_c], -1, -1, sectorsA_saved_lumos[set_env_c]); End End end Frame; End End


EDIT: I realized that sector2_ variables were not actually reading from sector 2 - have since modified that and found that the sector2_lumonisity is being set to 10, not 5.

[Edited on 22-1-2018 by BreadCaster]




~*~ Princess of Pies and Pastries ~*~
View user's profile View All Posts By User
CicTec
DIV Pro
******




Posts: 433
Registered: 6-8-2016
Member Is Offline


[*] posted on 22-1-2018 at 07:24 PM


Yes, I think this system of lights has made you confuse a lot, in fact I was writing that the variables for sector 2 are always set on sector 5, in fact by querying the correct sector, when you press 2 it indicates brightness 10 and not 5 as it should be, so some wrong value is passing to the SET_SECTOR_TEXTURE function.

Do a simple direct setting of the brightness of sectors 2, 4, and 6 without using the structure, if everything works then SET_SECTOR_TEXTURE is OK, in this case it could be some other bugs of your rutine or some DIV bugs in the use of arrays / structures to be verified.
View user's profile View All Posts By User
BreadCaster
Loyalty Card Holder
******


Avatar


Posts: 321
Registered: 2-3-2016
Member Is Offline


[*] posted on 22-1-2018 at 07:48 PM


Huh. Okay - so:

Code:
set_sector_texture(2, -1, -1, light_fx_data[lightnum].light_sector_A_offlumo); set_sector_texture(4, -1, -1, light_fx_data[lightnum].light_sector_A_offlumo); set_sector_texture(6, -1, -1, light_fx_data[lightnum].light_sector_A_offlumo);


sets sectors 2, 4 and 6 luminosity to a value of 5. But:

Code:
set_sector_texture(2, -1, -1, sectorsA_saved_lumos[set_env_c]); set_sector_texture(4, -1, -1, sectorsA_saved_lumos[set_env_c]); set_sector_texture(6, -1, -1, sectorsA_saved_lumos[set_env_c]);


sets sectors 2, 4 and 6 luminosity to a value of 10. But when you look in the Div Debugger, sectorsA_saved_lumos[0]=5, sectorsA_saved_lumos[1]=5 and sectorsA_saved_lumos[2]=5. This is inside the From loop that is DEFINITELY going thru numbers 0 to 2. Wtf?! :lol:

[Edited on 22-1-2018 by BreadCaster]




~*~ Princess of Pies and Pastries ~*~
View user's profile View All Posts By User
BreadCaster
Loyalty Card Holder
******


Avatar


Posts: 321
Registered: 2-3-2016
Member Is Offline


[*] posted on 22-1-2018 at 07:53 PM


Changing the values of sectorsA_saved_lumos[0 to 2] to 10 in the debugger FIXES the problem, everything lights up evenly, even tho on paper that makes no sense at all.... :S



~*~ Princess of Pies and Pastries ~*~
View user's profile View All Posts By User
CicTec
DIV Pro
******




Posts: 433
Registered: 6-8-2016
Member Is Offline


[*] posted on 22-1-2018 at 07:54 PM


So it seems possible to bug in the use of arrays or debugger by DIV,

Print on the screen with simple write_int's the values of the array, using:
sectorsA_saved_lumos[set_env_c]
and
sectorsA_saved_lumos[0]
sectorsA_saved_lumos[1]
etc ...

To see if they actually contain the correct values or not, unfortunately now I do not have time to do these tests, if you can try you see where the bugs are in the settings.

Try also to use SET_SECTOR_TEXTURE using constant values (5, 10, and so..) to see if it has a bug or not.
View user's profile View All Posts By User
BreadCaster
Loyalty Card Holder
******


Avatar


Posts: 321
Registered: 2-3-2016
Member Is Offline


[*] posted on 23-1-2018 at 03:56 PM


Ok, so I've tried some things.

Top left stats are the original textures and luminosity, top right stats are sector 2 textures and luminosity.

Bottom left stats are, as stated, the sectors in light_fx_data[0].sector_list_A[0 to 2] and bottom right stats are sectorsA_saved_lumos[0 to 2].







I still really think its some kind of bug with DIV! can't see how this could be my code at this point :(

EDIT: Using set_sector_texture(light_fx_data[0].sector_list_A[0 to 2], -1, -1, 5); doesnt work either, it sets it to 10, just like if I were using sectorsA_saved_lumos[0 to 2]. Maybe set_sector_texture doesnt like reading from arrays?

[Edited on 23-1-2018 by BreadCaster]




~*~ Princess of Pies and Pastries ~*~
View user's profile View All Posts By User
CicTec
DIV Pro
******




Posts: 433
Registered: 6-8-2016
Member Is Offline


[*] posted on 23-1-2018 at 06:34 PM


Ok, i've found the problem...

According to the DIV documentation on the SET_SECTOR_TEXTURE function about the luminosity param, it says:
Quote:

<luminosity> - luminosity of the texture. from 0 (ambience colour, wich is normally black) up to 15
(texture with the original colours). IF a -1 is indicated. the current level of luminosity in the sector will remain unchanged.


So if we set it to 15, we have the original colors of the texture, if it is 0, it will be equal to the color of the environment, otherwise blending values between the color texture and color environment.

If you open your WLD, you will see that the initial luminosity value is set to 10 (no is displayed in the editor, only you see the luminosity level of the texture compared to the original colors), however, when we try to retrieve the value with GET_SECTOR_TEXTURE, it returns 5, so when trying to restore the saved original value, obviously the luminosity is wrong.

The problem is ultimately a bug in the GET_SECTOR_TEXTURE function, because the VPE needs to keep the luminosity value as opposed to what we indicate with the SET function, however the GET function does not re-convert this value, just returns that used by VPE, not the one used by us according to the documentation.

As a test, just try the following code:
Code:
if(key(_1)); set_sector_texture(5, -1, lamp_on_roof_tex, 15); set_sector_texture(2, -1, -1, 15); set_sector_texture(4, -1, -1, 15); set_sector_texture(6, -1, -1, 15); end if(key(_2)) set_sector_texture(5, -1, lamp_off_roof_tex, -1); set_sector_texture(2, -1, -1, 10); set_sector_texture(4, -1, -1, 10); set_sector_texture(6, -1, -1, 10); end

Where it clearly shows that SET_SECTOR_TEXTURE works well.

I've fixed GET_SECTOR_TEXTURE and now your algorithm works fine :)

For the moment do not use the GET function, save the original luminosiity values of the WLD in an array and use it to restore when necessary, until a new build of DIV with the fix is available.
View user's profile View All Posts By User
CicTec
DIV Pro
******




Posts: 433
Registered: 6-8-2016
Member Is Offline


[*] posted on 23-1-2018 at 06:38 PM


Alternatively, if you do not want to save everything in an array, you can possibly do a workaround for now, as follows.
Code:
get_sector_texture(..........., &luminosity); luminosity = 15 - luminosity; // temp workaround fix.

So all should be work as espected.

[Edited on 23-1-2018 by CicTec]
View user's profile View All Posts By User
BreadCaster
Loyalty Card Holder
******


Avatar


Posts: 321
Registered: 2-3-2016
Member Is Offline


[*] posted on 23-1-2018 at 07:28 PM


FanTASTIC! I'm so glad you dedicated the time to helping out with this, Cictec - I really wanted to make sure that we worked out what the bug in Div was so it can be fixed in future versions :)

I'm using the workaround from your second reply (the lumo=15-lumo fix) and I can see how that works, and the program now works perfectly. I've got the perfected code here in case anyone wants to try it out for themselves - thanks so much for your help :D I'll include you in the final game credits.

Code:
Process anim_light(flickertype, lightnum); Private Lc; Lc_limit; orig_lc_limit; rand_lc_val; sectorsA_saved_lumos[50]; sectorsA_saved_floor_textures[50]; sectorsA_saved_roof_textures[50]; wallsA_saved_lumos[50]; wallsA_saved_textures[50]; save_env_c; set_env_c; set_defaults; LUMO_BUG_WORKAROUND=15; sector_light_info_stored; wall_light_info_stored; Begin SWITCH (flickertype); // Set flicker/blink patterns CASE 0: orig_lc_limit=90; END CASE 1: orig_lc_limit=150; END END lc_limit=orig_lc_limit; // Workaround for undeclared textures (if modifying wall/sector textures) // This sets the left over texture variables to -1 so they arent set to 0 if (light_fx_data[lightnum].modify_wallstex_A==1); From set_defaults=0 to 49; if (light_fx_data[lightnum].modifyto_texture_wall_A[set_defaults]==0); light_fx_data[lightnum].modifyto_texture_wall_A[set_defaults]=-1; End End End if (light_fx_data[lightnum].modify_sectorstex_A==1); From set_defaults=0 to 49; if (light_fx_data[lightnum].modifyto_floortexture_sectors_A[set_defaults]==0); light_fx_data[lightnum].modifyto_floortexture_sectors_A[set_defaults]=-1; End if (light_fx_data[lightnum].modifyto_rooftexture_sectors_A[set_defaults]==0); light_fx_data[lightnum].modifyto_rooftexture_sectors_A[set_defaults]=-1; End End End Loop; if (KEY(_I)); debug; end if (key(_1)); set_sector_texture(light_fx_data[lightnum].light_sector_A, -1, lamp_on_roof_tex, light_fx_data[lightnum].light_sector_A_onlumo); // SAVE env start If (sector_light_info_stored==0); // Only gets the info first time FROM save_env_c = 0 to 49; // Sectors If (light_fx_data[lightnum].sector_list_A[save_env_c]==-1); sector_light_info_stored=1; // So it doesnt try to save again Break; End get_sector_texture(light_fx_data[lightnum].sector_list_A[save_env_c], &sectorsA_saved_floor_textures[save_env_c], &sectorsA_saved_roof_textures[save_env_c], &sectorsA_saved_lumos[save_env_c]); sectorsA_saved_lumos[save_env_c]=LUMO_BUG_WORKAROUND-sectorsA_saved_lumos[save_env_c]; End End If (wall_light_info_stored==0); // Only gets the info first time FROM save_env_c = 0 to 49; // Walls If (light_fx_data[lightnum].wall_list_A[save_env_c]==-1); wall_light_info_stored=1; // So it doesnt try to save again Break; End get_wall_texture(light_fx_data[lightnum].wall_list_A[save_env_c], &wallsA_saved_textures[save_env_c], &wallsA_saved_lumos[save_env_c]); wallsA_saved_lumos[save_env_c]=LUMO_BUG_WORKAROUND-wallsA_saved_lumos[save_env_c]; End End // SAVE env end // SET env start FROM set_env_c = 0 to 49; // Sectors If (light_fx_data[lightnum].sector_list_A[set_env_c]==-1); Break; End if (light_fx_data[lightnum].modify_sectorstex_A==1); set_sector_texture(light_fx_data[lightnum].sector_list_A[set_env_c], light_fx_data[lightnum].modifyto_floortexture_sectors_A[set_env_c], light_fx_data[lightnum].modifyto_rooftexture_sectors_A[set_env_c], light_fx_data[lightnum].sector_lumo_A); Else set_sector_texture(light_fx_data[lightnum].sector_list_A[set_env_c], -1, -1, light_fx_data[lightnum].sector_lumo_A); End End FROM set_env_c = 0 to 49; // Walls If (light_fx_data[lightnum].wall_list_A[set_env_c]==-1); Break; End if (light_fx_data[lightnum].modify_wallstex_A==1); set_wall_texture(light_fx_data[lightnum].wall_list_A[set_env_c], light_fx_data[lightnum].modifyto_texture_wall_A[set_env_c], light_fx_data[lightnum].wall_lumo_A); Else set_wall_texture(light_fx_data[lightnum].wall_list_A[set_env_c], -1, light_fx_data[lightnum].wall_lumo_A); End End // SET env end end if(key(_2) and sector_light_info_stored==1 and wall_light_info_stored==1); set_sector_texture(light_fx_data[lightnum].light_sector_A, -1, lamp_off_roof_tex, light_fx_data[lightnum].light_sector_A_offlumo); FROM set_env_c = 0 to 49; // Sectors If (light_fx_data[lightnum].sector_list_A[set_env_c]==-1); Break; End if (light_fx_data[lightnum].modify_sectorstex_A==1); set_sector_texture(light_fx_data[lightnum].sector_list_A[set_env_c], sectorsA_saved_floor_textures[set_env_c], sectorsA_saved_roof_textures[set_env_c], sectorsA_saved_lumos[set_env_c]); Else set_sector_texture(light_fx_data[lightnum].sector_list_A[set_env_c], -1, -1, sectorsA_saved_lumos[set_env_c]); End End FROM set_env_c = 0 to 49; // Walls If (light_fx_data[lightnum].wall_list_A[set_env_c]==-1); Break; End if (light_fx_data[lightnum].modify_wallstex_A==1); set_wall_texture(light_fx_data[lightnum].wall_list_A[set_env_c], wallsA_saved_textures[set_env_c], wallsA_saved_lumos[set_env_c]); Else set_wall_texture(light_fx_data[lightnum].wall_list_A[set_env_c], -1, wallsA_saved_lumos[set_env_c]); End End end Frame; End End




~*~ Princess of Pies and Pastries ~*~
View user's profile View All Posts By User
CicTec
DIV Pro
******




Posts: 433
Registered: 6-8-2016
Member Is Offline


[*] posted on 23-1-2018 at 08:24 PM


Quote: Originally posted by BreadCaster  
I really wanted to make sure that we worked out what the bug in Div was so it can be fixed in future versions :)

Yes, in the end we were able to detect and correct the bug.

Quote: Originally posted by BreadCaster  

thanks so much for your help :D I'll include you in the final game credits.

Thanks for the credits, it was however a pleasure to help you, now go with the game. ;)
View user's profile View All Posts By User
CicTec
DIV Pro
******




Posts: 433
Registered: 6-8-2016
Member Is Offline


[*] posted on 23-1-2018 at 09:53 PM


As a further note, I am seeing that GET_WALL_TEXTURE has the same bug and SET_WALL_TEXTURE does not leave the luminosity unchanged if you pass the -1 value to the corresponding parameter, this is the same bug you notified me to SET_SECTOR_TEXTURE.

I've also fixed these functions now. If you use them in your project, for GET_WALL_TEXTURE you can use the workaround described above, if you need to use SET_WALL_TEXTURE with parameter -1, you must save the original value of brightness in some variable or constant then use these to restore everything.


[Edited on 24-1-2018 by CicTec]
View user's profile View All Posts By User
MikeDX
DIV Nerd
*********


Avatar


Posts: 8388607
Registered: 25-2-2016
Member Is Offline


[*] posted on 25-1-2018 at 10:25 PM


Cictec can you submit a pull request for this fix please (name it fixes/mode8_sectors as a branch and then submit a pull request only of that branch)

Also I am trying to catch up on the older pull requests and would like to merge both John's translation patches and your own fixes into the system and then see about doing a serious refactor of the code.

View user's profile View All Posts By User
CicTec
DIV Pro
******




Posts: 433
Registered: 6-8-2016
Member Is Offline


[*] posted on 25-1-2018 at 11:40 PM


Quote: Originally posted by MikeDX  
Cictec can you submit a pull request for this fix please (name it fixes/mode8_sectors as a branch and then submit a pull request only of that branch)

Currently I am in Linux and I have not had time to install a proper GIT system that allows me to perform a pull request or other in an appropriate manner, also my fork-repository is not updated with the fix, they are only locally.

I'll send you the fixes tomorrow anyway, it's just a modified file, but first you should merge my last pull-request before add it to official repository, if you encounter problems, delete my pull-request and I'll pass you the complete code I have here of DIV (I've already make a build of DIV here on Ubuntu Linux and it works correctly, you can perform further tests on your OS for safety).

Quote: Originally posted by MikeDX  

Also I am trying to catch up on the older pull requests and would like to merge both John's translation patches and your own fixes into the system

It seems excellent.

Quote: Originally posted by MikeDX  

and then see about doing a serious refactor of the code.

If this relates to what we discussed at the last meeting, it seems to me excellent news, maybe we should organize another to continue discussing this.

If you refer instead to this current version of DIV, my suggestion is to perform only a bug-fix where possible, and maybe formatting of code and translation from spanish to english, then leave it more like a DIV2Modern for historical and affective reasons (also because the current structure of the basic code does not provide easy possibilities to add new features), so devote all your efforts and free time that you can apply to the project to a complete rewrite for the real version of DIV3, you'll have less problems this way.
View user's profile View All Posts By User

  Go To Top

Powered by XMB
XMB Forum Software © 2001-2012 The XMB Group
[Queries: 18]