Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pixellight #559

Closed
wants to merge 103 commits into from
Closed
Show file tree
Hide file tree
Changes from 90 commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
155b5b7
blendtry1
qndel Jan 27, 2020
9058f22
static lights attempt1
qndel Jan 28, 2020
05c79f6
static lights attempt1
qndel Jan 28, 2020
fe456a7
before trying to use textures
qndel Jan 28, 2020
38a3651
light PR
qndel Jan 28, 2020
c026c81
code cleanup
qndel Jan 28, 2020
be9629d
code cleanup
qndel Jan 28, 2020
3fd803e
code cleanup
qndel Jan 28, 2020
971c589
code cleanup
qndel Jan 28, 2020
e971145
code cleanup
qndel Jan 28, 2020
e58085a
code cleanup
qndel Jan 28, 2020
8ae7504
fixed memory leak
qndel Jan 28, 2020
8a3c04b
cut fps hole only if fps displayed
qndel Jan 28, 2020
93a3838
static lights
qndel Jan 28, 2020
c5dcad8
fix travis error
qndel Jan 28, 2020
44f4e0e
fix SDL1 build
qndel Jan 28, 2020
be6af23
fix static light jumping
qndel Jan 28, 2020
ac2459c
separate ui test
qndel Jan 28, 2020
03cdc9f
separate ui test
qndel Jan 28, 2020
bb78514
separate ui test
qndel Jan 28, 2020
33ee6f7
ui work in progress
qndel Jan 28, 2020
a744ccb
still doesnt work
qndel Jan 28, 2020
b3ae81e
almost works
qndel Jan 29, 2020
b7a2c9d
everything works except missiles
qndel Jan 29, 2020
8ae1a05
fix shadows
qndel Jan 29, 2020
f1071ff
fix missiles jumping around
qndel Jan 29, 2020
94e715f
fix light affecting black ui elements
qndel Jan 29, 2020
eff2605
add some spell colors
qndel Jan 29, 2020
25074a6
use TILE_SIZE
qndel Jan 29, 2020
e54348f
fixed light being cut off
qndel Jan 29, 2020
ac38cf9
improve light formula
qndel Jan 29, 2020
b4efd54
blue color tweak
qndel Jan 29, 2020
5e5950c
partially fix ui and stuff staying in main menu
qndel Jan 29, 2020
8512ece
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Jan 29, 2020
0463732
get rid of the fps stuff
qndel Jan 29, 2020
ecec16a
some cleanup
qndel Jan 29, 2020
3453733
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Jan 29, 2020
9e5e19c
Hackity hack hack
glebm Jan 29, 2020
9ec77c1
Merge pull request #1 from glebm/pixellight
qndel Jan 29, 2020
1bb6082
Merge branch 'pixellight' of https://github.com/qndel/devilutionX int…
qndel Jan 29, 2020
fe6d0a0
some code cleanup, fix compiling
qndel Jan 30, 2020
5304c54
fix static lights on first load
qndel Jan 30, 2020
ab91502
remove SDL_Logs
qndel Jan 30, 2020
bb09beb
crappy fix, cant do better
qndel Jan 30, 2020
986c2b1
everything fully works! - except cursor
qndel Jan 31, 2020
04499d6
use unused variable to avoid modifying saves
qndel Jan 31, 2020
9eae567
small fix
qndel Jan 31, 2020
1db3a59
remove unused extern
qndel Jan 31, 2020
9171d12
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Jan 31, 2020
1b79376
merge
qndel Feb 1, 2020
596036d
working shitcode
qndel Feb 1, 2020
afec01d
working shitcode
qndel Feb 1, 2020
a9c3c3d
everything works again
qndel Feb 1, 2020
8e1fb0f
fix conflicts
qndel Feb 1, 2020
8df54cc
fix build - define POINT
qndel Feb 1, 2020
974bb74
cursor fully works
qndel Feb 1, 2020
055d40b
rewrite red on pause/death
qndel Feb 1, 2020
bb9b998
fix light on lags
qndel Feb 1, 2020
bb54e16
rewrite light color map, apply to all missiles
qndel Feb 2, 2020
b6a0067
handle different arrows properly
qndel Feb 2, 2020
a5af9d4
staticLights into vector
qndel Feb 2, 2020
f17ba0e
fix some warnings
qndel Feb 2, 2020
e797a45
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 2, 2020
b9ad301
revert at, doesnt work lol
qndel Feb 3, 2020
927c569
saving to character - careful, might break char
qndel Feb 3, 2020
ca62251
restore formatting
qndel Feb 3, 2020
3388741
restore formatting
qndel Feb 3, 2020
82353d0
minor tweaks
qndel Feb 3, 2020
c7402b9
im done with this shit
qndel Feb 4, 2020
25b9ab3
build fix
qndel Feb 4, 2020
64ee8cf
fix monster light
qndel Feb 5, 2020
e9f789a
small tweaks
qndel Feb 5, 2020
be17cdd
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 8, 2020
f6a442e
memory optimizations
qndel Feb 8, 2020
721d2b6
formatting
qndel Feb 8, 2020
3a37c18
adjust light position
qndel Feb 8, 2020
27928c6
even less memory
qndel Feb 8, 2020
8e52b39
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 8, 2020
7dbec08
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 9, 2020
f2920ca
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 9, 2020
0750dda
fix merge conflict
qndel Feb 9, 2020
bfd7770
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 11, 2020
8663102
fix conflict
qndel Feb 17, 2020
8c1e6d5
everything broke
qndel Feb 19, 2020
d9a17ec
restoring includes
qndel Feb 19, 2020
534cb50
Merge branch 'pixellight' of https://github.com/qndel/devilutionX int…
qndel Feb 19, 2020
1092c01
disable light if upscale 0
qndel Feb 19, 2020
e7bef88
disable light during screenshots
qndel Feb 19, 2020
353e705
minor cleanup
qndel Feb 19, 2020
83c5dff
poisoned water color / change light to lighten_only
qndel Feb 19, 2020
e93f166
enable light in town (WIP)
qndel Feb 22, 2020
dd32574
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 22, 2020
8be4d0c
light in town
qndel Feb 23, 2020
ead0adc
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Feb 23, 2020
5b68cbf
Merge branch 'master' of https://github.com/diasurgical/devilutionX i…
qndel Mar 17, 2020
fee9c54
fix conflict
qndel Mar 29, 2020
28fa025
fixed conflicts
qndel Apr 11, 2020
83650e9
fixed conflicts2
qndel Apr 11, 2020
a572009
update enums
qndel Apr 11, 2020
d43a212
fix light
qndel Apr 11, 2020
ccecde6
fix space
qndel Apr 12, 2020
a25689c
move town light to new mpq in save
qndel Apr 12, 2020
939c049
fix size
qndel Apr 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Source/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#define __ALL_H__

