Compare commits

...
36 Commits
Author SHA1 Message Date
alufolie91 f029a2b7d8 Merge branch 'Saturn-Next' into retrySOCK 2026-11-12 20:54:24 +01:00
alufolie91 32bd5a02ec fix some smol style gripes in lua mobj and player lib 2026-11-12 20:46:01 +01:00
indev 546fae5110 Merge branch 'remove-lua-udata-lib' into Saturn-Next 2026-11-12 22:43:23 +03:00
indev 148bd1ab4d Remove lua_udatalib, and use Lua_CreateFieldTable for mobj and player instead
Need to test this a little but in theory, udatalib doesn't really give
much benefits, and using fields table and enum is safer than messing
with offsetof
2026-11-10 21:53:23 +03:00
alufolie91 9a100439df Merge branch 'Saturn-Next' into retrySOCK 2026-11-05 15:40:28 +01:00
alufolie91 3b37f85024 Merge branch 'Saturn-Next' into retrySOCK 2026-10-16 15:24:18 +02:00
alufolie91 27a65ef973 Merge branch 'Saturn-Next' into retrySOCK 2026-09-27 17:54:06 +02:00
alufolie91 ffa9b2fa9a Merge branch 'Saturn-Next' into retrySOCK 2026-09-23 19:41:27 +02:00
alufolie91 ab9e0f923e Merge branch 'Saturn-Next' into retrySOCK 2026-09-18 18:31:42 +02:00
alufolie91 8bf3953b4a Merge branch 'Saturn-Next' into retrySOCK 2026-09-07 19:30:21 +02:00
alufolie91 44ef42cf84 start retry attempt prints from 1 not 0 2026-08-24 14:02:47 +02:00
alufolie91 746035bfea add missing line breaks to sock_send prints 2026-08-24 14:01:00 +02:00
alufolie91 70bc9879b3 Merge branch 'Saturn-Next' into retrySOCK 2026-08-24 13:57:25 +02:00
alufolie91 0e6a794a84 Merge branch 'Saturn-Next' into retrySOCK 2026-08-21 16:24:10 +02:00
alufolie91 4eccf40a0a Merge branch 'Saturn-Next' into retrySOCK 2026-08-07 16:38:50 +02:00
alufolie91 e3fd46297a Merge branch 'Saturn-Next' into retrySOCK 2026-08-01 16:29:40 +02:00
alufolie91 4c2e119385 Merge branch 'Saturn-Next' into retrySOCK 2026-07-24 16:22:36 +02:00
alufolie91 229a6a161e Merge branch 'Saturn-Next' into retrySOCK 2026-07-21 16:11:43 +02:00
alufolie91 1b2e4a1acc Merge branch 'Saturn-Next' into retrySOCK 2026-07-20 16:45:09 +02:00
alufolie91 2e6d49fcd6 Merge remote-tracking branch 'origin/Saturn-Next' into retrySOCK 2026-07-20 11:47:57 +02:00
alufolie91 7a8c66781b Merge branch 'Saturn-Next' into retrySOCK 2026-07-10 20:10:39 +02:00
alufolie91 c877226bfe Merge branch 'Saturn-Next' into retrySOCK 2026-07-08 18:57:24 +02:00
alufolie91 ac3c8b1d25 Merge branch 'Saturn-Next' into retrySOCK 2026-07-02 21:27:14 +02:00
alufolie91 feeba45b0d Merge branch 'Saturn-Next' into retrySOCK 2026-06-29 17:28:41 +02:00
alufolie91 06f3d2c91b Merge branch 'Saturn-Next' into retrySOCK 2026-06-28 22:58:25 +02:00
alufolie91 332fadc823 Merge branch 'Saturn-Next' into retrySOCK 2026-06-28 19:17:09 +02:00
alufolie91 39dc1b85e3 Merge branch 'Saturn-Next' into retrySOCK 2026-06-28 16:28:33 +02:00
alufolie91 5b2413444f Merge branch 'Saturn-Next' into retrySOCK 2026-06-27 18:53:02 +02:00
alufolie91 7855b2ed95 Merge branch 'Saturn-Next' into retrySOCK 2026-06-22 21:14:19 +02:00
alufolie91 caebe62ddb Merge branch 'Saturn-Next' into retrySOCK 2026-06-15 17:14:08 +02:00
alufolie91 9de285caac use sizeu1 instead of %lu
windoze.......
2026-06-13 13:41:00 +02:00
alufolie91 9bb4420ad3 Merge branch 'Saturn-Next' into retrySOCK 2026-06-13 13:37:44 +02:00
alufolie91 8dc3d870a1 Merge branch 'Saturn-Next' into retrySOCK 2026-06-12 22:08:53 +02:00
alufolie91 158546bd73 Merge remote-tracking branch 'origin/Saturn-Next' into retrySOCK 2026-06-12 21:21:33 +02:00
alufolie91 b89a3f1017 Merge branch 'Saturn-Next' into retrySOCK 2026-06-08 16:58:06 +02:00
alufolie91 f2e355a5a8 SOCK_Send: retry failed connections
very sketchy since idk networking for shit
but seems to work so far?
2026-06-05 13:21:26 +02:00
8 changed files with 1650 additions and 1433 deletions

