Compare commits

...

7 Commits

Author SHA1 Message Date
mid
b32671567e Switch to strncasecmp
All checks were successful
k4 Build Test / do_the_build (push) Successful in 52s
2025-07-13 10:15:02 +03:00
mid
f4cf597a95 _DEFAULT_SOURCE and _GNU_SOURCE
Some checks failed
k4 Build Test / do_the_build (push) Failing after 30s
2025-07-13 09:57:52 +03:00
mid
5f2e84d8cf Support LOOPPOINT metadata field for ogg files
Some checks failed
k4 Build Test / do_the_build (push) Failing after 30s
2025-07-12 23:27:33 +03:00
mid
7754e410fd EVEN MORE STABLIER
All checks were successful
k4 Build Test / do_the_build (push) Successful in 56s
2025-07-05 14:06:07 +03:00
mid
5a3a524cb3 add libgomp
All checks were successful
k4 Build Test / do_the_build (push) Successful in 50s
2025-07-05 11:26:59 +03:00
mid
55b8e827c2 Strip
All checks were successful
k4 Build Test / do_the_build (push) Successful in 50s
2025-07-05 10:39:43 +03:00
mid
368664d246 Bug fixes
All checks were successful
k4 Build Test / do_the_build (push) Successful in 56s
2025-06-29 22:22:13 +03:00
5 changed files with 52 additions and 28 deletions

View File