#include <SDL.h>
#include <vector>
#include <map>
#include <string>

#ifdef USE_SDL1
#include "sdl2_to_1_2_backports.h"
Expand Down
20 changes: 20 additions & 0 deletions Source/capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,27 @@ void CaptureScreen()

std::ofstream *out = CaptureFile(FileName);
if (out == nullptr) return;
#ifdef PIXEL_LIGHT
//disables per pixel light during screenshot
int tmp1 = testvar1;
int tmp2 = testvar2;
int tmp3 = testvar3;
int tmp4 = testvar4;
int tmp5 = testvar5;
testvar1 = 0;
testvar2 = 8;
testvar3 = 0;
testvar4 = 0;
testvar5 = 0;
#endif
DrawAndBlit();
#ifdef PIXEL_LIGHT
testvar1 = tmp1;
testvar2 = tmp2;
testvar3 = tmp3;
testvar4 = tmp4;
testvar5 = tmp5;
#endif
PaletteGetEntries(256, palette);
RedPalette();

Expand Down
4 changes: 4 additions & 0 deletions Source/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,10 @@ void RedBack()
{
int idx;

#ifdef PIXEL_LIGHT
drawRed = true;
return;
#endif
idx = light4flag ? 1536 : 4608;

/// ASSERT: assert(gpBuffer);
Expand Down
33 changes: 33 additions & 0 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ void run_game_loop(unsigned int uMsg)
SetCursor_(CURSOR_NONE);
ClearScreenBuffer();
force_redraw = 255;
#ifdef PIXEL_LIGHT
//deals with the transition while quitting diablo
redrawLights = 1;
#endif
scrollrt_draw_game_screen(TRUE);
saveProc = SetWindowProc(saveProc);
/// ASSERT: assert(saveProc == GM_Game);
Expand Down Expand Up @@ -1157,30 +1161,55 @@ void PressChar(int vkey)
return;
case '!':
case '1':
#if defined PIXEL_LIGHT && defined _DEBUG
testvar1 = ++testvar1 % 3;
CalcPlrItemVals(myplr, FALSE);
return;
#endif
if (plr[myplr].SpdList[0]._itype != ITYPE_NONE && plr[myplr].SpdList[0]._itype != ITYPE_GOLD) {
UseInvItem(myplr, INVITEM_BELT_FIRST);
}
return;
case '@':
case '2':
#if defined PIXEL_LIGHT && defined _DEBUG
testvar2 = ++testvar2 % 10;
CalcPlrItemVals(myplr, FALSE);
return;
#endif
if (plr[myplr].SpdList[1]._itype != ITYPE_NONE && plr[myplr].SpdList[1]._itype != ITYPE_GOLD) {
UseInvItem(myplr, INVITEM_BELT_FIRST + 1);
}
return;
case '#':
case '3':
#if defined PIXEL_LIGHT && defined _DEBUG
testvar3 = ++testvar3 % 2;
CalcPlrItemVals(myplr, FALSE);
return;
#endif
if (plr[myplr].SpdList[2]._itype != ITYPE_NONE && plr[myplr].SpdList[2]._itype != ITYPE_GOLD) {
UseInvItem(myplr, INVITEM_BELT_FIRST + 2);
}
return;
case '$':
case '4':
#if defined PIXEL_LIGHT && defined _DEBUG
testvar4 = ++testvar4 % 2;
CalcPlrItemVals(myplr, FALSE);
return;
#endif
if (plr[myplr].SpdList[3]._itype != ITYPE_NONE && plr[myplr].SpdList[3]._itype != ITYPE_GOLD) {
UseInvItem(myplr, INVITEM_BELT_FIRST + 3);
}
return;
case '%':
case '5':
#if defined PIXEL_LIGHT && defined _DEBUG
testvar5 = ++testvar5 % 4;
CalcPlrItemVals(myplr, FALSE);
return;
#endif
if (plr[myplr].SpdList[4]._itype != ITYPE_NONE && plr[myplr].SpdList[4]._itype != ITYPE_GOLD) {
UseInvItem(myplr, INVITEM_BELT_FIRST + 4);
}
Expand Down Expand Up @@ -1700,6 +1729,10 @@ void timeout_cursor(BOOL bTimeout)
SetCursor_(CURSOR_HOURGLASS);
force_redraw = 255;
}
#ifdef PIXEL_LIGHT
//deals with the lights while lagging
redrawLights = 1;
#endif
scrollrt_draw_game_screen(TRUE);
} else if (sgnTimeoutCurs) {
SetCursor_(sgnTimeoutCurs);
Expand Down
7 changes: 7 additions & 0 deletions Source/gamemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,16 @@ void gamemenu_new_game(BOOL bActivate)

deathflag = FALSE;
force_redraw = 255;
#ifdef PIXEL_LIGHT
//deals with the transition when choosing new game from ingame menu
redrawLights = 1;
#endif
scrollrt_draw_game_screen(TRUE);
gbRunGame = FALSE;
gamemenu_off();
#ifdef PIXEL_LIGHT
staticLights.clear();
#endif
}