No files matched your search

-2
View File
@@ -292,7 +292,6 @@ if(${SRB2_CONFIG_HAVE_BLUA})
lua_script.c
lua_skinlib.c
lua_thinkerlib.c
lua_udatalib.c
lua_glib.c
)
set(SRB2_LUA_HEADERS
@@ -302,7 +301,6 @@ if(${SRB2_CONFIG_HAVE_BLUA})
lua_profile.h
lua_libs.h
lua_script.h
lua_udatalib.h
lua_glib.h
)
-1
View File
@@ -97,6 +97,5 @@ lua_playerlib.c
lua_script.c
lua_skinlib.c
lua_thinkerlib.c
lua_udatalib.c
lua_glib.c
lua_profile.cpp
+34 -4
View File
@@ -752,9 +752,14 @@ static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr
static void SOCK_Send(void)
{
ssize_t c = ERRSOCKET;
int e = 0; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once
size_t i, j;
int retrycount = 0;
ssize_t c;
int e; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once
retry:
c = ERRSOCKET;
e = 0;
if (doomcom->remotenode < 0 || !nodeconnected[doomcom->remotenode])
return;
@@ -808,10 +813,35 @@ static void SOCK_Send(void)
if (c == ERRSOCKET && e != 0) // 0 means no socket for the address family was found
{
if (!ALLOWEDERROR(e))
I_Error("SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode,
if (ALLOWEDERROR(e))
return;
//if (!ALLOWEDERROR(e))
//I_Error("SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode,
//SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e));
// no need to spam this on retries
if (retrycount == 0)
CONS_Alert(CONS_ERROR, "SOCK_Send, error sending to node %d (%s) #%u, %s\n", doomcom->remotenode,
SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e));
// retry sending it
if (retrycount <= 3)
{
CONS_Printf("SOCK_Send: retrying... Attempt %d\n", retrycount+1);
retrycount++;
// wait quarter of a second or smth
I_Sleep(250);
goto retry;
}
// no recovery, guess we die
I_Error("SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode,
SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e));
}
if (retrycount > 0)
CONS_Alert(CONS_NOTICE, "SOCK_Send: successfully reconnected on Attempt %d\n", retrycount);
}
#undef ALLOWEDERROR
-10
View File
@@ -18,7 +18,6 @@
#include "p_slopes.h"
#include "r_main.h"
#include "lua_udatalib.h"
#include "lua_script.h"
#include "lua_libs.h"
#include "lua_hud.h" // hud_running errors
@@ -256,15 +255,6 @@ static const char *const vector_opt[] = {
static const char *const array_opt[] ={"iterate",NULL};
static const char *const valid_opt[] ={"valid",NULL};
#define pushsubsector(L, subsector) LUA_PushUserdata(L, subsector, META_SUBSECTOR)
int udatalib_getter_subsector(lua_State *L)
UDATALIB_SIMPLE_GETTER(subsector_t*, pushsubsector)
#undef pushsubsector
#define pushslope(L, slope) LUA_PushUserdata(L, slope, META_SLOPE)
int udatalib_getter_slope(lua_State *L)
UDATALIB_SIMPLE_GETTER(pslope_t*, pushslope)
#undef pushslope
// iterates through a sector's thinglist!
static int lib_iterateSectorThinglist(lua_State *L)
{
+769 -743
View File
File diff suppressed because it is too large. Load diff
+847 -422
View File
File diff suppressed because it is too large. Load diff
-137
View File
@@ -1,137 +0,0 @@
// SONIC ROBO BLAST 2 KART SATURN
//-----------------------------------------------------------------------------
// Copyright (C) 2025 by Indev.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file lua_udatalib.c
/// \brief Implementation of lua userdata object metatables based on getter/setter functions
#include "doomtype.h"
#include "m_fixed.h"
#include "lua_udatalib.h"
// Getters
int udatalib_getter_fixed(lua_State *L)
UDATALIB_SIMPLE_GETTER(fixed_t, lua_pushinteger)
int udatalib_getter_angle(lua_State *L)
UDATALIB_SIMPLE_GETTER(angle_t, lua_pushangle)
int udatalib_getter_uint8(lua_State *L)
UDATALIB_SIMPLE_GETTER(UINT8, lua_pushinteger)
int udatalib_getter_sint8(lua_State *L)
UDATALIB_SIMPLE_GETTER(SINT8, lua_pushinteger)
int udatalib_getter_uint16(lua_State *L)
UDATALIB_SIMPLE_GETTER(UINT16, lua_pushinteger)
int udatalib_getter_int16(lua_State *L)
UDATALIB_SIMPLE_GETTER(INT16, lua_pushinteger)
int udatalib_getter_uint32(lua_State *L)
UDATALIB_SIMPLE_GETTER(UINT32, lua_pushinteger)
int udatalib_getter_int32(lua_State *L)
UDATALIB_SIMPLE_GETTER(INT32, lua_pushinteger)
int udatalib_getter_uint64(lua_State *L)
UDATALIB_SIMPLE_GETTER(UINT64, lua_pushinteger)
int udatalib_getter_int64(lua_State *L)
UDATALIB_SIMPLE_GETTER(INT64, lua_pushinteger)
int udatalib_getter_string(lua_State *L)
UDATALIB_SIMPLE_GETTER(const char*, lua_pushstring)
int udatalib_getter_boolean(lua_State *L)
UDATALIB_SIMPLE_GETTER(boolean, lua_pushboolean)
int udatalib_getter_spritenum(lua_State *L)
UDATALIB_SIMPLE_GETTER(spritenum_t, lua_pushinteger)
int udatalib_getter_tic(lua_State *L)
UDATALIB_SIMPLE_GETTER(tic_t, lua_pushinteger)
// Setters
int udatalib_setter_fixed(lua_State *L)
UDATALIB_SIMPLE_SETTER(fixed_t, luaL_checkfixed)
int udatalib_setter_angle(lua_State *L)
UDATALIB_SIMPLE_SETTER(angle_t, luaL_checkangle)
int udatalib_setter_uint8(lua_State *L)
UDATALIB_SIMPLE_SETTER(UINT8, (UINT8)luaL_checkinteger)
int udatalib_setter_sint8(lua_State *L)
UDATALIB_SIMPLE_SETTER(SINT8, luaL_checkinteger)
int udatalib_setter_uint16(lua_State *L)
UDATALIB_SIMPLE_SETTER(UINT16, (UINT16)luaL_checkinteger)
int udatalib_setter_int16(lua_State *L)
UDATALIB_SIMPLE_SETTER(INT16, luaL_checkinteger)
int udatalib_setter_uint32(lua_State *L)
UDATALIB_SIMPLE_SETTER(UINT32, (UINT32)luaL_checkinteger)
int udatalib_setter_int32(lua_State *L)
UDATALIB_SIMPLE_SETTER(INT32, luaL_checkinteger)
int udatalib_setter_uint64(lua_State *L)
UDATALIB_SIMPLE_SETTER(UINT64, (UINT64)luaL_checkinteger)
int udatalib_setter_int64(lua_State *L)
UDATALIB_SIMPLE_SETTER(INT64, luaL_checkinteger)
int udatalib_setter_string(lua_State *L)
UDATALIB_SIMPLE_SETTER(const char*, luaL_checkstring)
int udatalib_setter_boolean(lua_State *L)
UDATALIB_SIMPLE_SETTER(boolean, luaL_checkboolean)
// ffs
int udatalib_setter_boolean_nocheck(lua_State *L)
UDATALIB_SIMPLE_SETTER(boolean, lua_toboolean)
int udatalib_setter_spritenum(lua_State *L)
UDATALIB_SIMPLE_SETTER(spritenum_t, luaL_checkinteger)
int udatalib_setter_tic(lua_State *L)
UDATALIB_SIMPLE_SETTER(tic_t, (tic_t)luaL_checkinteger)
void udatalib_addfield(lua_State *L, int mt, udata_field_t field)
{
int idx = abs_index(L, mt);
lua_createtable(L, 2, 0); // Push table
lua_pushinteger(L, field.offset); // Push offset
lua_pushcclosure(L, field.getter, 1); // Pop offset, push closure
lua_rawseti(L, -2, UDATALIB_GETTER); // Pop closure, add to table
lua_pushinteger(L, field.offset); // Push offset
lua_pushcclosure(L, field.setter, 1); // Pop offset, push closure
lua_rawseti(L, -2, UDATALIB_SETTER); // Pop closure, add to table
lua_pushstring(L, field.name); // Push field name
lua_pushvalue(L, -2); // Copy table
lua_rawset(L, idx); // Pop field name and table, add to metatable
lua_pop(L, 1); // Pop field table
}
void udatalib_addfields(lua_State *L, int mt, const udata_field_t fields[])
{
for (unsigned i = 0; fields[i].name != NULL; ++i)
{
udatalib_addfield(L, mt, fields[i]);
//CONS_Printf("Add field name=%s, offset=%d, getter=%p, setter=%p\n", fields[i].name, fields[i].offset, fields[i].getter, fields[i].setter);
}
}
-114
View File
@@ -1,114 +0,0 @@
// SONIC ROBO BLAST 2 KART SATURN
//-----------------------------------------------------------------------------
// Copyright (C) 2025 by Indev.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file lua_udatalib.h
/// \brief Implementation of lua userdata object metatables based on getter/setter functions
#ifndef __LUA_UDATALIB_H__
#define __LUA_UDATALIB_H__
#include "doomdef.h"
#include "lua_script.h"
#include "lua_libs.h"
#include "fastcmp.h"
// Indices in getter/setter tables for fields
#define UDATALIB_GETTER 1
#define UDATALIB_SETTER 2
typedef struct udata_field_s {
const char *name;
size_t offset;
lua_CFunction getter;
lua_CFunction setter;
} udata_field_t;
// Simple setters and getters, for situations where getter is simply
// "return obj.field" and setter is "obj.field = value"
int udatalib_getter_fixed(lua_State *L);
int udatalib_getter_angle(lua_State *L);
int udatalib_getter_uint8(lua_State *L);
int udatalib_getter_sint8(lua_State *L);
int udatalib_getter_uint16(lua_State *L);
int udatalib_getter_int16(lua_State *L);
int udatalib_getter_uint32(lua_State *L);
int udatalib_getter_int32(lua_State *L);
int udatalib_getter_uint64(lua_State *L);
int udatalib_getter_int64(lua_State *L);
int udatalib_getter_string(lua_State *L);
int udatalib_getter_boolean(lua_State *L);
int udatalib_getter_spritenum(lua_State *L);
int udatalib_getter_mobj(lua_State *L);
int udatalib_getter_subsector(lua_State *L);
int udatalib_getter_mobjtype(lua_State *L);
int udatalib_getter_player(lua_State *L);
int udatalib_getter_mapthing(lua_State *L);
int udatalib_getter_slope(lua_State *L);
int udatalib_getter_cmd(lua_State *L);
int udatalib_getter_playerstate(lua_State *L);
int udatalib_getter_powers(lua_State *L);
int udatalib_getter_kartstuff(lua_State *L);
int udatalib_getter_pflags(lua_State *L);
int udatalib_getter_panim(lua_State *L);
int udatalib_getter_tic(lua_State *L);
int udatalib_setter_fixed(lua_State *L);
int udatalib_setter_angle(lua_State *L);
int udatalib_setter_uint8(lua_State *L);
int udatalib_setter_sint8(lua_State *L);
int udatalib_setter_uint16(lua_State *L);
int udatalib_setter_int16(lua_State *L);
int udatalib_setter_uint32(lua_State *L);
int udatalib_setter_int32(lua_State *L);
int udatalib_setter_uint64(lua_State *L);
int udatalib_setter_int64(lua_State *L);
int udatalib_setter_string(lua_State *L);
int udatalib_setter_boolean(lua_State *L);
int udatalib_setter_boolean_nocheck(lua_State *L);
int udatalib_setter_spritenum(lua_State *L);
int udatalib_setter_mobj(lua_State *L);
int udatalib_setter_playerstate(lua_State *L);
int udatalib_setter_pflags(lua_State *L);
int udatalib_setter_panim(lua_State *L);
int udatalib_setter_tic(lua_State *L);
// Adds setter and getter for field and stores it as field.name..".get" and
// field.name..".set" in table at index mt. (metatable, usually)
void udatalib_addfield(lua_State *L, int mt, udata_field_t field);
// Convinience function to add array of fields at once.
void udatalib_addfields(lua_State *L, int mt, const udata_field_t fields[]);
// I miss C++ template functons :(
// Get pointer to field value within getter or setter
#define UDATALIB_GETFIELD(type, field) \
{ \
size_t offset = lua_tointeger(L, lua_upvalueindex(1)); \
field = (type*)((uint8_t*)lua_touserdata(L, 1) + offset); \
}
// Creates implementation for simple getter and setter. Super lazy, yes.
// Assumes userdata is a pointer to actual data. Maybe not really safe.
#define UDATALIB_SIMPLE_GETTER(type, pushf) \
{ \
type *field; \
UDATALIB_GETFIELD(type, field) \
pushf(L, *field); \
return 1; \
}
#define UDATALIB_SIMPLE_SETTER(type, checkf) \
{ \
type *field; \
UDATALIB_GETFIELD(type, field) \
*field = checkf(L, 2); \
return 0; \
}
#endif