Skip to content

Commit

Permalink
Remove use of <array>
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Jun 6, 2024
1 parent b8d0479 commit 35248eb
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 88 deletions.
32 changes: 16 additions & 16 deletions source_files/obsidian_main/aj_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ void ParseSectorField(sector_c *sector, const std::string& key, ajparse::token_k
else if (key == "texturefloor")
{
std::copy(value.data(), value.data() + MIN(8, value.size()),
sector->floor_tex.data());
sector->floor_tex);
}
else if (key == "textureceiling")
{
std::copy(value.data(), value.data() + MIN(8, value.size()),
sector->ceil_tex.data());
sector->ceil_tex);
}
else if (key == "lightlevel")
{
Expand Down Expand Up @@ -268,17 +268,17 @@ void ParseSidedefField(sidedef_c *side, const std::string& key, ajparse::token_k
else if (key == "texturetop")
{
std::copy(value.data(), value.data() + MIN(8, value.size()),
side->upper_tex.data());
side->upper_tex);
}
else if (key == "texturebottom")
{
std::copy(value.data(), value.data() + MIN(8, value.size()),
side->lower_tex.data());
side->lower_tex);
}
else if (key == "texturemiddle")
{
std::copy(value.data(), value.data() + MIN(8, value.size()),
side->mid_tex.data());
side->mid_tex);
}
else if (key == "sector")
{
Expand Down Expand Up @@ -767,10 +767,10 @@ bool LoadSectors() {
sector->floor_h = LE_S16(raw->floor_h);
sector->ceil_h = LE_S16(raw->ceil_h);

std::copy(raw->floor_tex.data(), raw->floor_tex.data() + 8,
sector->floor_tex.data());
std::copy(raw->ceil_tex.data(), raw->ceil_tex.data() + 8,
sector->ceil_tex.data());
std::copy(raw->floor_tex, raw->floor_tex + 8,
sector->floor_tex);
std::copy(raw->ceil_tex, raw->ceil_tex + 8,
sector->ceil_tex);

sector->light = LE_U16(raw->light);
sector->special = LE_U16(raw->special);
Expand Down Expand Up @@ -850,7 +850,7 @@ bool LoadThingsHexen() {

thing->special = LE_U16(raw->special);

thing->args = raw->arg;
memcpy(thing->args, raw->arg, 5);
}

return true; // OK
Expand Down Expand Up @@ -887,12 +887,12 @@ bool LoadSidedefs() {
side->x_offset = LE_S16(raw->x_offset);
side->y_offset = LE_S16(raw->y_offset);

std::copy(raw->upper_tex.data(), raw->upper_tex.data() + 8,
side->upper_tex.data());
std::copy(raw->mid_tex.data(), raw->mid_tex.data() + 8,
side->mid_tex.data());
std::copy(raw->lower_tex.data(), raw->lower_tex.data() + 8,
side->lower_tex.data());
std::copy(raw->upper_tex, raw->upper_tex + 8,
side->upper_tex);
std::copy(raw->mid_tex, raw->mid_tex + 8,
side->mid_tex);
std::copy(raw->lower_tex, raw->lower_tex + 8,
side->lower_tex);
}

return true; // OK
Expand Down
6 changes: 3 additions & 3 deletions source_files/obsidian_main/aj_poly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ static constexpr std::size_t EDGE_BUFFER_SIZE = 32;
void polygon_c::ClockwiseOrder() {
edge_c *cur;
edge_c **array;
std::array<edge_c *, EDGE_BUFFER_SIZE> edge_buffer;
edge_c *edge_buffer[EDGE_BUFFER_SIZE];

int i;
int total = 0;
Expand All @@ -726,7 +726,7 @@ void polygon_c::ClockwiseOrder() {

// use local array if small enough
if (total <= EDGE_BUFFER_SIZE) {
array = edge_buffer.data();
array = edge_buffer;
} else {
array = new edge_c *[total];
}
Expand Down Expand Up @@ -986,7 +986,7 @@ void CreateOuterEdges() {
limit_x2 += 64;
limit_y2 += 64;

std::array<vertex_c *, 4> v;
vertex_c *v[4];

v[0] = NewSplit();
v[0]->x = limit_x1;
Expand Down
15 changes: 7 additions & 8 deletions source_files/obsidian_main/aj_poly.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <stdint.h>
#include <cstring>
#include <string>
#include <array>
#include <unordered_map>
void Appl_FatalError(const char *str, ...);
void Appl_Printf(const char *str, ...);
Expand Down Expand Up @@ -70,8 +69,8 @@ class sector_c {
int floor_h, ceil_h;

// textures
std::array<char, 10> floor_tex;
std::array<char, 10> ceil_tex;
char floor_tex[10];
char ceil_tex[10];

// attributes
int light;
Expand Down Expand Up @@ -121,9 +120,9 @@ class sidedef_c {
int x_offset, y_offset;

// texture names
std::array<char, 10> upper_tex;
std::array<char, 10> lower_tex;
std::array<char, 10> mid_tex;
char upper_tex[10];
char lower_tex[10];
char mid_tex[10];

// UDMF support
std::unordered_map<std::string, std::string> misc_vals;
Expand Down Expand Up @@ -156,7 +155,7 @@ class linedef_c {
int tag;

// Hexen support
std::array<uint8_t, 5> args;
uint8_t args[5];

// UDMF support
std::unordered_map<std::string, std::string> misc_vals;
Expand Down Expand Up @@ -188,7 +187,7 @@ class thing_c {
int tid;
int height;
int special;
std::array<uint8_t, 5> args;
uint8_t args[5];

// UDMF support
std::unordered_map<std::string, std::string> misc_vals;
Expand Down
18 changes: 8 additions & 10 deletions source_files/obsidian_main/aj_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#ifndef __AJPOLY_STRUCTS_H__
#define __AJPOLY_STRUCTS_H__

#include <array>

#ifdef __GNUC__
#define PACKEDATTR __attribute__((packed))
#else
Expand All @@ -39,7 +37,7 @@ typedef struct {
uint32_t start;
uint32_t length;

std::array<char, 8> name;
char name[8];

} PACKEDATTR raw_wad_entry_t;

Expand All @@ -64,7 +62,7 @@ typedef struct {
uint16_t end; // ... to this vertex
uint16_t flags; // linedef flags (impassible, etc)
uint8_t type; // linedef type
std::array<uint8_t, 5> specials; // hexen specials
uint8_t specials[5]; // hexen specials
uint16_t sidedef1; // right sidedef
uint16_t sidedef2; // left sidedef

Expand All @@ -74,9 +72,9 @@ typedef struct {
int16_t x_offset; // X offset for texture
int16_t y_offset; // Y offset for texture

std::array<char, 8> upper_tex; // texture name for the part above
std::array<char, 8> lower_tex; // texture name for the part below
std::array<char, 8> mid_tex; // texture name for the regular part
char upper_tex[8]; // texture name for the part above
char lower_tex[8]; // texture name for the part below
char mid_tex[8]; // texture name for the regular part

uint16_t sector; // adjacent sector

Expand All @@ -86,8 +84,8 @@ typedef struct {
int16_t floor_h; // floor height
int16_t ceil_h; // ceiling height

std::array<char, 8> floor_tex; // floor texture
std::array<char, 8> ceil_tex; // ceiling texture
char floor_tex[8]; // floor texture
char ceil_tex[8]; // ceiling texture

uint16_t light; // light level (0-255)
uint16_t special; // special behaviour (0 = normal, 9 = secret, ...)
Expand All @@ -112,7 +110,7 @@ typedef struct {
uint16_t options; // when appears, deaf, dormant, etc..

uint8_t special; // special type
std::array<uint8_t, 5> arg; // special arguments
uint8_t arg[5]; // special arguments

} PACKEDATTR raw_hexen_thing_t;

Expand Down
2 changes: 1 addition & 1 deletion source_files/obsidian_main/aj_wad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ bool wad_c::ReadDirEntry() {
// ensure name gets NUL terminated
char name_buf[10];
memset(name_buf, 0, sizeof(name_buf));
memcpy(name_buf, entry.name.data(), 8);
memcpy(name_buf, entry.name, 8);

lump_c *lump = new lump_c(name_buf, start, length);

Expand Down
10 changes: 5 additions & 5 deletions source_files/obsidian_main/csg_doom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class vertex_c {
// keep track of a few (but not all) linedefs touching this vertex.
// this is used to detect colinear lines which can be merged. and
// also for horizontal texture alignment.
std::array<linedef_c *, 4> lines;
linedef_c *lines[4];

// was the vertex created by corner rounding code, and it split an
// existing linedef in half?
Expand Down Expand Up @@ -389,7 +389,7 @@ class linedef_c {
int special;
int tag;

std::array<uint8_t, 5> args;
uint8_t args[5];

double length;

Expand Down Expand Up @@ -1492,9 +1492,9 @@ static void MakeLine(region_c *R, snag_c *S) {
L->tag = L_tag;

if (use_trig) {
trig->getHexenArgs(L->args.data());
trig->getHexenArgs(L->args);
} else if (spec) {
spec->getHexenArgs(L->args.data());
spec->getHexenArgs(L->args);
}

// flags...
Expand Down Expand Up @@ -2578,7 +2578,7 @@ void Doom::linedef_c::Write() {

int f = front ? front->Write() : -1;
int b = back ? back->Write() : -1;
AddLinedef(v1, v2, f, b, special, flags, tag, args.data());
AddLinedef(v1, v2, f, b, special, flags, tag, args);
}

namespace Doom {
Expand Down
16 changes: 8 additions & 8 deletions source_files/obsidian_main/dm_prefab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ int wadfab_get_sector(lua_State *L) {
lua_setfield(L, -2, "tag");
}

lua_pushstring(L, SEC->floor_tex.data());
lua_pushstring(L, SEC->floor_tex);
lua_setfield(L, -2, "floor_tex");

lua_pushstring(L, SEC->ceil_tex.data());
lua_pushstring(L, SEC->ceil_tex);
lua_setfield(L, -2, "ceil_tex");

return 1;
Expand Down Expand Up @@ -304,13 +304,13 @@ int wadfab_get_side(lua_State *L) {
lua_setfield(L, -2, "sector");
}

lua_pushstring(L, SD->upper_tex.data());
lua_pushstring(L, SD->upper_tex);
lua_setfield(L, -2, "upper_tex");

lua_pushstring(L, SD->lower_tex.data());
lua_pushstring(L, SD->lower_tex);
lua_setfield(L, -2, "lower_tex");

lua_pushstring(L, SD->mid_tex.data());
lua_pushstring(L, SD->mid_tex);
lua_setfield(L, -2, "mid_tex");

lua_pushinteger(L, index);
Expand Down Expand Up @@ -546,18 +546,18 @@ int wadfab_get_3d_floor(lua_State *L) {
lua_pushinteger(L, SEC->floor_h);
lua_setfield(L, -2, "bottom_h");

lua_pushstring(L, SEC->floor_tex.data());
lua_pushstring(L, SEC->floor_tex);
lua_setfield(L, -2, "bottom_tex");

// TOP
lua_pushinteger(L, SEC->ceil_h);
lua_setfield(L, -2, "top_h");

lua_pushstring(L, SEC->ceil_tex.data());
lua_pushstring(L, SEC->ceil_tex);
lua_setfield(L, -2, "top_tex");

// SIDE
lua_pushstring(L, LD->right->mid_tex.data());
lua_pushstring(L, LD->right->mid_tex);
lua_setfield(L, -2, "side_tex");

lua_pushinteger(L, LD->right->x_offset);
Expand Down
20 changes: 10 additions & 10 deletions source_files/obsidian_main/g_doom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static const char *section_markers[NUM_SECTIONS][2] = {

// Empty script numbers matching Korax requirements to prevent errors being
// thrown
std::array<uint8_t, 128> empty_korax_behavior = {
static constexpr uint8_t empty_korax_behavior[128] = {
0x41, 0x43, 0x53, 0x00, 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
Expand Down Expand Up @@ -408,15 +408,15 @@ static void WriteBehavior() {
/*raw_behavior_header_t behavior;
std::string_view acs{"ACS"};
std::copy(acs.data(), acs.data() + 4, behavior.marker.data());
std::copy(acs.data(), acs.data() + 4, behavior.marker);
behavior.offset = LE_U32(8);
behavior.func_num = 0;
behavior.str_num = 0;
WriteLump("BEHAVIOR", &behavior, sizeof(behavior));*/

WriteLump("BEHAVIOR", empty_korax_behavior.data(), 128);
WriteLump("BEHAVIOR", empty_korax_behavior, 128);
}

static void ClearSections() {
Expand Down Expand Up @@ -683,8 +683,8 @@ void Doom::AddSector(int f_h, std::string f_tex, int c_h, std::string c_tex,
sec.floor_h = LE_S16(f_h);
sec.ceil_h = LE_S16(c_h);

std::copy(f_tex.data(), f_tex.data() + 8, sec.floor_tex.data());
std::copy(c_tex.data(), c_tex.data() + 8, sec.ceil_tex.data());
std::copy(f_tex.data(), f_tex.data() + 8, sec.floor_tex);
std::copy(c_tex.data(), c_tex.data() + 8, sec.ceil_tex);

sec.light = LE_U16(light);
sec.special = LE_U16(special);
Expand Down Expand Up @@ -723,9 +723,9 @@ void Doom::AddSidedef(int sector, std::string l_tex, std::string m_tex,

side.sector = LE_S16(sector);

std::copy(l_tex.data(), l_tex.data() + 8, side.lower_tex.data());
std::copy(m_tex.data(), m_tex.data() + 8, side.mid_tex.data());
std::copy(u_tex.data(), u_tex.data() + 8, side.upper_tex.data());
std::copy(l_tex.data(), l_tex.data() + 8, side.lower_tex);
std::copy(m_tex.data(), m_tex.data() + 8, side.mid_tex);
std::copy(u_tex.data(), u_tex.data() + 8, side.upper_tex);

side.x_offset = LE_S16(x_offset);
side.y_offset = LE_S16(y_offset);
Expand Down Expand Up @@ -833,7 +833,7 @@ void Doom::AddLinedef(int vert1, int vert2, int side1, int side2, int type,
// tag value is UNUSED

if (args) {
std::copy(args, args + 5, line.args.data());
std::copy(args, args + 5, line.args);
}

linedef_lump->Append(&line, sizeof(line));
Expand Down Expand Up @@ -1045,7 +1045,7 @@ void Doom::AddThing(int x, int y, int h, int type, int angle, int options,
thing.special = special;

if (args) {
std::copy(args, args + 5, thing.args.data());
std::copy(args, args + 5, thing.args);
}

thing_lump->Append(&thing, sizeof(thing));
Expand Down
Loading

0 comments on commit 35248eb

Please sign in to comment.