@@ -16,7 +16,7 @@ jobs:
- run: mkdir build build/k3 build/k3/compr bin bin/assets - run: mkdir build build/k3 build/k3/compr bin bin/assets
- run: CC="i686-w64-mingw32-gcc" CFLAGS="-I/usr/i686-w64-mingw32/include -I/usr/i686-w64-mingw32/include/lua5.3 -L/usr/i686-w64-mingw32/lib -Wno-error" make -B - run: CC="i686-w64-mingw32-gcc" CFLAGS="-I/usr/i686-w64-mingw32/include -I/usr/i686-w64-mingw32/include/lua5.3 -L/usr/i686-w64-mingw32/lib -Wno-error" make -B
- run: CC="i686-linux-gnu-gcc" CFLAGS="-I/usr/i686-linux-gnu/include -I/usr/i686-linux-gnu/include/lua5.3 -L/usr/i686-linux-gnu/lib -Wno-error -include /home/git/force_link_glibc_2.20.h" make -B - run: CC="i686-linux-gnu-gcc" CFLAGS="-I/usr/i686-linux-gnu/include -I/usr/i686-linux-gnu/include/lua5.3 -L/usr/i686-linux-gnu/lib -Wno-error -include /home/git/force_link_glibc_2.20.h" make -B
- run: cp /usr/lib/gcc/i686-w64-mingw32/12-win32/libgcc_s_dw2-1.dll /usr/lib/gcc/i686-w64-mingw32/12-win32/libstdc++-6.dll /usr/i686-w64-mingw32/lib/libportaudio-2.dll /usr/i686-w64-mingw32/lib/libwinpthread-1.dll bin/ - run: cp /usr/lib/gcc/i686-w64-mingw32/12-win32/libgcc_s_dw2-1.dll /usr/lib/gcc/i686-w64-mingw32/12-win32/libstdc++-6.dll /usr/i686-w64-mingw32/lib/libportaudio-2.dll /usr/i686-w64-mingw32/lib/libwinpthread-1.dll /usr/lib/gcc/i686-w64-mingw32/12-win32/libgomp-1.dll bin/
- run: cp -r /home/git/k4templateassets/* bin/assets/ - run: cp -r /home/git/k4templateassets/* bin/assets/
- run: mv bin k4 - run: mv bin k4
- run: zip -9r "k4${{ github.ref_name }}.zip" k4/ - run: zip -9r "k4${{ github.ref_name }}.zip" k4/

View File

@@ -10,11 +10,11 @@ k3_HDRS := $(call rwildcard,k3/src,*.h)
k3_OBJS := $(patsubst k3/src/%.c, build/k3/%.o, $(k3_SRCS)) k3_OBJS := $(patsubst k3/src/%.c, build/k3/%.o, $(k3_SRCS))
k3_DEPS := $(patsubst k3/src/%.c, build/k3/%.d, $(k3_SRCS)) k3_DEPS := $(patsubst k3/src/%.c, build/k3/%.d, $(k3_SRCS))
CFLAGS := $(CFLAGS) -Ik3/src -O2 -fopenmp CFLAGS := $(CFLAGS) -D_GNU_SOURCE -D_DEFAULT_SOURCE -Ik3/src -O2 -fopenmp -flto -s
ifneq (,$(findstring mingw,$(CC))) ifneq (,$(findstring mingw,$(CC)))
CFLAGS := -static-libgcc -static-libstdc++ -std=gnu99 -march=pentium4 -D_WIN32_WINNT=0x600 -DENET_FEATURE_ADDRESS_MAPPING -fno-pic -no-pie -fms-extensions -fno-pie -Isrc $(CFLAGS) CFLAGS := -static-libgcc -static-libstdc++ -std=gnu99 -march=pentium4 -D_WIN32_WINNT=0x600 -DENET_FEATURE_ADDRESS_MAPPING -fno-pic -no-pie -fms-extensions -fno-pie -Isrc $(CFLAGS)
LIBS := -l:libglfw3.a -lopengl32 -pthread -lm -l:libode.a -l:libvorbisfile.a -l:libvorbis.a -l:libogg.a -lportaudio -lgdi32 -lws2_32 -lwinmm -lstdc++ -lole32 -lsetupapi -lhid -l:liblua5.3.a $(LIBS) LIBS := -l:libglfw3.a -lopengl32 -pthread -lm -l:libode.a -l:libvorbisfile.a -l:libvorbis.a -l:libogg.a -lportaudio -lgdi32 -lws2_32 -lwinmm -lstdc++ -lole32 -lsetupapi -lhid -l:liblua5.3.a -liphlpapi $(LIBS)
else else
CFLAGS := -march=opteron $(SAN) -std=gnu99 -DENET_FEATURE_ADDRESS_MAPPING -fms-extensions -fno-pic -no-pie -fno-pie -Isrc $(CFLAGS) CFLAGS := -march=opteron $(SAN) -std=gnu99 -DENET_FEATURE_ADDRESS_MAPPING -fms-extensions -fno-pic -no-pie -fno-pie -Isrc $(CFLAGS)
LIBS := -lglfw3 -pthread -ldl -lm -lode -lstdc++ -llua5.3 -lvorbis -lvorbisfile -lportaudio $(LIBS) LIBS := -lglfw3 -pthread -ldl -lm -lode -lstdc++ -llua5.3 -lvorbis -lvorbisfile -lportaudio $(LIBS)

View File

@@ -986,8 +986,8 @@ void game_cleanup() {
Game.phys = dWorldCreate(); Game.phys = dWorldCreate();
dWorldSetGravity(Game.phys, 0, -15, 0); dWorldSetGravity(Game.phys, 0, -15, 0);
dWorldSetCFM(Game.phys, 0.0002); dWorldSetCFM(Game.phys, 0.00002);
dWorldSetERP(Game.phys, 0.2); dWorldSetERP(Game.phys, 0.1);
Game.space = dHashSpaceCreate(NULL); Game.space = dHashSpaceCreate(NULL);

View File

@@ -6,6 +6,11 @@
#include<math.h> #include<math.h>
#include<pthread.h> #include<pthread.h>
#include<assert.h> #include<assert.h>
#include"k3.h"
#ifdef _WIN32
#define strncasecmp _strnicmp
#endif
static uint32_t FinalSampleRate; static uint32_t FinalSampleRate;
static uint8_t FinalChannels; static uint8_t FinalChannels;
@@ -19,12 +24,22 @@ struct k3MixSource {
char *filepath; char *filepath;
OggVorbis_File vf; OggVorbis_File vf;
int bitstream; int bitstream;
size_t looppoint;
}; };
struct k3MixSource *k3MixSourceFile(const char *path) { struct k3MixSource *k3MixSourceFile(const char *path) {
struct k3MixSource *ret = calloc(1, sizeof(*ret)); struct k3MixSource *ret = calloc(1, sizeof(*ret));
ret->filepath = strdup(path); ret->filepath = strdup(path);
ov_fopen(path, &ret->vf); ov_fopen(path, &ret->vf);
ret->bitstream = 0; ret->bitstream = 0;
ret->looppoint = 0;
for(size_t ci = 0; ci < ret->vf.vc->comments; ci++) {
if(strncasecmp(ret->vf.vc->user_comments[ci], "looppoint=", 10) == 0) {
ret->looppoint = strtol(ret->vf.vc->user_comments[ci] + 10, NULL, 0);
k3Log(k3_DEBUG, "%s has loop point %lu", path, ret->looppoint);
}
}
return ret; return ret;
} }
void k3MixSourceClose(struct k3MixSource *src) { void k3MixSourceClose(struct k3MixSource *src) {
@@ -42,7 +57,7 @@ __attribute__((optimize("Ofast"))) static intmax_t ogg_read(struct k3MixWave *th
long lastRead = ov_read_float(&od->vf, &ni, sampleCount, &od->bitstream); long lastRead = ov_read_float(&od->vf, &ni, sampleCount, &od->bitstream);
if(this->loop && lastRead == 0) { if(this->loop && lastRead == 0) {
ov_pcm_seek(&od->vf, 0); ov_pcm_seek(&od->vf, od->looppoint);
continue; continue;
} else if(lastRead <= 0) { } else if(lastRead <= 0) {
this->end = true; this->end = true;

View File

@@ -4,11 +4,13 @@
#include<winsock2.h> #include<winsock2.h>
#include<ws2tcpip.h> #include<ws2tcpip.h>
#include<ntsecapi.h> #include<ntsecapi.h>
#include<iphlpapi.h>
#else #else
#include<netdb.h> #include<netdb.h>
#include<sys/socket.h> #include<sys/socket.h>
#include<sys/random.h> #include<sys/random.h>
#include<arpa/inet.h> #include<arpa/inet.h>
#include<ifaddrs.h>
#endif #endif
#include<unistd.h> #include<unistd.h>
#include<sys/types.h> #include<sys/types.h>
@@ -17,7 +19,6 @@
#include<string.h> #include<string.h>
#include<stdio.h> #include<stdio.h>
#include<errno.h> #include<errno.h>
#include<ifaddrs.h>
#define STUN_BINDING_REQUEST 0x0001 #define STUN_BINDING_REQUEST 0x0001
#define STUN_BINDING_INDICATION 0x1100 #define STUN_BINDING_INDICATION 0x1100
@@ -73,9 +74,14 @@ static int stoon_init_mini(struct Stoon *this, struct addrinfo *serv, uint16_t m
freeaddrinfo(myaddrinfo); freeaddrinfo(myaddrinfo);
#ifdef _WIN32 #ifdef _WIN32
IP_ADAPTER_ADDRESSES *addrs = malloc(1024 * 64); size_t sz = 1024 * 64;
if(GetAdaptersAddresses(serv->ai_family, GAA_FLAG_SKIP_MULTICAST, NULL, &addrs) == NO_ERROR) { IP_ADAPTER_ADDRESSES *addrs = malloc(sz);
if(GetAdaptersAddresses(serv->ai_family, GAA_FLAG_SKIP_MULTICAST, NULL, addrs, &sz) == NO_ERROR) {
for(IP_ADAPTER_ADDRESSES *ifa = addrs; ifa; ifa = ifa->Next) { for(IP_ADAPTER_ADDRESSES *ifa = addrs; ifa; ifa = ifa->Next) {
if(!ifa->FirstUnicastAddress) {
continue;
}
if(serv->ai_family == AF_INET6) { if(serv->ai_family == AF_INET6) {
uint8_t *addr = (void*) &((struct sockaddr_in6*) ifa->FirstUnicastAddress->Address.lpSockaddr)->sin6_addr; uint8_t *addr = (void*) &((struct sockaddr_in6*) ifa->FirstUnicastAddress->Address.lpSockaddr)->sin6_addr;
if(addr[0] == 0 && addr[1] == 0 && addr[2] == 0 && addr[3] == 0 && addr[4] == 0 && addr[5] == 0 && addr[6] == 0 && addr[7] == 0 && addr[8] == 0 && addr[9] == 0 && addr[10] == 0 && addr[11] == 0 && addr[12] == 0 && addr[13] == 0 && addr[14] == 0 && (addr[15] == 0 || addr[15] == 1)) { if(addr[0] == 0 && addr[1] == 0 && addr[2] == 0 && addr[3] == 0 && addr[4] == 0 && addr[5] == 0 && addr[6] == 0 && addr[7] == 0 && addr[8] == 0 && addr[9] == 0 && addr[10] == 0 && addr[11] == 0 && addr[12] == 0 && addr[13] == 0 && addr[14] == 0 && (addr[15] == 0 || addr[15] == 1)) {
@@ -100,26 +106,29 @@ static int stoon_init_mini(struct Stoon *this, struct addrinfo *serv, uint16_t m
struct ifaddrs *ifaddr; struct ifaddrs *ifaddr;
if(getifaddrs(&ifaddr) >= 0) { if(getifaddrs(&ifaddr) >= 0) {
for(struct ifaddrs *ifa = ifaddr; ifa; ifa = ifa->ifa_next) { for(struct ifaddrs *ifa = ifaddr; ifa; ifa = ifa->ifa_next) {
if(ifa->ifa_addr->sa_family == serv->ai_family) { if(!ifa->ifa_addr || ifa->ifa_addr->sa_family != serv->ai_family) {
if(serv->ai_family == AF_INET6) { continue;
uint8_t *addr = (void*) &((struct sockaddr_in6*) ifa->ifa_addr)->sin6_addr;
if(addr[0] == 0 && addr[1] == 0 && addr[2] == 0 && addr[3] == 0 && addr[4] == 0 && addr[5] == 0 && addr[6] == 0 && addr[7] == 0 && addr[8] == 0 && addr[9] == 0 && addr[10] == 0 && addr[11] == 0 && addr[12] == 0 && addr[13] == 0 && addr[14] == 0 && (addr[15] == 0 || addr[15] == 1)) {
continue;
}
memcpy(this->peercode.localV6, addr, 16);
memcpy(this->peercode.localP6, &myport, 2);
} else {
uint8_t *addr = (void*) &((struct sockaddr_in*) ifa->ifa_addr)->sin_addr;
if(addr[0] == 0 && addr[1] == 0 && addr[2] == 0 && addr[3] == 0 || addr[0] == 127 && addr[1] == 0 && addr[2] == 0 && addr[3] == 1) {
continue;
}
memcpy(this->peercode.localV4, addr, 4);
memcpy(this->peercode.localP4, &myport, 2);
}
break;
} }
if(serv->ai_family == AF_INET6) {
uint8_t *addr = (void*) &((struct sockaddr_in6*) ifa->ifa_addr)->sin6_addr;
if(addr[0] == 0 && addr[1] == 0 && addr[2] == 0 && addr[3] == 0 && addr[4] == 0 && addr[5] == 0 && addr[6] == 0 && addr[7] == 0 && addr[8] == 0 && addr[9] == 0 && addr[10] == 0 && addr[11] == 0 && addr[12] == 0 && addr[13] == 0 && addr[14] == 0 && (addr[15] == 0 || addr[15] == 1)) {
continue;
}
memcpy(this->peercode.localV6, addr, 16);
memcpy(this->peercode.localP6, &myport, 2);
} else {
uint8_t *addr = (void*) &((struct sockaddr_in*) ifa->ifa_addr)->sin_addr;
if(addr[0] == 0 && addr[1] == 0 && addr[2] == 0 && addr[3] == 0 || addr[0] == 127 && addr[1] == 0 && addr[2] == 0 && addr[3] == 1) {
continue;
}
memcpy(this->peercode.localV4, addr, 4);
memcpy(this->peercode.localP4, &myport, 2);
}
break;
} }
freeifaddrs(ifaddr); freeifaddrs(ifaddr);