[Freeciv-Dev] MFC patches
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Hi
The folowing is a sequence of diff files that I made against the CVS server
today. Could someone check to verify that they don't break the server code?
Andy Black
PS. If the sequence is too confusing, I can send the diffs out as attachments.
Index: packets.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v
retrieving revision 1.43
diff -u -2 -r1.43 packets.c
--- packets.c 1999/06/12 07:41:56 1.43
+++ packets.c 1999/06/29 02:18:25
@@ -17,7 +17,9 @@
#include <unistd.h>
+#if !(GENERATING68K || GENERATINGPPC) /* non mac header(s) */
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#endif
#include "capability.h"
@@ -1883,5 +1885,5 @@
if(pc) {
if(pc->send_buffer.ndata) {
- if(write(pc->sock, pc->send_buffer.data, pc->send_buffer.ndata)!=
+ if(write(pc->sock, (const char *)pc->send_buffer.data,
pc->send_buffer.ndata)!=
pc->send_buffer.ndata) {
freelog(LOG_NORMAL, "failed writing data to socket");
@@ -1911,5 +1913,5 @@
}
else {
- if(write(pc->sock, data, len)!=len) {
+ if(write(pc->sock, (const char *)data, len)!=len) {
freelog(LOG_NORMAL, "failed writing data to socket");
return -1;
@@ -1934,5 +1936,5 @@
int didget;
- if((didget=read(sock, buffer->data+buffer->ndata,
+ if((didget=read(sock, (char *)(buffer->data+buffer->ndata),
MAX_PACKET_SIZE-buffer->ndata))<=0)
return -1;
Index: shared.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/shared.c,v
retrieving revision 1.19
diff -u -2 -r1.19 shared.c
--- shared.c 1999/06/17 12:11:53 1.19
+++ shared.c 1999/06/29 02:18:20
@@ -21,6 +21,10 @@
#include <assert.h>
+#if (GENERATING68K || GENERATINGPPC) /* mac header(s) */
+#include <events.h> /* for WaitNextEvent() */
+#else
#include <sys/time.h>
#include <sys/types.h>
+#endif
#include <unistd.h>
@@ -283,4 +287,9 @@
void myusleep(unsigned long usec)
{
+#if (GENERATING68K || GENERATINGPPC) /* mac timeshare function */
+ EventRecord the_event; /* dummy var for timesharing */
+ WaitNextEvent(0, &the_event, GetCaretTime(), nil); /* this is suposed to
+ give other application procseor time for the mac*/
+#else
#ifndef HAVE_USLEEP
struct timeval tv;
@@ -291,4 +300,5 @@
#else
usleep(usec);
+#endif
#endif
}
Index: civserver.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/civserver.c,v
retrieving revision 1.98
diff -u -2 -r1.98 civserver.c
--- civserver.c 1999/06/22 10:45:48 1.98
+++ civserver.c 1999/06/29 02:42:47
@@ -23,5 +23,7 @@
#include <unistd.h>
+#if !(GENERATING68K || GENERATINGPPC) /* non mac header(s) */
#include <sys/types.h>
+#endif
#ifdef __EMX__
@@ -132,5 +134,9 @@
...
**************************************************************************/
+#if (GENERATING68K || GENERATINGPPC) /* mac doesn't have comand line */
+int main(void)
+#else /*LINUX does*/
int main(int argc, char *argv[])
+#endif /* end main def selector*/
{
int h=0, v=0, n=1;
@@ -143,4 +149,5 @@
int loglevel=LOG_NORMAL;
+#if !(GENERATING68K || GENERATINGPPC) /* non mac code */
if (!getuid() || !geteuid()) {
fprintf(stderr, "%s: Fatal error: you're trying to run me as
superuser!\n",
@@ -149,4 +156,5 @@
exit(1);
}
+#endif
strcpy(metaserver_info_line, DEFAULT_META_SERVER_INFO_STRING);
@@ -154,5 +162,76 @@
/* no we don't use GNU's getopt or even the "standard" getopt */
/* yes we do have reasons ;) */
-
+#if (GENERATING68K || GENERATINGPPC) /* Mac Options */
+ optptr=GetNewDialog(128,nil,(WindowPtr)-1);
+ err=SetDialogDefaultItem(optptr, 2);
+ if (err != 0)
+ {
+ exit(1);
+ }
+ err=SetDialogTracksCursor(optptr, true);
+ if (err != 0)
+ {
+ exit(1);
+ }
+
+ while(!done)
+ {
+ Str255 the_string;
+ DialogPtr optptr;
+ short the_item, the_type;
+ Handle the_handle;
+ Rect the_rect;
+ OSErr err;
+ long temp;
+ ModalDialog(0, &the_item);
+ switch (the_item)
+ {
+ case 1:
+ done = true;
+ break;
+ case 2:
+ exit(0);
+ break;
+ case 4:
+ GetDItem( optptr, 4, &the_type, &the_handle, &the_rect);
+ GetIText( the_handle, (unsigned char *)load_filename);
+ break;
+ case 6:
+ GetDItem( optptr, 6, &the_type, &the_handle, &the_rect);
+ GetIText( the_handle, (unsigned char *)gamelog_filename);
+ break;
+ case 8:
+ GetDItem( optptr, 8, &the_type, &the_handle, &the_rect);
+ GetIText( the_handle, (unsigned char *)log_filename);
+ break;
+ case 10:
+ GetDItem( optptr, 10, &the_type, &the_handle, &the_rect);
+ GetIText( the_handle, (unsigned char *)script_filename);
+ break;
+ case 12:
+ GetDItem( optptr, 12, &the_type, &the_handle, &the_rect);
+ GetIText( the_handle, the_string);
+ StringToNum( the_string, &temp);
+ if (temp>0)
+ port=temp;
+ break;
+ case 13:
+ GetDItem(optptr, 13, &the_type, &the_handle, &the_rect);
+ n=GetCtlValue((ControlHandle)the_handle);
+ SetCtlValue((ControlHandle)the_handle, !n);
+ break;
+ case 15:
+ case 16:
+ case 17:
+ GetDItem(optptr, (log_level+15), &the_type, &the_handle, &the_rect);
+ SetCtlValue((ControlHandle)the_handle, false);
+ log_level=the_item-15;
+ GetDItem(optptr, the_item, &the_type, &the_handle, &the_rect);
+ SetCtlValue((ControlHandle)the_handle, true);
+ break;
+ }
+ }
+ DisposeDialog(optptr);
+#else /*non mac options*/
i=1;
while(i<argc) {
@@ -247,5 +326,5 @@
i++;
}
-
+#endif /*end option selector*/
if(v && !h) {
fprintf(stderr, FREECIV_NAME_VERSION "\n");
@@ -282,8 +361,19 @@
gamelog(GAMELOG_NORMAL,"Starting new log");
-#if IS_BETA_VERSION
+#if (GENERATING68K || GENERATINGPPC) /* mac alternate beta */
+ #if IS_BETA_VERSION
+ con_write(C_COMMENT,"This is an alpha/beta version of MacFreeciv. "
+ " This is based on the 1.8.0 Version of the Freeciv code. "
+ " Send error/bug reports to :%s"
+ " Visit
http://www.geocities.com/SiliconValley/Orchard/8738/MFC/index.html\n"
+ "for new versions of this project",MAILING_LIST);
+ #endif
+#else
+ #if IS_BETA_VERSION
con_write(C_COMMENT, "Freeciv 1.8 will be released "
"third week of March at %s", WEBSITE_URL);
+ #endif
#endif
+
con_flush();
Index: mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.36
diff -u -2 -r1.36 mapgen.c
--- mapgen.c 1999/06/15 11:47:31 1.36
+++ mapgen.c 1999/06/29 02:43:02
@@ -17,5 +17,4 @@
#include <time.h>
-#include <sys/time.h>
#include "game.h"
Index: meta.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/meta.c,v
retrieving revision 1.7
diff -u -2 -r1.7 meta.c
--- meta.c 1999/06/12 07:42:02 1.7
+++ meta.c 1999/06/29 02:42:11
@@ -18,6 +18,9 @@
#include <string.h>
#include <time.h>
-
#include <unistd.h>
+
+#if (GENERATING68K || GENERATINGPPC) /* mac network headers */
+#include <OpenTransport.h>
+#else /*LINUX network headers*/
#include <sys/types.h>
#include <sys/socket.h>
@@ -25,4 +28,5 @@
#include <arpa/inet.h>
#include <netdb.h>
+#endif /*end network header selection*/
#include "packets.h"
@@ -34,23 +38,37 @@
#endif
+#if (GENERATING68K || GENERATINGPPC) /* mac network globals */
+TEndpointInfo meta_info;
+EndpointRef meta_ep;
+InetAddress serv_addr;
+#else /*LINUX network globals*/
extern int errno;
static int sockfd,n,in_size;
static struct sockaddr_in cli_addr,serv_addr;
+#endif /*end network global selector*/
int send_to_metaserver(char *desc, char *info)
{
unsigned char buffer[MAX_PACKET_SIZE], *cptr;
-
+#if (GENERATING68K || GENERATINGPPC) /* mac alternate networking */
+ struct TUnitData xmit;
+ OSStatus err
+ xmit.udata.maxlen = MAX_PACKET_SIZE;
+ xmit.udata.buf=&buffer;
+#else
if(sockfd==0)
return 0;
-
+#endif
cptr=put_int16(buffer+2, PACKET_UDP_PCKT);
cptr=put_string(cptr, desc);
cptr=put_string(cptr, info);
put_int16(buffer, cptr-buffer);
-
- n=sendto(sockfd, (const void*)buffer, cptr-buffer,0,
+#if (GENERATING68K || GENERATINGPPC) /* mac alternate networking */
+ xmit.udata.len=strlen(buffer);
+ err=OTSndUData(meta_ep, &xmit);
+#else
+ n=sendto(sockfd, buffer, cptr-buffer,0,
(struct sockaddr *) &serv_addr, sizeof(serv_addr) );
-
+#endif
return 1;
}
@@ -58,5 +76,9 @@
void server_close_udp(void)
{
+#if (GENERATING68K || GENERATINGPPC)
+ OTUnbind(meta_ep);
+#else
close(sockfd);
+#endif
}
@@ -64,7 +86,14 @@
{
char servername[]=METASERVER_ADDR;
+#if (GENERATING68K || GENERATINGPPC) /* mac alternate networking */
+ OSStatus err1;
+ OSErr err2;
+ MapperRef ref=OTOpenMapper(OTCreateConfiguration("dnr"), 0, &err1);
+ TLookupRequest request, reply;
+#else
struct hostent *hp;
u_int bin;
-
+#endif
+
/*
* Fill in the structure "serv_addr" with the address of the
@@ -72,4 +101,12 @@
* is valid, both decimal-dotted and name.
*/
+#if (GENERATING68K || GENERATINGPPC) /* mac alternate networking */
+ request.udata.len=strlen(servername);
+ request.udata.buf=&servername;
+ err2=OTLookupName(ref, 1, &request, &reply);
+ serv_adr=reply.udata.buf;
+ if((serv_adr.fHost == 0) || (err2 != 0) || (reply.respcount==0)) {
+ {
+#else
in_size = sizeof(inet_addr(servername));
bin = inet_addr(servername);
@@ -77,4 +114,5 @@
{
if((hp = gethostbyname(servername)) ==NULL) {
+#endif
perror("Metaserver: address error");
con_puts(C_METAERROR,"Not reporting to the metaserver in this game.");
@@ -83,14 +121,17 @@
}
}
+ /*
+ * Open a UDP socket (an Internet datagram socket).
+ */
+#if (GENERATING68K || GENERATINGPPC) /* mac alternate networking */
+ meta_ep=OTOpenEndpoint(OTCreateConfiguration(kUDPName), 0, &meta_info,
&err1);
+ if (err1 != 0) {
+#else
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(METASERVER_PORT);
memcpy(&serv_addr.sin_addr, hp->h_addr, hp->h_length);
-
- /*
- * Open a UDP socket (an Internet datagram socket).
- */
-
if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+#endif
perror("metaserver: can't open datagram socket");
con_puts(C_METAERROR, "Not reporting to the metaserver in this game.");
@@ -102,4 +143,8 @@
*/
+#if (GENERATING68K || GENERATINGPPC) /* mac alternate networking */
+ err=OTBind(meta_ep, NULL, NULL);
+ if (err1 != 0) {
+#else
memset( &cli_addr, 0, sizeof(cli_addr)); /* zero out */
cli_addr.sin_family = AF_INET;
@@ -107,4 +152,5 @@
cli_addr.sin_port = htons(0);
if(bind(sockfd, (struct sockaddr *) &cli_addr, sizeof(cli_addr)) < 0) {
+#endif
perror("metaserver: can't bind local address");
con_puts(C_METAERROR, "Not reporting to the metaserver in this game.");
Index: sernet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/sernet.c,v
retrieving revision 1.15
diff -u -2 -r1.15 sernet.c
--- sernet.c 1999/06/12 07:42:02 1.15
+++ sernet.c 1999/06/29 02:42:23
@@ -18,8 +18,10 @@
#include <unistd.h>
+#if !(GENERATING68K || GENERATINGPPC) /* non mac header(s) */
#include <sys/signal.h>
#include <sys/types.h>
#include <sys/time.h>
#include <pwd.h>
+#endif
#if defined(AIX) || defined(__EMX__)
@@ -29,4 +31,5 @@
#include <signal.h>
+#if !(GENERATING68K || GENERATINGPPC) /* non mac header(s) */
#include <sys/socket.h>
#include <netdb.h>
@@ -34,4 +37,5 @@
#include <netinet/in.h>
#include <arpa/inet.h>
+#endif
#include "log.h"
- [Freeciv-Dev] MFC patches,
Andy Black <=
|
|