- [FIX] Estava calculatn mal el nombre de LINEDEFS.

- [FIX] Si l'altura del sector es 0, ignorar este drawColumn().
- [FIX] Coordenades en Y invertides.
This commit is contained in:
2026-03-01 20:10:05 +01:00
parent 7c3c3eb088
commit 0ceeed7a6a

View File

@@ -41,7 +41,7 @@ std::vector<sector> sectors;
int current_sector = 38; int current_sector = 38;
int current_sector2 = 38; int current_sector2 = 38;
vec2 position = { 1056.0f, -3616.0f }; vec2 position = { 1056.0f, 3616.0f };
//vec2 position = {975.0f, -3525.0f}; //vec2 position = {975.0f, -3525.0f};
float orientation = 90.0f; //270.0f; float orientation = 90.0f; //270.0f;
//float orientation = 180.0f; //float orientation = 180.0f;
@@ -219,7 +219,7 @@ void loadMap(const char* name)
int16_t *vertices = (int16_t *)wad::load(name, "VERTEXES", &size); int16_t *vertices = (int16_t *)wad::load(name, "VERTEXES", &size);
const int num_vertices = size/4; const int num_vertices = size/4;
for (int i=0;i<num_vertices;++i) for (int i=0;i<num_vertices;++i)
verts.emplace_back(vec2{float(vertices[i*2]), float(vertices[i*2+1])}); verts.emplace_back(vec2{float(vertices[i*2]), -float(vertices[i*2+1])});
free(vertices); free(vertices);
uint8_t *sectors_lump = wad::load(name, "SECTORS", &size); uint8_t *sectors_lump = wad::load(name, "SECTORS", &size);
@@ -245,7 +245,7 @@ void loadMap(const char* name)
uint8_t *linedefs_lump = wad::load(name, "LINEDEFS", &size); uint8_t *linedefs_lump = wad::load(name, "LINEDEFS", &size);
uint16_t *l = (uint16_t *)linedefs_lump; uint16_t *l = (uint16_t *)linedefs_lump;
size /= 28; size /= 14;
for (int i=0; i<size; ++i) { for (int i=0; i<size; ++i) {
const int16_t v1 = *(l++); const int16_t v1 = *(l++);
const int16_t v2 = *(l++); const int16_t v2 = *(l++);
@@ -257,7 +257,7 @@ void loadMap(const char* name)
if (ld1 != -1) { if (ld1 != -1) {
wall w; wall w;
w.v1 = v2; w.v2 = v1; w.v1 = v1; w.v2 = v2;
w.portal = portal ? arr[ld2].sector : -1; w.portal = portal ? arr[ld2].sector : -1;
char txt[9]; txt[8]=0; char txt[9]; txt[8]=0;
for (int i=0;i<8;++i) txt[i] = toupper(arr[ld1].middle_texture[i]); for (int i=0;i<8;++i) txt[i] = toupper(arr[ld1].middle_texture[i]);
@@ -270,7 +270,7 @@ void loadMap(const char* name)
} }
if (ld2 != -1) { if (ld2 != -1) {
wall w; wall w;
w.v1 = v1; w.v2 = v2; w.v1 = v2; w.v2 = v1;
w.portal = portal ? arr[ld1].sector : -1; w.portal = portal ? arr[ld1].sector : -1;
char txt[9]; txt[8]=0; char txt[9]; txt[8]=0;
for (int i=0;i<8;++i) txt[i] = toupper(arr[ld2].middle_texture[i]); for (int i=0;i<8;++i) txt[i] = toupper(arr[ld2].middle_texture[i]);
@@ -407,6 +407,7 @@ void drawColumn(sector &s, int screen_column, int start, int end, float a_inc, v
{ {
//const int tex_height = gif->h; //64; //const int tex_height = gif->h; //64;
const float sector_height = s.ceiling_height - s.floor_height; const float sector_height = s.ceiling_height - s.floor_height;
if (sector_height == 0) return;
const int width = w->surf ? w->surf->w : w->upper_surf ? w->upper_surf->w : w->lower_surf ? w->lower_surf->w : 64; const int width = w->surf ? w->surf->w : w->upper_surf ? w->upper_surf->w : w->lower_surf ? w->lower_surf->w : 64;
draw::map::putp(result.x, result.y, 6); draw::map::putp(result.x, result.y, 6);
@@ -731,7 +732,7 @@ int main(int argc, char *argv[])
{ {
//if (sec==current_sector2) //if (sec==current_sector2)
for (auto &w : s.walls) { for (auto &w : s.walls) {
if (dot(normal, w.normal) >= 0) continue; //if (dot(normal, w.normal) >= 0) continue;
draw::map::line(verts[w.v1].x, verts[w.v1].y, verts[w.v2].x, verts[w.v2].y, sec==current_sector?20:4, position.x, position.y); draw::map::line(verts[w.v1].x, verts[w.v1].y, verts[w.v2].x, verts[w.v2].y, sec==current_sector?20:4, position.x, position.y);
vec2 nx {(verts[w.v2].x+verts[w.v1].x)/2, (verts[w.v2].y+verts[w.v1].y)/2}; vec2 nx {(verts[w.v2].x+verts[w.v1].x)/2, (verts[w.v2].y+verts[w.v1].y)/2};
draw::map::line(nx.x, nx.y, nx.x+w.normal.x*20, nx.y+w.normal.y*20, sec==current_sector?22:3, position.x, position.y); draw::map::line(nx.x, nx.y, nx.x+w.normal.x*20, nx.y+w.normal.y*20, sec==current_sector?22:3, position.x, position.y);