Commit 1715fd24 authored by Nemo Ma's avatar Nemo Ma Committed by GitHub

Merge pull request #106 from hikawiier/waaagh

update roommng
parents 3d9f048d aade25b9
...@@ -19,6 +19,7 @@ $admin_cmd_list = Array( ...@@ -19,6 +19,7 @@ $admin_cmd_list = Array(
'pcmng' => 5, 'pcmng' => 5,
'npcmng' => 5, 'npcmng' => 5,
'gameinfomng' => 5, 'gameinfomng' => 5,
'roommng' => 5,
'antiAFKmng' => 4, 'antiAFKmng' => 4,
'templates_clean' => 4, 'templates_clean' => 4,
); );
......
...@@ -192,18 +192,6 @@ if(!$db->num_rows($result)) ...@@ -192,18 +192,6 @@ if(!$db->num_rows($result))
$db->query("ALTER TABLE {$gtablepre}game ADD noisevars varchar(1000) NOT NULL DEFAULT '' AFTER gamevars"); $db->query("ALTER TABLE {$gtablepre}game ADD noisevars varchar(1000) NOT NULL DEFAULT '' AFTER gamevars");
echo "向game表中添加了字段noisevars<br>"; echo "向game表中添加了字段noisevars<br>";
} }
$result = $db->query("DESCRIBE {$gtablepre}game groomid");
if(!$db->num_rows($result))
{
$db->query("ALTER TABLE {$gtablepre}game ADD groomid tinyint(3) unsigned NOT NULL DEFAULT '0' '' AFTER gamestate");
echo "向game表中添加了字段groomid<br>";
}
$result = $db->query("DESCRIBE {$gtablepre}game groomnums");
if(!$db->num_rows($result))
{
$db->query("ALTER TABLE {$gtablepre}game ADD groomnums tinyint(3) unsigned NOT NULL DEFAULT '0' AFTER groomid");
echo "向game表中添加了字段groomnums<br>";
}
echo "Update Fish.<br>"; echo "Update Fish.<br>";
?> ?>
\ No newline at end of file
...@@ -76,7 +76,6 @@ table.dialogue { ...@@ -76,7 +76,6 @@ table.dialogue {
} }
table.infotable { table.infotable {
float: left;
margin-top: 10px; margin-top: 10px;
position:relative; position:relative;
text-align: center; text-align: center;
...@@ -85,7 +84,6 @@ table.infotable { ...@@ -85,7 +84,6 @@ table.infotable {
} }
table.infotable td, table.infotable td,
table.infotable th { table.infotable th {
text-align: center;
border:1px solid rgba(225, 124, 226, 0.4); border:1px solid rgba(225, 124, 226, 0.4);
} }
......
...@@ -255,6 +255,8 @@ $lang = array ...@@ -255,6 +255,8 @@ $lang = array
'gamecheck_comment' => '修正游戏人数异常和移动下拉框消失的功能', 'gamecheck_comment' => '修正游戏人数异常和移动下拉框消失的功能',
'templates_clean' => '清空模板缓存', 'templates_clean' => '清空模板缓存',
'templates_clean_comment' => '清空已生成的模板缓存文件', 'templates_clean_comment' => '清空已生成的模板缓存文件',
'roommng' => '临时性房间管理',
'roommng_comment' => '强制关闭指定编号的房间<br>不能关闭0号大房间(临时功能)',
'pcmng' => '玩家数据管理', 'pcmng' => '玩家数据管理',
'pcmng_comment' => '修改当前局玩家的各数值,不影响帐号', 'pcmng_comment' => '修改当前局玩家的各数值,不影响帐号',
......
<?php
if(!defined('IN_ADMIN')) {
exit('Access Denied');
}
if($command == 'killroom')
{
roommng_close_room($roomkey,1);
$command = '';
}
echo <<<EOT
<form method="post" name="roommng" onsubmit="admin.php">
<input type="hidden" name="mode" value="roommng">
<input type="hidden" name="command" value="killroom">
强制关闭<input type="number" name="roomkey" value=1 min="1" max="{$max_rooms}">号房间<br>
<input type="submit" value="关闭"><br>
</form>
EOT;
?>
\ No newline at end of file
...@@ -10,10 +10,6 @@ if(version_compare(PHP_VERSION, '4.3.0', '<')) { ...@@ -10,10 +10,6 @@ if(version_compare(PHP_VERSION, '4.3.0', '<')) {
exit('PHP version must >= 4.3.0!'); exit('PHP version must >= 4.3.0!');
} }
require GAME_ROOT.'./include/global.func.php'; require GAME_ROOT.'./include/global.func.php';
require GAME_ROOT.'./include/init.func.php';
require GAME_ROOT.'./include/resources.func.php';
require GAME_ROOT.'./include/game/revclubskills.func.php';
require GAME_ROOT.'./include/game/dice.func.php';
error_reporting(E_ALL); error_reporting(E_ALL);
set_error_handler('gameerrorhandler'); set_error_handler('gameerrorhandler');
$magic_quotes_gpc = false; $magic_quotes_gpc = false;
...@@ -46,6 +42,11 @@ $db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect); ...@@ -46,6 +42,11 @@ $db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect); unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
require GAME_ROOT.'./gamedata/system.php'; require GAME_ROOT.'./gamedata/system.php';
require GAME_ROOT.'./include/init.func.php';
require GAME_ROOT.'./include/resources.func.php';
require GAME_ROOT.'./include/roommng.func.php';
require GAME_ROOT.'./include/game/revclubskills.func.php';
require GAME_ROOT.'./include/game/dice.func.php';
require config('resources',$gamecfg); require config('resources',$gamecfg);
require config('gamecfg',$gamecfg); require config('gamecfg',$gamecfg);
require config('combatcfg',$gamecfg); require config('combatcfg',$gamecfg);
...@@ -55,25 +56,19 @@ require config('audio',$gamecfg); ...@@ -55,25 +56,19 @@ require config('audio',$gamecfg);
require config('tooltip',$gamecfg); require config('tooltip',$gamecfg);
$gtablepre = $tablepre; $gtablepre = $tablepre;
# 检查game表是否需要补缺
roommng_verify_db_game_structure();
ob_start(); ob_start();
$cuser = & ${$tablepre.'user'}; $cuser = & ${$gtablepre.'user'};
$cpass = & ${$tablepre.'pass'}; $cpass = & ${$gtablepre.'pass'};
$roomlist = Array(); $roomlist = Array();
$result = $db->query("SELECT * FROM {$gtablepre}game WHERE groomid>0"); $result = $db->query("SELECT * FROM {$gtablepre}game WHERE groomid>0");
while($roominfo = $db->fetch_array($result)) while($roominfo = $db->fetch_array($result))
{ {
# 房间内没有人时自动关闭房间 $roomlist[$roominfo['groomid']] = $roominfo;
if(!$roominfo['groomnums'])
{
$db->query("DELETE FROM {$gtablepre}game WHERE groomid = {$roominfo['groomid']}");
}
else
{
$roomlist[$roominfo['groomid']] = $roominfo;
}
} }
if($cuser) if($cuser)
...@@ -81,7 +76,6 @@ if($cuser) ...@@ -81,7 +76,6 @@ if($cuser)
$tr = $db->query("SELECT * FROM {$gtablepre}users WHERE username='$cuser'"); $tr = $db->query("SELECT * FROM {$gtablepre}users WHERE username='$cuser'");
$tp = $db->fetch_array($tr); $tp = $db->fetch_array($tr);
} }
$rid = isset($tp['roomid']) ? $tp['roomid'] : 0; $rid = isset($tp['roomid']) ? $tp['roomid'] : 0;
$groomid = $rid; $groomid = $rid;
...@@ -91,7 +85,7 @@ if(!empty($rid)) ...@@ -91,7 +85,7 @@ if(!empty($rid))
if(!$db->num_rows($result)) if(!$db->num_rows($result))
{ {
$gr = $db->query("SELECT gamenum FROM {$gtablepre}game WHERE groomid=0"); $gr = $db->query("SELECT gamenum FROM {$gtablepre}game WHERE groomid=0");
$gnums = $db->fetch_array($gr)[0] + $rid; $gnums = $db->result($result, 0) + $rid;
$starttime = $now + $startmin*5; $starttime = $now + $startmin*5;
$db->query("INSERT INTO {$gtablepre}game (gamenum,groomid,groomnums,gamestate,starttime) VALUES ('$gnums','$rid','1','0','$starttime')"); $db->query("INSERT INTO {$gtablepre}game (gamenum,groomid,groomnums,gamestate,starttime) VALUES ('$gnums','$rid','1','0','$starttime')");
} }
......
...@@ -4,6 +4,67 @@ if(!defined('IN_GAME')) { ...@@ -4,6 +4,67 @@ if(!defined('IN_GAME')) {
exit('Access Denied'); exit('Access Denied');
} }
function roommng_verify_db_game_structure()
{
global $db,$gtablepre;
$result = $db->query("DESCRIBE {$gtablepre}users roomid");
if(!$db->num_rows($result))
{
$db->query("ALTER TABLE {$gtablepre}users ADD roomid tinyint(3) unsigned NOT NULL DEFAULT '0' AFTER groupid");
echo "向users表中添加了字段roomid<br>";
}
$result = $db->query("DESCRIBE {$gtablepre}game groomid");
if(!$db->num_rows($result))
{
$db->query("ALTER TABLE {$gtablepre}game ADD groomid tinyint(3) unsigned NOT NULL DEFAULT '0' '' AFTER gamestate");
echo "向game表中添加了字段groomid<br>";
}
$result = $db->query("DESCRIBE {$gtablepre}game groomnums");
if(!$db->num_rows($result))
{
$db->query("ALTER TABLE {$gtablepre}game ADD groomnums tinyint(3) unsigned NOT NULL DEFAULT '0' AFTER groomid");
echo "向game表中添加了字段groomnums<br>";
}
$result = $db->query("SHOW INDEX FROM {$gtablepre}game");
$gr = $db->fetch_array($result);
if($gr['Column_name'] != 'groomid')
{
$db->query("ALTER TABLE`{$gtablepre}game` DROP PRIMARY KEY");
$db->query("ALTER TABLE`{$gtablepre}game` ADD PRIMARY KEY (`groomid`)");
echo "将game表的索引变更为groomid<br>";
}
return;
}
function roommng_close_room($rkey,$log_print=0)
{
global $db,$gtablepre;
if(!$rkey)
{
echo "不能关闭大房间!<br>";
return;
}
$result = $db->query("SELECT * FROM {$gtablepre}game WHERE groomid='$rkey'");
if($db->num_rows($result))
{
$gdata = $db->fetch_array($result);
# 清空房间内玩家
if($gdata['groomnums']) $db->query("UPDATE {$gtablepre}users SET roomid = 0 WHERE roomid= {$rkey}");
# 关闭房间
$db->query("DELETE FROM {$gtablepre}game WHERE groomid = {$rkey}");
if($log_print) echo "已关闭房间 {$rkey} 号<br>";
}
else
{
if($log_print) echo "房间 {$rkey} 未开启,或房间不存在!<br>";
}
}
?> ?>
...@@ -272,8 +272,9 @@ function rs_game($mode = 0) { ...@@ -272,8 +272,9 @@ function rs_game($mode = 0) {
$qry = ''; $qry = '';
foreach($shoplist as $lst){ foreach($shoplist as $lst){
if(!empty($lst) && strpos($lst,',')!==false){ if(!empty($lst) && strpos($lst,',')!==false){
$lst = explode(',',$lst);
if(empty($lst[8])) $lst[8] = ''; if(empty($lst[8])) $lst[8] = '';
list($kind,$num,$price,$area,$item,$itmk,$itme,$itms,$itmsk)=explode(',',$lst); list($kind,$num,$price,$area,$item,$itmk,$itme,$itms,$itmsk)=$lst;
if($kind != 0){ if($kind != 0){
$qry .= "('$kind','$num','$price','$area','$item','$itmk','$itme','$itms','$itmsk'),"; $qry .= "('$kind','$num','$price','$area','$item','$itmk','$itme','$itms','$itmsk'),";
} }
......
...@@ -55,10 +55,18 @@ if(!empty($roomact)) ...@@ -55,10 +55,18 @@ if(!empty($roomact))
if(empty($udata['roomid'])) gexit('你没有在任何房间里!', __file__, __line__); if(empty($udata['roomid'])) gexit('你没有在任何房间里!', __file__, __line__);
$result = $db->query("SELECT groomnums FROM {$gtablepre}game WHERE groomid = {$udata['roomid']}"); $result = $db->query("SELECT groomnums FROM {$gtablepre}game WHERE groomid = {$udata['roomid']}");
if($db->num_rows($result)) if($db->num_rows($result))
{ {
$join_nums = $db->result($result, 0); $join_nums = $db->result($result, 0);
$join_nums--; $join_nums--;
$db->query("UPDATE {$gtablepre}game SET groomnums = {$join_nums} WHERE groomid = {$udata['roomid']}"); # 退出房间时,检查是关闭房间还是减少房间内人数
if($join_nums > 0)
{
$db->query("UPDATE {$gtablepre}game SET groomnums = {$join_nums} WHERE groomid = {$udata['roomid']}");
}
else
{
roommng_close_room($udata['roomid']);
}
} }
$db->query("UPDATE {$gtablepre}users SET roomid = 0 WHERE username='$cuser'"); $db->query("UPDATE {$gtablepre}users SET roomid = 0 WHERE username='$cuser'");
unset($roomact); unset($roomact);
......
...@@ -91,6 +91,11 @@ ...@@ -91,6 +91,11 @@
<td>$lang['templates_clean_comment']</td> <td>$lang['templates_clean_comment']</td>
<td>$admin_cmd_list['templates_clean']</td> <td>$admin_cmd_list['templates_clean']</td>
</tr> </tr>
<tr height="45px">
<td><input type="submit" style="width:100;height:40;" value="$lang['roommng']" onclick="$('command').value='roommng'" <!--{if $mygroup < $admin_cmd_list['roommng']}-->disabled="true"<!--{/if}-->></td>
<td>$lang['roommng_comment']</td>
<td>$admin_cmd_list['roommng']</td>
</tr>
</table> </table>
</td> </td>
</tr> </tr>
......
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
</span> </span>
<br> <br>
<span class="evergreen"> <span class="evergreen">
<span class="evergreen">当前房间列表:
<input type="button" value="点击查看房间列表" onclick="showModalDialog($('roomlist'));">
<div style="height:5px;">&nbsp;</div>
{template roomlist} {template roomlist}
</span> </span>
</td> </td>
......
...@@ -27,6 +27,14 @@ ...@@ -27,6 +27,14 @@
<!--{/if}--> <!--{/if}-->
<!--{elseif $itemcmd == 'elementmix'}--> <!--{elseif $itemcmd == 'elementmix'}-->
<style> <style>
table.infotable {
float: left;
margin-top: 10px;
position:relative;
text-align: center;
border-radius: 3px;
border:2px solid rgba(225, 124, 226, 0.25);
}
table.infotable th { table.infotable th {
width: 55px; width: 55px;
text-align: center; text-align: center;
......
<span class="evergreen">当前房间列表:<br>(房间状态更新可能存在延迟,如果发现房间状态不对请刷新几次)</span><br> <dialog id="roomlist" style="max-width: 90%;max-height: 80%; text-align: left;">
<span class="evergreen">当前房间列表:<br><span class="grey">房间状态更新可能存在延迟<br>如果发现房间状态不对请刷新几次</span></span><br>
<div style="height:5px;">&nbsp;</div> <div style="height:5px;">&nbsp;</div>
<form method="post" name="roomact" onsubmit="return false;" > <form method="post" name="roomact" onsubmit="return false;" >
<input type="hidden" name="roomact" id="roomact" value=""> <input type="hidden" name="roomact" id="roomact" value="">
<div class="scroll-pane-roomlist" style="width:520px;max-height:300px;">
<table CellSpacing=0 CellPadding=0 class="infotable"> <table CellSpacing=0 CellPadding=0 class="infotable">
<tr> <tr>
<td class="b1" width="60px">编号</td> <td class="b1" width="60px">编号</td>
...@@ -52,6 +51,6 @@ ...@@ -52,6 +51,6 @@
</tr> </tr>
<!--{/loop}--> <!--{/loop}-->
</table> </table>
</div>
</form> </form>
<div style="height:5px;">&nbsp;</div> <img class="dialog-background" src="img/profile.gif" onclick="closeDialog($('roomlist'))">
\ No newline at end of file </dialog>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment