mirror of
https://github.com/libretro/RetroArch
synced 2025-01-31 15:32:59 +00:00
Merge pull request #8610 from meleu/runtime_rcheevos_switch_c89
C89/CXX support for rcheevos
This commit is contained in:
commit
287c95ac8b
@ -1627,7 +1627,8 @@ found:
|
||||
CORO_SUB(RCHEEVOS_GET_GAMEID)
|
||||
|
||||
{
|
||||
int size = rc_url_get_gameid(coro->url, sizeof(coro->url), coro->hash);
|
||||
int size;
|
||||
size = rc_url_get_gameid(coro->url, sizeof(coro->url), coro->hash);
|
||||
|
||||
if (size < 0)
|
||||
{
|
||||
@ -1777,12 +1778,16 @@ found:
|
||||
*************************************************************************/
|
||||
CORO_SUB(RCHEEVOS_LOGIN)
|
||||
{
|
||||
const char* username = coro->settings->arrays.cheevos_username;
|
||||
const char* password = coro->settings->arrays.cheevos_password;
|
||||
const char* token = coro->settings->arrays.cheevos_token;
|
||||
const char* username;
|
||||
const char* password;
|
||||
const char* token;
|
||||
int ret;
|
||||
char tok[256];
|
||||
|
||||
username = coro->settings->arrays.cheevos_username;
|
||||
password = coro->settings->arrays.cheevos_password;
|
||||
token = coro->settings->arrays.cheevos_token;
|
||||
|
||||
if (rcheevos_locals.token[0])
|
||||
CORO_RET();
|
||||
|
||||
|
10
deps/rcheevos/include/rcheevos.h
vendored
10
deps/rcheevos/include/rcheevos.h
vendored
@ -150,15 +150,15 @@ typedef struct {
|
||||
/* A value read from memory. */
|
||||
rc_memref_value_t* memref;
|
||||
|
||||
/* A value. */
|
||||
unsigned value;
|
||||
/* An integer value. */
|
||||
unsigned num;
|
||||
|
||||
/* A floating point value. */
|
||||
double fp_value;
|
||||
double dbl;
|
||||
|
||||
/* A reference to the Lua function that provides the value. */
|
||||
int function_ref;
|
||||
};
|
||||
int luafunc;
|
||||
} value;
|
||||
|
||||
char type;
|
||||
}
|
||||
|
5
deps/rcheevos/src/rcheevos/internal.h
vendored
5
deps/rcheevos/src/rcheevos/internal.h
vendored
@ -3,10 +3,11 @@
|
||||
|
||||
#include "rcheevos.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define RC_TAG2(x,y) x ## y
|
||||
#define RC_TAG(x,y) RC_TAG2(x,y)
|
||||
#define RC_OFFSETOF(s, f) ((int)(long long)(&((s*)0)->f))
|
||||
#define RC_ALIGNOF(t) RC_OFFSETOF(struct RC_TAG(_unnamed, __LINE__) {char c; t d;}, d)
|
||||
#define RC_ALIGNOF(t) offsetof(struct RC_TAG(_unnamed, __LINE__) {char c; t d;}, d)
|
||||
|
||||
#define RC_ALLOC(t, p) ((t*)rc_alloc((p)->buffer, &(p)->offset, sizeof(t), RC_ALIGNOF(t), &(p)->scratch))
|
||||
|
||||
|
4
deps/rcheevos/src/rcheevos/memref.c
vendored
4
deps/rcheevos/src/rcheevos/memref.c
vendored
@ -22,7 +22,7 @@ rc_memref_value_t* rc_alloc_memref_value(rc_parse_state_t* parse, unsigned addre
|
||||
if (parse->scratch.memref_count == parse->scratch.memref_size) {
|
||||
if (parse->scratch.memref == parse->scratch.memref_buffer) {
|
||||
parse->scratch.memref_size += 16;
|
||||
memref = malloc(parse->scratch.memref_size * sizeof(parse->scratch.memref_buffer[0]));
|
||||
memref = (rc_memref_t*)malloc(parse->scratch.memref_size * sizeof(parse->scratch.memref_buffer[0]));
|
||||
if (memref) {
|
||||
parse->scratch.memref = memref;
|
||||
memcpy(memref, parse->scratch.memref_buffer, parse->scratch.memref_count * sizeof(parse->scratch.memref_buffer[0]));
|
||||
@ -34,7 +34,7 @@ rc_memref_value_t* rc_alloc_memref_value(rc_parse_state_t* parse, unsigned addre
|
||||
}
|
||||
else {
|
||||
parse->scratch.memref_size += 32;
|
||||
memref = realloc(parse->scratch.memref, parse->scratch.memref_size * sizeof(parse->scratch.memref_buffer[0]));
|
||||
memref = (rc_memref_t*)realloc(parse->scratch.memref, parse->scratch.memref_size * sizeof(parse->scratch.memref_buffer[0]));
|
||||
if (memref) {
|
||||
parse->scratch.memref = memref;
|
||||
}
|
||||
|
32
deps/rcheevos/src/rcheevos/operand.c
vendored
32
deps/rcheevos/src/rcheevos/operand.c
vendored
@ -21,7 +21,9 @@ extern "C" {
|
||||
|
||||
static int rc_parse_operand_lua(rc_operand_t* self, const char** memaddr, rc_parse_state_t* parse) {
|
||||
const char* aux = *memaddr;
|
||||
#ifndef RC_DISABLE_LUA
|
||||
const char* id;
|
||||
#endif
|
||||
|
||||
if (*aux++ != '@') {
|
||||
return RC_INVALID_LUA_OPERAND;
|
||||
@ -31,7 +33,9 @@ static int rc_parse_operand_lua(rc_operand_t* self, const char** memaddr, rc_par
|
||||
return RC_INVALID_LUA_OPERAND;
|
||||
}
|
||||
|
||||
#ifndef RC_DISABLE_LUA
|
||||
id = aux;
|
||||
#endif
|
||||
|
||||
while (isalnum(*aux) || *aux == '_') {
|
||||
aux++;
|
||||
@ -52,7 +56,7 @@ static int rc_parse_operand_lua(rc_operand_t* self, const char** memaddr, rc_par
|
||||
return RC_INVALID_LUA_OPERAND;
|
||||
}
|
||||
|
||||
self->function_ref = luaL_ref(parse->L, LUA_REGISTRYINDEX);
|
||||
self->value.luafunc = luaL_ref(parse->L, LUA_REGISTRYINDEX);
|
||||
}
|
||||
|
||||
#endif /* RC_DISABLE_LUA */
|
||||
@ -131,7 +135,7 @@ static int rc_parse_operand_memory(rc_operand_t* self, const char** memaddr, rc_
|
||||
address = 0xffffffffU;
|
||||
}
|
||||
|
||||
self->memref = rc_alloc_memref_value(parse, address, size, is_bcd);
|
||||
self->value.memref = rc_alloc_memref_value(parse, address, size, is_bcd);
|
||||
if (parse->offset < 0)
|
||||
return parse->offset;
|
||||
|
||||
@ -158,7 +162,7 @@ static int rc_parse_operand_trigger(rc_operand_t* self, const char** memaddr, rc
|
||||
}
|
||||
|
||||
self->type = RC_OPERAND_CONST;
|
||||
self->value = (unsigned)value;
|
||||
self->value.num = (unsigned)value;
|
||||
|
||||
aux = end;
|
||||
break;
|
||||
@ -191,7 +195,7 @@ static int rc_parse_operand_trigger(rc_operand_t* self, const char** memaddr, rc
|
||||
}
|
||||
|
||||
self->type = RC_OPERAND_CONST;
|
||||
self->value = (unsigned)value;
|
||||
self->value.num = (unsigned)value;
|
||||
|
||||
aux = end;
|
||||
break;
|
||||
@ -229,7 +233,7 @@ static int rc_parse_operand_term(rc_operand_t* self, const char** memaddr, rc_pa
|
||||
}
|
||||
|
||||
self->type = RC_OPERAND_CONST;
|
||||
self->value = (unsigned)value;
|
||||
self->value.num = (unsigned)value;
|
||||
|
||||
aux = end;
|
||||
break;
|
||||
@ -246,7 +250,7 @@ static int rc_parse_operand_term(rc_operand_t* self, const char** memaddr, rc_pa
|
||||
}
|
||||
|
||||
self->type = RC_OPERAND_CONST;
|
||||
self->value = (unsigned)value;
|
||||
self->value.num = (unsigned)value;
|
||||
|
||||
aux = end;
|
||||
break;
|
||||
@ -269,15 +273,15 @@ static int rc_parse_operand_term(rc_operand_t* self, const char** memaddr, rc_pa
|
||||
case '+': case '-':
|
||||
case '1': case '2': case '3': case '4': case '5':
|
||||
case '6': case '7': case '8': case '9':
|
||||
self->fp_value = strtod(aux, &end);
|
||||
self->value.dbl = strtod(aux, &end);
|
||||
|
||||
if (end == aux) {
|
||||
return RC_INVALID_FP_OPERAND;
|
||||
}
|
||||
|
||||
if (floor(self->fp_value) == self->fp_value) {
|
||||
if (floor(self->value.dbl) == self->value.dbl) {
|
||||
self->type = RC_OPERAND_CONST;
|
||||
self->value = (unsigned)floor(self->fp_value);
|
||||
self->value.num = (unsigned)floor(self->value.dbl);
|
||||
}
|
||||
else {
|
||||
self->type = RC_OPERAND_FP;
|
||||
@ -338,7 +342,7 @@ unsigned rc_evaluate_operand(rc_operand_t* self, rc_peek_t peek, void* ud, lua_S
|
||||
|
||||
switch (self->type) {
|
||||
case RC_OPERAND_CONST:
|
||||
value = self->value;
|
||||
value = self->value.num;
|
||||
break;
|
||||
|
||||
case RC_OPERAND_FP:
|
||||
@ -349,7 +353,7 @@ unsigned rc_evaluate_operand(rc_operand_t* self, rc_peek_t peek, void* ud, lua_S
|
||||
#ifndef RC_DISABLE_LUA
|
||||
|
||||
if (L != 0) {
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, self->function_ref);
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, self->value.luafunc);
|
||||
lua_pushcfunction(L, rc_luapeek);
|
||||
|
||||
luapeek.peek = peek;
|
||||
@ -374,15 +378,15 @@ unsigned rc_evaluate_operand(rc_operand_t* self, rc_peek_t peek, void* ud, lua_S
|
||||
break;
|
||||
|
||||
case RC_OPERAND_ADDRESS:
|
||||
value = self->memref->value;
|
||||
value = self->value.memref->value;
|
||||
break;
|
||||
|
||||
case RC_OPERAND_DELTA:
|
||||
value = self->memref->previous;
|
||||
value = self->value.memref->previous;
|
||||
break;
|
||||
|
||||
case RC_OPERAND_PRIOR:
|
||||
value = self->memref->prior;
|
||||
value = self->value.memref->prior;
|
||||
break;
|
||||
}
|
||||
|
||||
|
6
deps/rcheevos/src/rcheevos/term.c
vendored
6
deps/rcheevos/src/rcheevos/term.c
vendored
@ -37,7 +37,7 @@ rc_term_t* rc_parse_term(const char** memaddr, rc_parse_state_t* parse) {
|
||||
case RC_OPERAND_ADDRESS:
|
||||
case RC_OPERAND_DELTA:
|
||||
case RC_OPERAND_PRIOR:
|
||||
size = self->operand2.memref->memref.size;
|
||||
size = self->operand2.value.memref->memref.size;
|
||||
break;
|
||||
default:
|
||||
size = RC_MEMSIZE_32_BITS;
|
||||
@ -81,7 +81,7 @@ rc_term_t* rc_parse_term(const char** memaddr, rc_parse_state_t* parse) {
|
||||
}
|
||||
else {
|
||||
self->operand2.type = RC_OPERAND_CONST;
|
||||
self->operand2.value = 1;
|
||||
self->operand2.value.num = 1;
|
||||
}
|
||||
|
||||
*memaddr = aux;
|
||||
@ -95,5 +95,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 (unsigned)((double)value * self->operand2.fp_value);
|
||||
return (unsigned)((double)value * self->operand2.value.dbl);
|
||||
}
|
||||
|
@ -121,8 +121,6 @@ HAVE_QT=auto # Qt companion support
|
||||
C89_QT=no
|
||||
HAVE_XSHM=no # XShm video driver support
|
||||
HAVE_CHEEVOS=yes # Retro Achievements
|
||||
C89_CHEEVOS=no
|
||||
CXX_CHEEVOS=no
|
||||
HAVE_LUA=no # Lua support (for Retro Achievements)
|
||||
HAVE_DISCORD=yes # Discord Integration
|
||||
C89_DISCORD=no
|
||||
|
Loading…
x
Reference in New Issue
Block a user