mirror of
https://github.com/thepigeongenerator/mcaselector-lite
synced 2026-02-07 23:28:09 +01:00
Migrate from i* signed integer type definitions to s* integer definitions.
The `s*` format is preferred due to it being
This commit is contained in:
@@ -28,12 +28,12 @@ enum mcx_compression {
|
||||
MCX_COMPRESSION_CUSTOM = 0x7F,
|
||||
};
|
||||
|
||||
/* first 4 bytes is an i32 indicating remaining bytes, the following byte defines the compression scheme */
|
||||
static int mcx_loadchunk(const u8 *restrict buf, const i32 *restrict table, int idx)
|
||||
/* first 4 bytes is an s32 indicating remaining bytes, the following byte defines the compression scheme */
|
||||
static int mcx_loadchunk(const u8 *restrict buf, const s32 *restrict table, int idx)
|
||||
{
|
||||
const u8 *chunk = buf + (be32toh(table[idx]) >> 8) * SECTOR;
|
||||
|
||||
i32 len;
|
||||
s32 len;
|
||||
memcpy(&len, chunk, 4);
|
||||
len = be32toh(len);
|
||||
chunk += 4;
|
||||
|
||||
@@ -42,7 +42,7 @@ static inline u64 buftoh64(const void *restrict buf)
|
||||
/* Processes the incoming array data in `buf`. Which contains `nmem` items of `size`.
|
||||
* The data shall be converted to little-endian on little-endian systems
|
||||
* Outputs the allocated data to `out`, returns where the next pointer would be. */
|
||||
static const u8 *procarr(const u8 *restrict buf, i32 nmemb, uint size, struct nbt_array *restrict out)
|
||||
static const u8 *procarr(const u8 *restrict buf, s32 nmemb, uint size, struct nbt_array *restrict out)
|
||||
{
|
||||
usize len = nmemb * size;
|
||||
*out = (struct nbt_array){
|
||||
@@ -60,7 +60,7 @@ static const u8 *procarr(const u8 *restrict buf, i32 nmemb, uint size, struct nb
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
if (size == 1)
|
||||
return buf;
|
||||
i32 i = 0;
|
||||
s32 i = 0;
|
||||
while (i < nmemb) {
|
||||
switch (size) {
|
||||
case 2: ((u16 *)out->dat)[i] = be16toh(((u16 *)out->dat)[i]); break;
|
||||
@@ -90,7 +90,7 @@ static const u8 *proclist(const u8 *restrict buf, struct nbt_array *restrict out
|
||||
}
|
||||
|
||||
buf++;
|
||||
i32 len;
|
||||
s32 len;
|
||||
memcpy(&len, buf, 4);
|
||||
len = be32toh(len);
|
||||
buf += 4;
|
||||
@@ -102,7 +102,7 @@ const u8 *nbt_proctag(const u8 *restrict buf, u16 slen, void *restrict out)
|
||||
const u8 *ptr, *tmp;
|
||||
ptr = buf + 3 + slen;
|
||||
|
||||
i32 nmem;
|
||||
s32 nmem;
|
||||
uint size;
|
||||
|
||||
switch (*buf) {
|
||||
@@ -133,23 +133,23 @@ const u8 *nbt_proctag(const u8 *restrict buf, u16 slen, void *restrict out)
|
||||
* `ptr` is assumed to be the start of the `NBT_LIST` data, e.i. The list's ID, followed by the list's length.
|
||||
* If `ID` is `NBT_I8`, `NBT_I16`, `NBT_I32`, `NBT_I64`, `NBT_F32`, or `NBT_F64`, the entire list length is computed and returned.
|
||||
* For other types this won't be possible, and thus will add `1` to `dpt`, and write the list data to `lens` and `tags` at this new `dpt`. */
|
||||
static const u8 *nexttag_list(const u8 *restrict ptr, uint *restrict const dpt, i32 *restrict const lens, u8 *restrict const tags)
|
||||
static const u8 *nexttag_list(const u8 *restrict ptr, uint *restrict const dpt, s32 *restrict const lens, u8 *restrict const tags)
|
||||
{
|
||||
const u8 *tag = ptr;
|
||||
ptr++;
|
||||
switch (*tag) {
|
||||
case NBT_END: break;
|
||||
case NBT_I8: ptr += (i32)buftoh32(ptr) * 1; break;
|
||||
case NBT_I16: ptr += (i32)buftoh32(ptr) * 2; break;
|
||||
case NBT_I8: ptr += (s32)buftoh32(ptr) * 1; break;
|
||||
case NBT_I16: ptr += (s32)buftoh32(ptr) * 2; break;
|
||||
case NBT_I32: // fall through
|
||||
case NBT_F32: ptr += (i32)buftoh32(ptr) * 4; break;
|
||||
case NBT_F32: ptr += (s32)buftoh32(ptr) * 4; break;
|
||||
case NBT_I64: // fall through
|
||||
case NBT_F64: ptr += (i32)buftoh32(ptr) * 8; break;
|
||||
case NBT_F64: ptr += (s32)buftoh32(ptr) * 8; break;
|
||||
default:
|
||||
// TODO: handle out of bounds... Might not be required if we use flexible array member
|
||||
(*dpt)++;
|
||||
tags[*dpt] = *tag;
|
||||
lens[*dpt] = (i32)buftoh32(ptr);
|
||||
lens[*dpt] = (s32)buftoh32(ptr);
|
||||
break;
|
||||
}
|
||||
ptr += 4;
|
||||
@@ -162,7 +162,7 @@ static const u8 *nexttag_list(const u8 *restrict ptr, uint *restrict const dpt,
|
||||
* - `lens` shall contain `MAX_DEPTH` of items representing the list length, if the current item is non-zero we shall assume we're in a list.
|
||||
* Where the value is decremented until we reach `0`.
|
||||
* - `tags` shall contain `MAX_DEPTH` of items representing the list's stored type. */
|
||||
static const u8 *nexttag(const u8 *restrict tag, uint *restrict const dpt, i32 *restrict const lens, u8 *restrict const tags)
|
||||
static const u8 *nexttag(const u8 *restrict tag, uint *restrict const dpt, s32 *restrict const lens, u8 *restrict const tags)
|
||||
{
|
||||
u8 type;
|
||||
const u8 *ptr = tag;
|
||||
@@ -183,9 +183,9 @@ static const u8 *nexttag(const u8 *restrict tag, uint *restrict const dpt, i32 *
|
||||
case NBT_I64: // fall through
|
||||
case NBT_F64: ptr += 8; break;
|
||||
|
||||
case NBT_ARR_I8: ptr += 4 + (i32)buftoh32(ptr) * 1; break;
|
||||
case NBT_ARR_I32: ptr += 4 + (i32)buftoh32(ptr) * 4; break;
|
||||
case NBT_ARR_I64: ptr += 4 + (i32)buftoh32(ptr) * 8; break;
|
||||
case NBT_ARR_I8: ptr += 4 + (s32)buftoh32(ptr) * 1; break;
|
||||
case NBT_ARR_I32: ptr += 4 + (s32)buftoh32(ptr) * 4; break;
|
||||
case NBT_ARR_I64: ptr += 4 + (s32)buftoh32(ptr) * 8; break;
|
||||
case NBT_STR: ptr += 2 + (u16)buftoh16(ptr) * 1; break;
|
||||
|
||||
case NBT_END: (*dpt)--; break;
|
||||
@@ -209,7 +209,7 @@ const u8 *nbt_nexttag(const u8 *restrict buf)
|
||||
{
|
||||
const u8 *tag;
|
||||
u8 tags[MAX_DEPTH] = {0};
|
||||
i32 lens[MAX_DEPTH] = {0};
|
||||
s32 lens[MAX_DEPTH] = {0};
|
||||
uint dpt = 0;
|
||||
|
||||
tag = buf;
|
||||
|
||||
@@ -40,7 +40,7 @@ enum nbt_tagid {
|
||||
};
|
||||
|
||||
struct nbt_array {
|
||||
i32 nmemb;
|
||||
s32 nmemb;
|
||||
void *dat;
|
||||
};
|
||||
|
||||
|
||||
@@ -48,10 +48,10 @@ int conf_procval(u8 type, const char *val, void *out)
|
||||
switch (type) {
|
||||
case CONF_STR: *(char **)out = strdup(val); return 0;
|
||||
|
||||
case CONF_I8: *(i8 *)out = strtoimax(val, &end, 0); return (end && !*end);
|
||||
case CONF_I16: *(i16 *)out = strtoimax(val, &end, 0); return (end && !*end);
|
||||
case CONF_I32: *(i32 *)out = strtoimax(val, &end, 0); return (end && !*end);
|
||||
case CONF_I64: *(i64 *)out = strtoimax(val, &end, 0); return (end && !*end);
|
||||
case CONF_I8: *(s8 *)out = strtoimax(val, &end, 0); return (end && !*end);
|
||||
case CONF_I16: *(s16 *)out = strtoimax(val, &end, 0); return (end && !*end);
|
||||
case CONF_I32: *(s32 *)out = strtoimax(val, &end, 0); return (end && !*end);
|
||||
case CONF_I64: *(s64 *)out = strtoimax(val, &end, 0); return (end && !*end);
|
||||
|
||||
case CONF_U8: *(u8 *)out = strtoumax(val, &end, 0); return (end && !*end);
|
||||
case CONF_U16: *(u16 *)out = strtoumax(val, &end, 0); return (end && !*end);
|
||||
|
||||
@@ -22,7 +22,7 @@ static int win_w, win_h;
|
||||
|
||||
static void screen_resize(int w, int h)
|
||||
{
|
||||
i32 verts[VERTC][4] = {
|
||||
s32 verts[VERTC][4] = {
|
||||
{0, 0, w, 20 },
|
||||
{0, 20, w, h - 40},
|
||||
{0, h, w, -20 },
|
||||
@@ -62,7 +62,7 @@ int render_init(void)
|
||||
// set VBO info
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
glEnableVertexAttribArray(0); // set the array data index to 0
|
||||
glVertexAttribIPointer(0, 4, GL_INT, 4 * sizeof(i32), NULL);
|
||||
glVertexAttribIPointer(0, 4, GL_INT, 4 * sizeof(s32), NULL);
|
||||
|
||||
glBindVertexArray(0);
|
||||
return 0;
|
||||
|
||||
@@ -10,10 +10,10 @@ typedef unsigned short int ushort;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned long ulong;
|
||||
typedef unsigned long long ullong;
|
||||
typedef __INT8_TYPE__ i8;
|
||||
typedef __INT16_TYPE__ i16;
|
||||
typedef __INT32_TYPE__ i32;
|
||||
typedef __INT64_TYPE__ i64;
|
||||
typedef __INT8_TYPE__ s8;
|
||||
typedef __INT16_TYPE__ s16;
|
||||
typedef __INT32_TYPE__ s32;
|
||||
typedef __INT64_TYPE__ s64;
|
||||
typedef __UINT8_TYPE__ u8;
|
||||
typedef __UINT16_TYPE__ u16;
|
||||
typedef __UINT32_TYPE__ u32;
|
||||
|
||||
Reference in New Issue
Block a user