void gamemenu_quit_game(BOOL bActivate)
Expand Down
4 changes: 4 additions & 0 deletions Source/interfac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ void ShowProgress(unsigned int uMsg)

gbSomebodyWonGameKludge = FALSE;
plrmsg_delay(TRUE);
#ifdef PIXEL_LIGHT
// disables light system till next DrawAndBlit which renders the dungeon
redrawLights = -1;
#endif

/// ASSERT: assert(ghMainWnd);
saveProc = SetWindowProc(DisableInputWndProc);
Expand Down
3 changes: 3 additions & 0 deletions Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ void CalcPlrItemVals(int p, BOOL Loadgfx)
int ghit = 0; // increased damage from enemies

int lrad = 10; // light radius
#ifdef PIXEL_LIGHT
lrad = 2 + testvar2;
#endif

int ihp = 0; // increased HP
int imana = 0; // increased mana
Expand Down
38 changes: 38 additions & 0 deletions Source/lighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,37 @@ void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum)
block_x = 0;
block_y = 0;

#ifdef PIXEL_LIGHT
if (Lnum == -1) {
bool updated = false;
int color = lightColorMap["STATICLIGHT"];
if (setlevel && setlvlnum == SL_POISONWATER) {
if (quests[QTYPE_PW]._qactive == 3) {
color = lightColorMap["CLEAREDWATER"];
} else {
color = lightColorMap["POISONEDWATER"];
}
}
for (int i = 0; i < staticLights[currlevel + setlvlnum * (32 * setlevel)].size(); i++) {
LightListStruct *it = &staticLights[currlevel + setlvlnum * (32 * setlevel)][i];
if (it->_lx == nXPos && it->_ly == nYPos) {
it->_lradius = nRadius;
it->_lcolor = color;
updated = true;
break;
}
}
if (!updated){
LightListStruct tmp;
tmp._lx = nXPos;
tmp._ly = nYPos;
tmp._lradius = nRadius;
tmp._lcolor = color;
staticLights[currlevel + setlvlnum * (32 * setlevel)].push_back(tmp);
}
}

