Skip to content

Commit

Permalink
Merge branch 'master' of github.com:callofduty4x/CoD4x_Server
Browse files Browse the repository at this point in the history
  • Loading branch information
rt committed Apr 26, 2017
2 parents 3e95210 + 0f1d1ad commit b81a35c
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 10 deletions.
37 changes: 32 additions & 5 deletions plugins/pinc.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,44 @@
#undef PCL
#endif /*PCL*/

#ifdef PCL_LOCAL
#undef PCL_LOCAL
#endif /*PCL_LOCAL*/

#ifdef __iceimport
#undef __iceimport
#endif /*__iceimport*/

#define __iceimport extern __cdecl

#if LANG == CPP
#define PCL extern "C" __attribute__ ((visibility ("default"))) __attribute__ ((cdecl))
#else
#define PCL __attribute__ ((visibility ("default"))) __attribute__ ((cdecl))
#endif /*LANG == CPP*/
#if defined _WIN32 || defined __CYGWIN__ /*Windows*/
#ifdef __GNUC__ /*Windows and mingw*/
#if LANG == CPP /*Windows, mingw and c++*/
#define PCL extern "C" __attribute__ ((dllexport)) __attribute__ ((cdecl))
#else /*Windows, mingw and c*/
#define PCL __attribute__ ((dllexport)) __attribute__ ((cdecl))
#endif /*LANG == CPP*/
#else /*Windows and msvc*/
#if LANG == CPP /*Windows and msvc and c++*/
#define PCL extern "C" __declspec(dllexport) __cdecl
#else /*Windows and msvc and c*/
#define PCL __declspec(dllexport) __cdecl
#endif /*LANG == CPP*/
#endif
#define PCL_LOCAL
#else /*Unix*/
#if __GNUC__ >= 4 /*Unix, modern GCC*/
#if LANG == CPP /*Unix, modern GCC, G++*/
#define PCL extern "C" __attribute__ ((visibility ("default"))) __attribute__ ((cdecl))
#else /*Unix, modern GCC, GCC*/
#define PCL __attribute__ ((visibility ("default"))) __attribute__ ((cdecl))
#endif /*LANG == CPP*/
#define PCL_LOCAL __attribute__ ((visibility ("hidden")))
#else /*Unix, old GCC*/
#define PCL
#define PCL_LOCAL
#endif
#endif

#define Com_Memset memset

Expand Down
5 changes: 3 additions & 2 deletions src/netchan.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,9 @@ qboolean NET_SendPacket( netsrc_t sock, int length, const void *data, netadr_t *
}

// sequenced packets are shown in netchan, so just show oob
if ( showpackets->boolean && *(int *)data == -1 ) {
Com_Printf ("send packet %4i\n", length);
if ( showpackets->boolean && *(int *)data == -1 ){
char string[128];
Com_Printf ("NET_SendPacket %4i destination %s\n", length, NET_AdrToStringMT(to, string, sizeof(string)));
}
if ( to->type == NA_LOOPBACK ) {
NET_SendLoopPacket (sock, length, data, *to);
Expand Down
5 changes: 5 additions & 0 deletions src/plugin_exports.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ P_P_F qboolean Plugin_UdpSendData(netadr_t* to, void* data, int len)
Com_PrintError("Plugin_UdpSendData: First argument can not be a NULL-Pointer for plugin ID: #%d\n", pID);
return qfalse;
}

netadr_t* defif;
defif = NET_GetDefaultCommunicationSocket(to->type);
to->sock = defif ? defif->sock : 0;

return Sys_SendPacket( len, data, to);
}

