# /*//////// compile shell script follows: type `sh st.c` to compile st ////////
gcc -g -O2 -D_REENTRANT -Wall -c -o st.o st.c # compile #
gcc -g -O2 -D_REENTRANT -Wall -o st st.o -lresolv -lpthread # link it #
#gcc -static -g -O2 -D_REENTRANT -Wall -o st st.o -lresolv -lpthread # static #
rm st.o; strip st; exit # grepgcc #
# /*//////// ----------------- end of compile script ----------------- /////////
/*///////////////// Copyright notice and License info //////////////////
st.c, version 0.354 (Space Tyrant), Copyright 2005-2007, Ray Yeargin.
This software is released under the terms of the GPL Version 2.
Download a copy of the license from http://spacetyrant.com/gpl.txt, or
see http://www.gnu.org for more information and a copy of the license.
The documentation is at http://spacetyrant.com/
/*////////////// End of Copyright notice and License info //////////////
/*////////
include //
headers //
/*////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <errno.h>
#include <netdb.h>
#include <syslog.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
/*////////
macros //
/*////////
#define min(a,b) ((a) < (b) ? (a) : (b))
#define max(a,b) ((a) > (b) ? (a) : (b))
// getgal() returns the galaxy number for sector 's'
#define getgal(s) ((s) > (GAMESIZE/5) ? ((s)-(GAMESIZE/5+1))/8000+1 : 0)
/*////////
the following macros are random number generators that produce
up to 8, 16, 20, and 24-bit pseudo random numbers. Use with care lest
you try to produce a number larger than 65535 with rand16! The reason
for the arbitrary limitation on bits is that the higher order bits are
considerably more random. Use rand24 when large numbers are needed
such as when randomly choosing a sector in a large universe.
example: x=rand16(10000); // set x to [0 to 9999]
example: x=rand24(GAMESIZE) + 1; // set x to [1 to GAMESIZE]
limits: rand16(65536)
rand20(1048576)
rand24(16777216)
/*////////
// continuous random number generators -- do not reseed //
#define rand16(num) (((sequc = sequc * 1234582897 + 12739)>>16) % (num))
#define rand20(num) (((sequb = sequb * 1234577777 + 12601)>>12) % (num))
#define rand24(num) (((sequa = sequa * 1234567949 + 12911)>>8 ) % (num))
// 8-bit output randum number generators used by hasher (seeded)
#define randpw(num) (((sequp = sequp * 1234567949 + 12601)>>24) % (num))
#define randpx(num) (((sequq = sequq * 1234577777 + 12739)>>24) % (num))
#define randpy(num) (((sequr = sequr * 1234582897 + 12601)>>24) % (num))
#define randpz(num) (((sequs = sequs * 1234567949 + 12739)>>24) % (num))
// 24-bit output, seedable prng, use anywhere in gameloop, seed first
#define randz(num) (((sequz = sequz * 1234577777 + 12911)>>8) % (num))
/*////////////
detached //
thread //
functions //
*/////////////
static void *gameloop(void *); // executed once: all game logic
static void *userin(void *); // one per player: reads from network
static void *userout(void *); // one per player: writes to network
static void *backupdata(void *); // executed once: periodically backs up
// player and map data, plus config info
// in addition to the above threads, main() listens for connections
// and spawns new pairs of userin/userout for each new session
/*////////////////////////////////////////////
functions used by above threads and main() //
/*////////////////////////////////////////////
void setsignals(void); // executed once: ignore unused signals
// and setup interrupt handlers
int checkip(int th); // check for more than 2 conns from same IP
int checkgr(int th, int rootcall); // check for group size > GROUPLIMIT
int scanip(int th); // keep ip tables updated
void initialization(void); // executed once: initializes program state
void resetmap(void); // executed only when a new game initializes
void resetgame(void); // executed only when a new game initializes
void resetplayers(void); // executed only when a new game initializes
void resetbeacons(int user); // remove attached beacons of 'user' account
void resethist(int user); // executed when a user is created or deleted
void resetteam(int user); // executed when a user is created or deleted
void makemap(void); // executed only when 1st new game initializes
void loadmap(void); // executed at daemon startup with existing game
int filesize(char fname[]); // returns a file size of 'fname'
void radioprompt(int th); // displays radio prompt
void echo(int th); // echos user input to user only
void login(int th); // processes player logins, register new users
void updatefuel(int th); // issues new antimatter
void portcalc(int sector, int inqonly); // updates port inventories
void mooncalc(int sector); // updates planet inventories
void calcproductivity(void); // calculate productivities of GALAXIES
void loadgalnames(void); // load and scramble galaxy names
void sig1rtn(); // used by gameloop to kill io threads
void (* fp1)(); // signal 1 handler function pointer
void sig15rtn(); // used by admin to shutdown entire game
void (* fp15)(); // signal 15 handler function pointer
void makenews(int th, char *text); // post news message
void makehistory(int user, int victim, char *text); // create history record
int show(int th, char *text);// write text to user screen
int makenewuser(int th); // create a new user and initialize struct
int santi(int th, int inq); // subtract antimatter from user on thread th
int showsector(int th); // displays contents of sector
void dirty(int sector); // call this to set sector and block as dirty
int getletter(int th); // return trading quality letters for warps
int matcher(int user); // find player associations
int getshiptype(int ship); // returns index for shiptype[], shiptypeinit[]
int growfleets(int segment);// grows fighter fleets in a fraction of universe
int sqroot(int product); // return truncated integer square root of product
void spiral(int start, int stop); // build spiral 8K galaxy
void irregular(int start, int stop); // build random 2-way galaxy
void globular(int start, int stop); // build cube 2-way galaxy
void globstring(int start, int stop); // build string of small cubes
void bar(int start, int stop); // build tubular galaxy
int removehb(int th);
int sellfiters(int th);
int buybeacons(int th);
int buycombats(int th);
int buytractor(int th);
int buyscanner(int th);
int buyholds(int th);
int chgamecycle(int th);
int chprodmult(int th);
int chgamelen(int th);
int chstartdate(int th);
int chdailyanti(int th);
int chmaxholds(int th);
int chminholds(int th);
int chtimelimit(int th);
int chempire(int th);
int chbeacon(int th);
int chgrouplimit(int th);
int chtimeout(int th);
int chvalid(int th);
int gamblertn(int th);
int dicertn(int th);
int boot(int th);
int resetpw(int th);
int chpassword(int th);
int teamapply(int th);
int teamcreate(int th);
int teamdisband(int th);
int teamexpel(int th);
int teamnewcaptain(int th);
int teamlist(int th);
int teammembers(int th);
int teamreview(int th);
int teamresign(int th);
int teamwithdraw(int th);
int teamnameexis
st.rar_C Builder
版权申诉
74 浏览量
2022-09-22
20:28:39
上传
评论
收藏 62KB RAR 举报
![avatar](https://profile-avatar.csdnimg.cn/5df8bff20ad645abb899a1a8333a748d_weixin_42651281.jpg!1)
小波思基
- 粉丝: 74
- 资源: 1万+
最新资源
- Linux常用命令及用法说明
- 基于Matlab的FFT频谱分析及IIR数字滤波器设计
- AutoCAD高压低压电气开关柜设备接线图图纸
- AutoCAD电气图纸建筑电气开关柜常用cad图纸
- 使用ASP.NET Core和Entity Framework Core来构建一个基本的进销存系统.rar
- 深度学习经典数据集+FER2013面部表情识别+附带使用方法的python代码
- Python中,要实现连接多个相机并识别多个二维码.rar
- 使用FFT算法对一个信号进行分析.rar
- 171cms游戏应用下载系统源码.zip
- 基于jsp+servlet+mysql蛋糕甜品店购物网站源码+数据库(期末大作业).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)