#endif
if (Lnum >= 0) {
xoff = LightList[Lnum]._xoff;
yoff = LightList[Lnum]._yoff;
Expand Down Expand Up @@ -1019,7 +1050,11 @@ void InitLighting()
}
}

#ifdef PIXEL_LIGHT
int AddLight(int x, int y, int r, int color)
#else
int AddLight(int x, int y, int r)
#endif
{
int lid;

Expand All @@ -1038,6 +1073,9 @@ int AddLight(int x, int y, int r)
LightList[lid]._yoff = 0;
LightList[lid]._ldel = 0;
LightList[lid]._lunflag = 0;
#ifdef PIXEL_LIGHT
LightList[lid]._lcolor = color;
#endif
dolighting = TRUE;
}

Expand Down
4 changes: 4 additions & 0 deletions Source/lighting.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ void ToggleLighting();
#endif
void InitLightMax();
void InitLighting();
#ifdef PIXEL_LIGHT
int AddLight(int x, int y, int r, int color = 0xFFFFFF);
#else
int AddLight(int x, int y, int r);
#endif
void AddUnLight(int i);
void ChangeLightRadius(int i, int r);
void ChangeLightXY(int i, int x, int y);
Expand Down
70 changes: 65 additions & 5 deletions Source/loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ DEVILUTION_BEGIN_NAMESPACE

BYTE *tbuff;

