Updated rcheevos to 7.0.1

This commit is contained in:
Andre Leiradella 2018-09-27 21:45:50 +01:00
parent ad992d227b
commit 793205e457
11 changed files with 22 additions and 25 deletions

View File

@ -7,14 +7,6 @@ extern "C" {
typedef struct lua_State lua_State;
/*****************************************************************************\
| User configuration |
\*****************************************************************************/
#ifndef RC_ALIGNMENT
#define RC_ALIGNMENT sizeof(void*)
#endif
/*****************************************************************************\
| Return values |
\*****************************************************************************/

View File

@ -1,9 +1,9 @@
#include "internal.h"
void* rc_alloc(void* pointer, int* offset, int size, rc_scratch_t* scratch) {
void* rc_alloc(void* pointer, int* offset, int size, int alignment, rc_scratch_t* scratch) {
void* ptr;
*offset = (*offset + RC_ALIGNMENT - 1) & -RC_ALIGNMENT;
*offset = (*offset + alignment - 1) & ~(alignment - 1);
if (pointer != 0) {
ptr = (void*)((char*)pointer + *offset);

View File

@ -8,7 +8,7 @@ rc_condition_t* rc_parse_condition(int* ret, void* buffer, rc_scratch_t* scratch
int ret2;
aux = *memaddr;
self = (rc_condition_t*)rc_alloc(buffer, ret, sizeof(rc_condition_t), scratch);
self = RC_ALLOC(rc_condition_t, buffer, ret, scratch);
self->current_hits = 0;
if (*aux != 0 && aux[1] == ':') {

View File

@ -27,7 +27,7 @@ rc_condset_t* rc_parse_condset(int* ret, void* buffer, rc_scratch_t* scratch, co
rc_condition_t** next;
int in_pause;
self = (rc_condset_t*)rc_alloc(buffer, ret, sizeof(rc_condset_t), scratch);
self = RC_ALLOC(rc_condset_t, buffer, ret, scratch);
self->has_pause = 0;
next = &self->conditions;

View File

@ -4,7 +4,7 @@ rc_expression_t* rc_parse_expression(int* ret, void* buffer, rc_scratch_t* scrat
rc_expression_t* self;
rc_term_t** next;
self = (rc_expression_t*)rc_alloc(buffer, ret, sizeof(rc_expression_t), scratch);
self = RC_ALLOC(rc_expression_t, buffer, ret, scratch);
next = &self->terms;
for (;;) {

View File

@ -3,6 +3,11 @@
#include "rcheevos.h"
#define RC_OFFSETOF(s, f) ((int)(long long)(&((s*)0)->f))
#define RC_ALIGNOF(t) RC_OFFSETOF(struct{char c; t d;}, d)
#define RC_ALLOC(t, p, o, s) ((t*)rc_alloc(p, o, sizeof(t), RC_ALIGNOF(t), s))
typedef union {
rc_operand_t operand;
rc_condition_t condition;
@ -14,7 +19,7 @@ typedef union {
}
rc_scratch_t;
void* rc_alloc(void* pointer, int* offset, int size, rc_scratch_t* scratch);
void* rc_alloc(void* pointer, int* offset, int size, int alignment, rc_scratch_t* scratch);
void rc_parse_trigger_internal(rc_trigger_t* self, int* ret, void* buffer, rc_scratch_t* scratch, const char** memaddr, lua_State* L, int funcs_ndx);

View File

@ -92,7 +92,7 @@ void rc_parse_lboard_internal(rc_lboard_t* self, int* ret, void* buffer, void* s
found |= RC_LBOARD_PROGRESS;
memaddr += 4;
self->progress = (rc_value_t*)rc_alloc(buffer, ret, sizeof(rc_value_t), scratch);
self->progress = RC_ALLOC(rc_value_t, buffer, ret, scratch);
rc_parse_value_internal(self->progress, ret, buffer, scratch, &memaddr, L, funcs_ndx);
if (*ret < 0) {
@ -137,7 +137,7 @@ int rc_lboard_size(const char* memaddr) {
rc_scratch_t scratch;
ret = 0;
self = (rc_lboard_t*)rc_alloc(0, &ret, sizeof(rc_lboard_t), &scratch);
self = RC_ALLOC(rc_lboard_t, 0, &ret, &scratch);
rc_parse_lboard_internal(self, &ret, 0, &scratch, memaddr, 0, 0);
return ret;
}
@ -148,7 +148,7 @@ rc_lboard_t* rc_parse_lboard(void* buffer, const char* memaddr, lua_State* L, in
rc_scratch_t scratch;
ret = 0;
self = (rc_lboard_t*)rc_alloc(buffer, &ret, sizeof(rc_lboard_t), &scratch);
self = RC_ALLOC(rc_lboard_t, buffer, &ret, &scratch);
rc_parse_lboard_internal(self, &ret, buffer, 0, memaddr, L, funcs_ndx);
return ret >= 0 ? self : 0;
}

View File

@ -295,8 +295,8 @@ typedef struct {
rc_luapeek_t;
static int rc_luapeek(lua_State* L) {
unsigned address = luaL_checkinteger(L, 1);
unsigned num_bytes = luaL_checkinteger(L, 2);
unsigned address = (unsigned)luaL_checkinteger(L, 1);
unsigned num_bytes = (unsigned)luaL_checkinteger(L, 2);
rc_luapeek_t* luapeek = (rc_luapeek_t*)lua_touserdata(L, 3);
unsigned value = luapeek->peek(address, num_bytes, luapeek->ud);

View File

@ -6,7 +6,7 @@ rc_term_t* rc_parse_term(int* ret, void* buffer, rc_scratch_t* scratch, const ch
int ret2;
aux = *memaddr;
self = (rc_term_t*)rc_alloc(buffer, ret, sizeof(rc_term_t), scratch);
self = RC_ALLOC(rc_term_t, buffer, ret, scratch);
self->invert = 0;
ret2 = rc_parse_operand(&self->operand1, &aux, 0, L, funcs_ndx);
@ -84,5 +84,5 @@ unsigned rc_evaluate_term(rc_term_t* self, rc_peek_t peek, void* ud, lua_State*
return value * (rc_evaluate_operand(&self->operand2, peek, ud, L) ^ self->invert);
}
return value * self->operand2.fp_value;
return (unsigned)(value * self->operand2.fp_value);
}

View File

@ -41,7 +41,7 @@ int rc_trigger_size(const char* memaddr) {
rc_scratch_t scratch;
ret = 0;
self = (rc_trigger_t*)rc_alloc(0, &ret, sizeof(rc_trigger_t), &scratch);
self = RC_ALLOC(rc_trigger_t, 0, &ret, &scratch);
rc_parse_trigger_internal(self, &ret, 0, &scratch, &memaddr, 0, 0);
return ret;
}
@ -52,7 +52,7 @@ rc_trigger_t* rc_parse_trigger(void* buffer, const char* memaddr, lua_State* L,
rc_scratch_t scratch;
ret = 0;
self = (rc_trigger_t*)rc_alloc(buffer, &ret, sizeof(rc_trigger_t), &scratch);
self = RC_ALLOC(rc_trigger_t, buffer, &ret, &scratch);
rc_parse_trigger_internal(self, &ret, buffer, 0, &memaddr, L, funcs_ndx);
return ret >= 0 ? self : 0;
}

View File

@ -30,7 +30,7 @@ int rc_value_size(const char* memaddr) {
rc_scratch_t scratch;
ret = 0;
self = (rc_value_t*)rc_alloc(0, &ret, sizeof(rc_value_t), &scratch);
self = RC_ALLOC(rc_value_t, 0, &ret, &scratch);
rc_parse_value_internal(self, &ret, 0, &scratch, &memaddr, 0, 0);
return ret;
}
@ -41,7 +41,7 @@ rc_value_t* rc_parse_value(void* buffer, const char* memaddr, lua_State* L, int
rc_scratch_t scratch;
ret = 0;
self = (rc_value_t*)rc_alloc(buffer, &ret, sizeof(rc_value_t), &scratch);
self = RC_ALLOC(rc_value_t, buffer, &ret, &scratch);
rc_parse_value_internal(self, &ret, buffer, 0, &memaddr, L, funcs_ndx);
return ret >= 0 ? self : 0;
}