Compare commits
7 Commits
90f0e2dd42
...
v1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b32671567e | ||
|
|
f4cf597a95 | ||
|
|
5f2e84d8cf | ||
|
|
7754e410fd | ||
|
|
5a3a524cb3 | ||
|
|
55b8e827c2 | ||
|
|
368664d246 |
@@ -16,7 +16,7 @@ jobs:
|
||||
- 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-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: mv bin k4
|
||||
- run: zip -9r "k4${{ github.ref_name }}.zip" k4/
|
||||
|
||||
4
Makefile
4
Makefile
@@ -10,11 +10,11 @@ k3_HDRS := $(call rwildcard,k3/src,*.h)
|
||||
k3_OBJS := $(patsubst k3/src/%.c, build/k3/%.o, $(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)))
|
||||
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
|
||||
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)
|
||||
|
||||
@@ -986,8 +986,8 @@ void game_cleanup() {
|
||||
Game.phys = dWorldCreate();
|
||||
dWorldSetGravity(Game.phys, 0, -15, 0);
|
||||
|
||||
dWorldSetCFM(Game.phys, 0.0002);
|
||||
dWorldSetERP(Game.phys, 0.2);
|
||||
dWorldSetCFM(Game.phys, 0.00002);
|
||||
dWorldSetERP(Game.phys, 0.1);
|
||||
|
||||
Game.space = dHashSpaceCreate(NULL);
|
||||
|
||||
|
||||
17
src/k3mix.c
17
src/k3mix.c
@@ -6,6 +6,11 @@
|
||||
#include<math.h>
|
||||
#include<pthread.h>
|
||||
#include<assert.h>
|
||||
#include"k3.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define strncasecmp _strnicmp
|
||||
#endif
|
||||
|
||||
static uint32_t FinalSampleRate;
|
||||
static uint8_t FinalChannels;
|
||||
@@ -19,12 +24,22 @@ struct k3MixSource {
|
||||
char *filepath;
|
||||
OggVorbis_File vf;
|
||||
int bitstream;
|
||||
size_t looppoint;
|
||||
};
|
||||
struct k3MixSource *k3MixSourceFile(const char *path) {
|
||||
struct k3MixSource *ret = calloc(1, sizeof(*ret));
|
||||
ret->filepath = strdup(path);
|
||||
ov_fopen(path, &ret->vf);
|
||||
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;
|
||||
}
|
||||
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);
|
||||
|
||||
if(this->loop && lastRead == 0) {
|
||||
ov_pcm_seek(&od->vf, 0);
|
||||
ov_pcm_seek(&od->vf, od->looppoint);
|
||||
continue;
|
||||
} else if(lastRead <= 0) {
|
||||
this->end = true;
|
||||
|
||||
19
src/stoon.c
19
src/stoon.c
@@ -4,11 +4,13 @@
|
||||
#include<winsock2.h>
|
||||
#include<ws2tcpip.h>
|
||||
#include<ntsecapi.h>
|
||||
#include<iphlpapi.h>
|
||||
#else
|
||||
#include<netdb.h>
|
||||
#include<sys/socket.h>
|
||||
#include<sys/random.h>
|
||||
#include<arpa/inet.h>
|
||||
#include<ifaddrs.h>
|
||||
#endif
|
||||
#include<unistd.h>
|
||||
#include<sys/types.h>
|
||||
@@ -17,7 +19,6 @@
|
||||
#include<string.h>
|
||||
#include<stdio.h>
|
||||
#include<errno.h>
|
||||
#include<ifaddrs.h>
|
||||
|
||||
#define STUN_BINDING_REQUEST 0x0001
|
||||
#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);
|
||||
|
||||
#ifdef _WIN32
|
||||
IP_ADAPTER_ADDRESSES *addrs = malloc(1024 * 64);
|
||||
if(GetAdaptersAddresses(serv->ai_family, GAA_FLAG_SKIP_MULTICAST, NULL, &addrs) == NO_ERROR) {
|
||||
size_t sz = 1024 * 64;
|
||||
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) {
|
||||
if(!ifa->FirstUnicastAddress) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(serv->ai_family == AF_INET6) {
|
||||
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)) {
|
||||
@@ -100,7 +106,10 @@ static int stoon_init_mini(struct Stoon *this, struct addrinfo *serv, uint16_t m
|
||||
struct ifaddrs *ifaddr;
|
||||
if(getifaddrs(&ifaddr) >= 0) {
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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)) {
|
||||
@@ -118,9 +127,9 @@ static int stoon_init_mini(struct Stoon *this, struct addrinfo *serv, uint16_t m
|
||||
memcpy(this->peercode.localV4, addr, 4);
|
||||
memcpy(this->peercode.localP4, &myport, 2);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
freeifaddrs(ifaddr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user