merge from 0.4.3: versionserver and red team score-use in dm

This commit is contained in:
Alfred Eriksson 2008-09-02 17:36:50 +00:00
parent c597887b91
commit fa5231f2c2
3 changed files with 68 additions and 1 deletions

View file

@ -390,7 +390,7 @@ void GAMECONTROLLER::snap(int snapping_client)
gameobj->warmup = warmup; gameobj->warmup = warmup;
gameobj->teamscore_red = teamscore[0]; gameobj->teamscore_red = is_teamplay() ? teamscore[0] : game.players[snapping_client].score;
gameobj->teamscore_blue = teamscore[1]; gameobj->teamscore_blue = teamscore[1];
} }

View file

@ -0,0 +1,60 @@
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
#include <string.h>
#include <base/system.h>
extern "C" {
#include <engine/e_network.h>
}
#include "versionsrv.h"
static net_client net_op; // main
void send_ver(NETADDR *addr)
{
NETCHUNK p;
unsigned char data[sizeof(VERSIONSRV_VERSION) + sizeof(VERSION_DATA)];
memcpy(data, VERSIONSRV_VERSION, sizeof(VERSIONSRV_VERSION));
memcpy(data + sizeof(VERSIONSRV_VERSION), VERSION_DATA, sizeof(VERSION_DATA));
p.client_id = -1;
p.address = *addr;
p.flags = NETSENDFLAG_CONNLESS;
p.data = data;
p.data_size = sizeof(data);
net_op.send(&p);
}
int main(int argc, char **argv)
{
NETADDR bindaddr;
mem_zero(&bindaddr, sizeof(bindaddr));
bindaddr.port = VERSIONSRV_PORT;
net_op.open(bindaddr, 0);
dbg_msg("versionsrv", "started");
while(1)
{
net_op.update();
// process packets
NETCHUNK packet;
while(net_op.recv(&packet))
{
if(packet.data_size == sizeof(VERSIONSRV_GETVERSION) &&
memcmp(packet.data, VERSIONSRV_GETVERSION, sizeof(VERSIONSRV_GETVERSION)) == 0)
{
send_ver(&packet.address);
}
}
// be nice to the CPU
thread_sleep(1);
}
return 0;
}

View file

@ -0,0 +1,7 @@
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
static const int VERSIONSRV_PORT = 8302;
static const unsigned char VERSION_DATA[] = {0x00, 0, 4, 3};
static const unsigned char VERSIONSRV_GETVERSION[] = {255, 255, 255, 255, 'v', 'e', 'r', 'g'};
static const unsigned char VERSIONSRV_VERSION[] = {255, 255, 255, 255, 'v', 'e', 'r', 's'};