#ifdef PIXEL_LIGHT
void CopyInt(const void *src, void *dst);
#endif
void LoadGame(BOOL firstflag)
{
int i, j;
Expand All @@ -14,6 +17,29 @@ void LoadGame(BOOL firstflag)

FreeGameMem();
pfile_remove_temp_files();
#ifdef PIXEL_LIGHT
staticLights.clear();
int mapSize;
LoadBuff = pfile_read("staticlights", &dwLen);
if (LoadBuff != NULL) {
tbuff = LoadBuff;
CopyInt(tbuff, &mapSize);
for (int i = 0; i < mapSize; i++) {
int key, vectorSize;
CopyInt(tbuff, &key);
CopyInt(tbuff, &vectorSize);
for (int j = 0; j < vectorSize; j++) {
LightListStruct tmpLight;
CopyInt(tbuff, &tmpLight._lx);
CopyInt(tbuff, &tmpLight._ly);
CopyInt(tbuff, &tmpLight._lradius);
CopyInt(tbuff, &tmpLight._lcolor);
staticLights[key].push_back(tmpLight);
}
}
mem_free_dbg(LoadBuff);
}
#endif
pfile_get_game_name(szName);
LoadBuff = pfile_read(szName, &dwLen);
tbuff = LoadBuff;
Expand Down Expand Up @@ -215,7 +241,7 @@ void CopyBytes(const void *src, const int n, void *dst)

void CopyChar(const void *src, void *dst)
{
*(char*)dst = *(char*)src;
*(char*)dst = *(char *)src;
tbuff += 1;
}

Expand Down Expand Up @@ -779,7 +805,7 @@ void LoadLighting(int i)
CopyInt(tbuff, &pLight->_lid);
CopyInt(tbuff, &pLight->_ldel);
CopyInt(tbuff, &pLight->_lunflag);
CopyInt(tbuff, &pLight->field_18);
CopyInt(tbuff, &pLight->_lcolor);
CopyInt(tbuff, &pLight->_lunx);
CopyInt(tbuff, &pLight->_luny);
CopyInt(tbuff, &pLight->_lunr);
Expand All @@ -798,7 +824,7 @@ void LoadVision(int i)
CopyInt(tbuff, &pVision->_lid);
CopyInt(tbuff, &pVision->_ldel);
CopyInt(tbuff, &pVision->_lunflag);
CopyInt(tbuff, &pVision->field_18);
CopyInt(tbuff, &pVision->_lcolor);
CopyInt(tbuff, &pVision->_lunx);
CopyInt(tbuff, &pVision->_luny);
CopyInt(tbuff, &pVision->_lunr);
Expand Down Expand Up @@ -957,6 +983,40 @@ void SaveGame()
dwLen = codec_get_encoded_len(tbuff - SaveBuff);
pfile_write_save_file(szName, SaveBuff, tbuff - SaveBuff, dwLen);
mem_free_dbg(SaveBuff);
#ifdef PIXEL_LIGHT
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems this could use restoring tbuff to previous value after custom saving/loading ends, it didn't corrupt saves in this case but when moved to a different place, it would

int staticSize = 1;
for (std::map<int, std::vector<LightListStruct>>::iterator it = staticLights.begin(); it != staticLights.end(); ++it) {
staticSize += it->second.size() * 4 + 2;
}
//1 for map size, 4 for every vector element, 2 per vector for key and vector size
staticSize *= 4;
dwLen = codec_get_encoded_len(staticSize);
SaveBuff = DiabloAllocPtr(dwLen);
tbuff = SaveBuff;
int num = staticLights.size();
CopyInt(&num, tbuff);

for (std::map<int, std::vector<LightListStruct>>::iterator it = staticLights.begin(); it != staticLights.end(); ++it) {
num = it->first;
CopyInt(&num, tbuff);
num = it->second.size();
CopyInt(&num, tbuff);
for (int j = 0; j < it->second.size(); j++) {
num = it->second[j]._lx;
CopyInt(&num, tbuff);
num = it->second[j]._ly;
CopyInt(&num, tbuff);
num = it->second[j]._lradius;
CopyInt(&num, tbuff);
num = it->second[j]._lcolor;
CopyInt(&num, tbuff);
}
}

dwLen = codec_get_encoded_len(tbuff - SaveBuff);
pfile_write_save_file("staticlights", SaveBuff, tbuff - SaveBuff, dwLen);
mem_free_dbg(SaveBuff);
#endif
gbValidSaveFile = TRUE;
pfile_rename_temp_to_perm();
pfile_write_hero();
Expand Down Expand Up @@ -1497,7 +1557,7 @@ void SaveLighting(int i)
CopyInt(&pLight->_lid, tbuff);
CopyInt(&pLight->_ldel, tbuff);
CopyInt(&pLight->_lunflag, tbuff);
CopyInt(&pLight->field_18, tbuff);
CopyInt(&pLight->_lcolor, tbuff);
CopyInt(&pLight->_lunx, tbuff);
CopyInt(&pLight->_luny, tbuff);
CopyInt(&pLight->_lunr, tbuff);
Expand All @@ -1516,7 +1576,7 @@ void SaveVision(int i)
CopyInt(&pVision->_lid, tbuff);
CopyInt(&pVision->_ldel, tbuff);
CopyInt(&pVision->_lunflag, tbuff);
CopyInt(&pVision->field_18, tbuff);
CopyInt(&pVision->_lcolor, tbuff);
CopyInt(&pVision->_lunx, tbuff);
CopyInt(&pVision->_luny, tbuff);
CopyInt(&pVision->_lunr, tbuff);
Expand Down
4 changes: 4 additions & 0 deletions Source/misdat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ MissileData missiledata[] = {
{ MIS_FLARE, &AddFlare, &MI_Firebolt, TRUE, 1, MISR_MAGIC, MFILE_FLARE, -1, -1 },
{ MIS_MISEXP2, &AddMisexp, &MI_Misexp, TRUE, 2, MISR_MAGIC, MFILE_FLAREEXP, -1, -1 },
{ MIS_TELEPORT, &AddTeleport, &MI_Teleport, FALSE, 1, 0, MFILE_NONE, LS_ELEMENTL, -1 },
#ifdef PIXEL_LIGHT
{ MIS_FARROW, &AddFArrow, &MI_LArrow, TRUE, 0, MISR_FIRE, MFILE_FARROW, -1, -1 },
#else
{ MIS_FARROW, &AddLArrow, &MI_LArrow, TRUE, 0, MISR_FIRE, MFILE_FARROW, -1, -1 },
#endif
{ MIS_DOOMSERP, NULL, NULL, FALSE, 1, MISR_MAGIC, MFILE_DOOM, LS_DSERP, -1 },
{ MIS_FIREWALLA, &miss_null_1D, &MI_Firewall, TRUE, 2, MISR_FIRE, MFILE_FIREWAL, -1, -1 },
{ MIS_STONE, &AddStone, &MI_Stone, FALSE, 1, MISR_MAGIC, MFILE_NONE, LS_SCURIMP, -1 },
Expand Down
Loading