Skip to content
Snippets Groups Projects
Commit 5745e68c authored by slevy's avatar slevy
Browse files

Plugin-ize.

parent 565a7689
No related branches found
No related tags found
No related merge requests found
#include "nethack.h"
#ifndef USE_NETHACK
void nethack_init() { }
#else /* do USE_NETHACK */
......@@ -25,7 +23,6 @@ void nethack_init() { }
#include "specks.h"
#include "partiviewc.h"
#include "partiview.H"
#include "nethack.h"
struct sockaddr_in netsin;
......@@ -36,9 +33,10 @@ struct netops {
int cmds;
};
struct netops listening = { 1, 1 };
struct netops broadcasting = { 0, 0 };
static struct netops listening = { 1, 1 };
static struct netops broadcasting = { 0, 0 };
static int net_parse_args( struct stuff **, int argc, char *argv[], char *fname, void * );
static void dorecv(int fd, void *junk);
static int setnet(struct sockaddr_in *sinp, int ttl);
static int sendjump( float txyz[3], float rxyz[3] );
......@@ -51,11 +49,13 @@ void rxyz2aer( float aer[3], const float rxyz[3] );
static int netupdates;
void nethack_init() {
extern "C" {
void nethack_init() {
parti_add_commands( net_parse_args, "net", NULL );
}
}
int net_parse_args( struct stuff **, int argc, char *argv[], void * ) {
int net_parse_args( struct stuff **, int argc, char *argv[], char *fname, void * ) {
int i;
struct sockaddr_in sin;
......@@ -91,7 +91,7 @@ int net_parse_args( struct stuff **, int argc, char *argv[], void * ) {
memcpy(&sin.sin_addr, hp->h_addr_list[0], sizeof(sin.sin_addr));
sin.sin_family = hp->h_addrtype;
} else {
msg("net addrs: %s: unknown host\n", argv[2]);
msg("%s: net addrs: %s: unknown host\n", fname, argv[2]);
break;
}
setnet( &sin, ttl );
......@@ -205,9 +205,6 @@ static void cmdtrace( struct stuff **, int argc, char *argv[] ) {
static int setnet(struct sockaddr_in *sinp, int ttl) {
int multi = IN_CLASSD( ntohl( sinp->sin_addr.s_addr ) );
struct sockaddr_in osin;
int i;
struct hostent *hp;
static int on = 1;
if(netfd >= 0) {
......@@ -287,6 +284,7 @@ static int setnet(struct sockaddr_in *sinp, int ttl) {
Fl::add_fd( netfd, dorecv, NULL );
netupdate();
return 1;
}
#define PV_MAGIC 0x19570118
......@@ -388,9 +386,13 @@ static void receivecmd( int *buf, int len, struct sockaddr_in *srcsin ) {
parti_redraw();
}
#ifndef __BITS_SOCKET_H
# define socklen_t int
#endif
static void dorecv(int fd, void *junk) {
struct sockaddr_in sfrom;
size_t sfromlen = sizeof(sfrom);
socklen_t sfromlen = sizeof(sfrom);
int len;
int buf[16384];
int kind;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment