All Data Structures Namespaces Files Functions Variables Pages
common.inc.php
Go to the documentation of this file.
<?php
//set_magic_quotes_runtime(0);
define('IN_GAME', TRUE);
define('GAME_ROOT', substr(dirname(__FILE__), 0, -7));
define('GAMENAME', 'bra');
if(PHP_VERSION < '4.3.0') {
exit('PHP version must >= 4.3.0!');
}
require GAME_ROOT.'./include/global.func.php';
error_reporting(E_ALL);
set_error_handler('gameerrorhandler');
$magic_quotes_gpc = get_magic_quotes_gpc();
extract(gstrfilter($_COOKIE));
extract(gstrfilter($_POST));
extract(gstrfilter($_GET));
//$_GET = gstrfilter($_GET);
$_REQUEST = gstrfilter($_REQUEST);
$_FILES = gstrfilter($_FILES);
require GAME_ROOT.'./config.inc.php';
//$errorinfo ? error_reporting(E_ALL) : error_reporting(0);
date_default_timezone_set('Etc/GMT');
//$now = time() + $moveutmin*60;
$now = time() + $moveut*3600 + $moveutmin*60;
list($sec,$min,$hour,$day,$month,$year,$wday) = explode(',',date("s,i,H,j,n,Y,w",$now));
//if($attackevasive) {
// include_once GAME_ROOT.'./include/security.inc.php';
//}
require GAME_ROOT.'./include/db_'.$database.'.class.php';
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
//$db->select_db($dbname);
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
require GAME_ROOT.'./gamedata/system.php';
require config('resources',$gamecfg);
require config('gamecfg',$gamecfg);
include GAME_ROOT.'./gamedata/combatinfo.php';
ob_start();
if(CURSCRIPT !== 'chat'){
//if($gzipcompress && function_exists('ob_gzhandler') && CURSCRIPT != 'wap') {
// ob_start('ob_gzhandler');
//} else {
// $gzipcompress = 0;
// ob_start();
//}
//$gamestate状态：0-上局游戏结束；10-新游戏准备阶段；20-游戏开放激活；30-游戏停止激活；40-游戏连斗；50-游戏死斗。
//$pt = getmicrotime();
$plock=fopen(GAME_ROOT.'./gamedata/process.lock','ab');
flock($plock,LOCK_EX);
load_gameinfo();
$lostfocus = false;
// $losttime = $now - $lastupdate;
// if($losttime >= $lostfocusmin * 60){
// $result = $db->query("SELECT pid FROM {$tablepre}players WHERE endtime > '$lastupdate' AND type = '0'");
// if(!$db->num_rows($result)){//满足失去焦点的判定条件
// $lostfocus = true;
// echo 'LOST FOCUS:'.$losttime;
// if($now - $afktime > $losttime){
// $afktime = $now;
// addnews();
// }
// }
// }
//include GAME_ROOT.'./gamedata/gameinfo.php';
$ginfochange = false;
// $old_gamestate = $gamestate;
// $old_areanum = $areanum;
if(!$gamestate) { //判定游戏准备
if(($starttime)&&($now > $starttime - $startmin*60)) {
$gamenum++;
$gamestate = 10;
$hdamage = 0;
$hplayer = '';
$noisemode = '';
//save_gameinfo();
include_once GAME_ROOT.'./include/system.func.php';
rs_game(1+2+4+8+16+32);
//save_gameinfo();
$ginfochange = true;
}
}
if($gamestate == 10) {//判定游戏开始
if($now >= $starttime) {
$gamestate = 20;
//save_gameinfo();
//addnews($starttime,'newgame',$gamenum);
addnews($starttime,'newgame',$gamenum);
systemputchat($starttime,'newgame');
$ginfochange = true;
}
}
//if (($gamestate > 10)&&($now > $areatime)) {
// include_once GAME_ROOT.'./include/system.func.php';
// addarea($areatime);
// save_gameinfo();
//}
//$combatinfo = file_get_contents(GAME_ROOT.'./gamedata/combatinfo.php');
//list($hdamage,$hplayer,$noisetime,$noisepls,$noiseid,$noiseid2,$noisemode) = explode(',',$combatinfo);
if (($gamestate > 10)&&($now > $areatime)) {//判定增加禁区
include_once GAME_ROOT.'./include/system.func.php';
while($now>$areatime){
$o_areatime = $areatime;
$areatime += $areahour*60;
//save_gameinfo();
add_once_area($o_areatime);
$areawarn = 0;
//save_gameinfo();
$ginfochange = true;
// testlog('禁区增加');
}
//addarea($areatime);
}elseif(($gamestate > 10)&&($now > $areatime - $areawarntime)&&(!$areawarn)){//判定警告增加禁区
include_once GAME_ROOT.'./include/system.func.php';
areawarn();
//save_gameinfo();
$ginfochange = true;
}
if($gamestate == 20) {
$arealimit = $arealimit > 0 ? $arealimit : 1;
if(($validnum <= 0)&&($areanum >= $arealimit*$areaadd)) {//判定无人参加并结束游戏
gameover($areatime-3599,'end4');
} elseif(($areanum >= $arealimit*$areaadd) || ($validnum >= $validlimit)) {//判定游戏停止激活
$gamestate = 30;
//save_gameinfo();
$ginfochange = true;
}
}
if($gamestate < 40 && $gamestate > 20 && $alivenum <= $combolimit) {//判定进入连斗条件1：停止激活时玩家数少于特定值
$gamestate = 40;
addnews($now,'combo');
systemputchat($now,'combo');
$ginfochange = true;
}elseif($gamestate < 40 && $gamestate >= 20 && $combonum && $deathnum >= $combonum){//判定进入连斗条件2：死亡人数超过特定公式计算出的值
$real_combonum = $deathlimit + ceil($validnum/$deathdeno) * $deathnume;
if($deathnum >= $real_combonum){
$gamestate = 40;
addnews($now,'combo');
systemputchat($now,'combo');
}else{
$combonum = $real_combonum;
addnews($now,'comboupdate',$combonum,$deathnum);
systemputchat($now,'comboupdate',$combonum);
}
$ginfochange = true;
}
// if((($gamestate == 30)&&($alivenum <= $combolimit))||($deathlimit&&($gamestate < 40)&&($gamestate >= 20)&&($deathnum >= $deathlimit))) {//判定进入连斗
// $gamestate = 40;
// //save_gameinfo();
// //$db->query("UPDATE {$tablepre}players SET teamID='',teamPass='' WHERE type=0 ");
// addnews($now,'combo');
// systemputchat($now,'combo');
// $ginfochange = true;
// }
if (($gamestate >= 40)&&($now > $afktime + $antiAFKertime * 60)) {//判定自动反挂机
include_once GAME_ROOT.'./include/system.func.php';
antiAFK();
$afktime = $now;
//echo 'afk';
//save_gameinfo();
$ginfochange = true;
}
if($gamestate >= 40) {
if($alivenum <= 1) {
include_once GAME_ROOT.'./include/system.func.php';
gameover();
// testlog('游戏结束');
}
}
if($ginfochange || $lostfocus){
save_gameinfo();
}
fclose($plock);
}
if (CURSCRIPT == 'botservice')
{
$cuser = $botname;
$cpass = $botpass;
}
else
{
$cuser = & ${$tablepre.'user'};
$cpass = & ${$tablepre.'pass'};
}
//function testlog($name){
// global $month,$day,$hour,$min,$sec,$old_gamestate,$gamestate,$old_areanum,$areanum,$pt;
// //$a = file_get_contents(GAME_ROOT.'./gamedata/gameinfo.php');
// $pt2 = getmicrotime();
// $nowtime = "{$month}月{$day}日{$hour}时{$min}分{$sec}秒；{$pt} {$pt2}";
// $a = "{$nowtime}\n {$name}\n 『旧游戏状态:{$old_gamestate}；新游戏状态:{$gamestate}』\n 『旧禁区数目:{$old_areanum}；新禁区数目:{$areanum}』\n\n";
// $filec = file_get_contents(GAME_ROOT.'./log.txt');
// $a = $a.$filec;
// file_put_contents(GAME_ROOT.'./log.txt',$a);
// return;
//}
?>
$_REQUEST
$_REQUEST
Definition: common.inc.php:20
$hplayer
$hplayer
Definition: combatinfo.php:6
$tablepre
$tablepre
Definition: config.inc.php:58
$areawarntime
$areawarntime
Definition: gamecfg_1.php:9
systemputchat
systemputchat($time, $type, $msg= '')
Definition: global.func.php:454
GAME_ROOT
const GAME_ROOT
Definition: common.inc.php:6
$database
$database
Definition: config.inc.php:67
$gamecfg
$gamecfg
Definition: system.php:22
$areanum
$areanum
Definition: gameinfo.php:9
$hdamage
if(!defined('IN_GAME')) $hdamage
Definition: combatinfo.php:5
$validnum
$validnum
Definition: gameinfo.php:13
$validlimit
$validlimit
Definition: gamecfg_1.php:44
$deathdeno
$deathdeno
Definition: gamecfg_1.php:50
$arealimit
$arealimit
Definition: gamecfg_1.php:11
$moveutmin
$moveutmin
Definition: config.inc.php:52
$magic_quotes_gpc
$magic_quotes_gpc
Definition: common.inc.php:15
$dbpw
$dbpw
Definition: config.inc.php:12
areawarn
areawarn()
Definition: system.func.php:360
gstrfilter
gstrfilter($str)
Definition: global.func.php:48
gameover
gameover($time=0, $mode= '', $winname= '')
Definition: system.func.php:388
$noisemode
$noisemode
Definition: combatinfo.php:11
addnews
addnews($t=0, $n= '', $a='', $b='', $c= '', $d= '', $e= '')
Definition: global.func.php:228
dbstuff
Definition: db_mysql.class.php:7
$antiAFKertime
$antiAFKertime
Definition: gamecfg_1.php:24
$moveut
$moveut
Definition: config.inc.php:49
$combolimit
$combolimit
Definition: gamecfg_1.php:46
$deathnum
$deathnum
Definition: gameinfo.php:15
elseif
【生存者数：<?php echo $alivenum?> 人】< input type="button"value="显示全部幸存者"onClick="$('alivemode').value='all';$('gbmode').value='none';postCmd('alive','alive.php');"></p > if($gamblingon &&$gamestate >=20) elseif($gamblingon &&$gamestate<=10)
Definition: 1_alive.tpl.php:18
add_once_area
add_once_area($atime)
Definition: system.func.php:273
$alivenum
$alivenum
Definition: gameinfo.php:14
rs_game
if(!defined('IN_GAME')) rs_game($mode=0)
Definition: system.func.php:7
load_gameinfo
load_gameinfo()
Definition: global.func.php:276
$deathnume
$deathnume
Definition: gamecfg_1.php:52
antiAFK
antiAFK($timelimit=0)
Definition: system.func.php:632
$db
$db
Definition: common.inc.php:39
$gamestate
$gamestate
Definition: gameinfo.php:4
CURSCRIPT
const CURSCRIPT
Definition: admin.php:3
config
config($file= '', $cfg=1)
Definition: global.func.php:122
$startmin
$startmin
Definition: system.php:20
$dbhost
$dbhost
Definition: config.inc.php:6
$deathlimit
$deathlimit
Definition: gamecfg_1.php:48
$gamenum
$gamenum
Definition: gameinfo.php:3
$dbuser
$dbuser
Definition: config.inc.php:9
$areahour
$areahour
Definition: gamecfg_1.php:5
$now
$now
Definition: common.inc.php:30
$pconnect
$pconnect
Definition: config.inc.php:40
$areatime
$areatime
Definition: gameinfo.php:10
$dbname
$dbname
Definition: config.inc.php:15
$starttime
$starttime
Definition: gameinfo.php:5
$cpass
$cpass
Definition: common.inc.php:207
$areaadd
$areaadd
Definition: gamecfg_1.php:7
$_FILES
$_FILES
Definition: common.inc.php:21
save_gameinfo
save_gameinfo()
Definition: global.func.php:304