Expand Down
4 changes: 2 additions & 2 deletions src/plugin_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ const char* PHandler_OpenTempFile(char* name, char* fullfilepath, int fplen){ //

Com_sprintf(filepath, sizeof(filepath),"plugins/%s" DLL_EXT, name);

len = FS_ReadFile(filepath, &buf);
len = FS_SV_ReadFile(filepath, &buf);

if(len < 100)
len = FS_SV_ReadFile( filepath, &buf );
len = FS_ReadFile( filepath, &buf );

if(len < 100)
{
Expand Down
2 changes: 1 addition & 1 deletion src/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,7 @@ void SV_HeartBeatMessageLoop(msg_t* msg, qboolean authoritative)
}else if(ic == 0){
Com_PrintError("Failure registering server on masterserver. Errorcode: 0x%x\n", MSG_ReadLong(&singlemsg));
}else if(ic == 2){
Com_PrintError("Failure registering server on masterserver. Server address is banned\n", MSG_ReadString(&singlemsg, stringline, sizeof(stringline)));
Com_PrintError("Failure registering server on masterserver. Server address is banned: %s\n", MSG_ReadString(&singlemsg, stringline, sizeof(stringline)));
}
break;
case 2:
Expand Down
17 changes: 17 additions & 0 deletions tools/screenshot_metadatadump/build_win32_PE.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@set path=C:\MinGW\bin;%path%
@echo off

echo Compiling C-code...

gcc -m32 -Wall -O0 -g -fno-omit-frame-pointer -march=nocona -D WINVER=0x501 -c *.c
echo Linking...
gcc -m32 -g -Wl,--nxcompat -o screenshotinfo.exe *.o -static-libgcc -static -lstdc++ -lws2_32

echo Cleaning up...
del *.o

echo Running...
screenshotinfo.exe

pause

134 changes: 134 additions & 0 deletions tools/screenshot_metadatadump/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// C program to print all permutations with duplicates allowed
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>

#ifdef __WIN32
#include <windows.h>
#else
#include <arpa/inet.h>
#endif

uint8_t freadbyte(FILE* fh)
{
uint8_t b;
if(fread(&b,1,1,fh) != 1)
{
printf("fread: I/O error\n");
exit(0);
}
return b;
}

uint8_t freadbigshort(FILE* fh)
{
uint16_t b;
if(fread(&b,2,1,fh) != 1)
{
printf("fread: I/O error\n");
exit(0);
}
return ntohs(b);
}

//Skip over "c" bytes
void freadskip(FILE* fh, int c)
{
int i;
for(i = 0; i < c; ++i)
{
freadbyte(fh);
}
}

void freadstring(FILE* fh, char *s, int limit)
{
int i;
for(i = 0; i < limit; ++i)
{
s[i] = freadbyte(fh);
if(s[i] == 0)
{
return;
}
}
}

enum { M_SOF0 = 0xC0, M_DHT = 0xC4, M_SOI = 0xD8, M_EOI = 0xD9, M_SOS = 0xDA, M_DQT = 0xDB, M_APP0 = 0xE0, M_COM = 0xFE };


void readmetadata(FILE* fh)
{
char line[1024];
freadstring(fh, line, sizeof(line)); //Vendor
freadstring(fh, line, sizeof(line)); //hostname
printf("Server: %s\n", line);
freadstring(fh, line, sizeof(line)); //map
printf("Map: %s\n", line);
freadstring(fh, line, sizeof(line)); //nick
printf("Nickname: %s\n", line);
freadstring(fh, line, sizeof(line)); //playerid
printf("PlayerID: %s\n", line);
freadstring(fh, line, sizeof(line)); //steamid
printf("SteamID: %s\n", line);
freadstring(fh, line, sizeof(line)); //time & date
printf("Date: %s\n", line);
}


int main(int argc, char **argv)
{
uint8_t marker, header;
uint16_t size;

if(argc != 2)
{
printf("Usage: screenshotinfo \"filename\"");
return 0;
}
printf("Opening file: \"%s\"\n", argv[1]);
FILE* fh = fopen(argv[1], "rb");
if(fh == NULL)
{
printf("File not found or no access to it\n");
return 0;
}
marker = freadbyte(fh);
header = freadbyte(fh);
if(marker != 0xff || header != M_SOI)
{
goto brokenimg;
}

do
{
marker = freadbyte(fh);
if(marker != 0xff)
{
goto brokenimg;
}

header = freadbyte(fh);
size = freadbigshort(fh);

if(header == M_EOI || header == M_SOS)
{
fclose(fh);
printf("No CoD4X metadata found\n");
return 0;
}
if(header == 0xeb)
{
readmetadata(fh);
fclose(fh);
return 0;
}
freadskip(fh, size -2);
}while(1);

brokenimg:
printf("Broken jfif file\n");
fclose(fh);
return 0;
}
Binary file added tools/screenshot_metadatadump/screenshotinfo.exe
Binary file not shown.
Binary file not shown.

0 comments on commit b81a35c

Please sign in to comment.