本帖最后由 清杨子 于 2009-11-28 19:25 编辑
原牧场已修复因点击我的农场图标导致可以继续购买动物的BUG。但不是很完美,仍有问题,有1个棚1个窝,本应做多养6只动物,却可以养7只动物。
现已解决此问题,因各版本不同,顾只放出相关修改代码。
修改原理为,通过判断提交购买动物的窝棚属性,结合实际窝棚数量以及窝棚各自可养动物数量,确定是否超过限制。原通过级别确定动物数量的方法注释不用。
修改方法:
1.搜索newmc.php文件中- if ( $_REQUEST['mod'] == "cgi_buy_animal" )
复制代码 2.将原限制购买动物的代码修改为- //限制越级购买动物
- $Got_numw = 0;
- $Got_nump = 0;
- foreach ( $animal[animal] as $key => $value )
- {
- if($value->cId != 0)
- {
- if($value->cId>1500)
- {
- $Got_nump++;
- }
- else
- {
- $Got_numw++;
- }
- }
- //$value->cId != 0 && $Got_num++;
- }
- $limit_p = ($animal["item3"]-10330)*3;
- $limit_w = ($animal["item2"]-10220)*3;
- if($_REQUEST['cId']>1500)
- {
- ( $Got_nump + $_REQUEST['number'] ) >$limit_p &&exit("{"errorContent":"\\u5BF9\\u4E0D\\u8D77\\uFF0C\\u60A8\\u5F53\\u524D\\u7684\\u7B49\\u7EA7\\u6700\\u591A\\u80FD\\u9972\\u517B" . $limit_p . "\\u53EA\\u52A8\\u7269\\u3002\\uFF08\\u5DF2\\u9972\\u517B" . $Got_nump . "\\u53EA\\uFF09","errorType":"1011"}");
- }
- else
- {
- ( $Got_numw + $_REQUEST['number'] ) >$limit_w &&exit("{"errorContent":"\\u5BF9\\u4E0D\\u8D77\\uFF0C\\u60A8\\u5F53\\u524D\\u7684\\u7B49\\u7EA7\\u6700\\u591A\\u80FD\\u9972\\u517B" . $limit_w . "\\u53EA\\u52A8\\u7269\\u3002\\uFF08\\u5DF2\\u9972\\u517B" . $Got_numw . "\\u53EA\\uFF09","errorType":"1011"}");
- }
-
-
- $grade = intval(sqrt( ($list[0][mc_exp] + 25)/100 ) - 0.5);
- // $grade_animal = grade_animal( $grade );
- // ( $Got_num + $_REQUEST['number'] ) > $grade_animal && exit("{"errorContent":"\\u5BF9\\u4E0D\\u8D77\\uFF0C\\u60A8\\u5F53\\u524D\\u7684\\u7B49\\u7EA7\\u6700\\u591A\\u80FD\\u9972\\u517B" . $grade_animal . "\\u53EA\\u52A8\\u7269\\u3002\\uFF08\\u5DF2\\u9972\\u517B" . $Got_num . "\\u53EA\\uFF09","errorType":"1011"}");
- intval($shop[$_REQUEST['cId']][cLevel]) > $grade && exit("{"errorContent":"\\u4E0D\\u80FD\\u8D8A\\u7EA7\\u9886\\u517B\\u52A8\\u7269\\uFF01","errorType":"1011"}");
- //限制越级购买动物
复制代码 3.整个购买动物的过程为- if ( $_REQUEST['mod'] == "cgi_buy_animal" )
- {
- $query = $_SGLOBAL['db']->query( "SELECT money,animal,mc_exp FROM ".tname( "plug_newfarm" )." where uid=".$_SGLOBAL['supe_uid'] );
- while ( $value = $_SGLOBAL['db']->fetch_array( $query ) )
- {
- $list[] = $value;
- }
- $animal = ( array )json_decode( $list[0][animal] );
- if ( $list[0][money] < $shop[$_REQUEST['cId']][price] * $_REQUEST['number'] )
- {
- exit( );
- }
- //限制越级购买动物
- $Got_numw = 0;
- $Got_nump = 0;
- foreach ( $animal[animal] as $key => $value )
- {
- if($value->cId != 0)
- {
- if($value->cId>1500)
- {
- $Got_nump++;
- }
- else
- {
- $Got_numw++;
- }
- }
- //$value->cId != 0 && $Got_num++;
- }
- $limit_p = ($animal["item3"]-10330)*3;
- $limit_w = ($animal["item2"]-10220)*3;
- if($_REQUEST['cId']>1500)
- {
- ( $Got_nump + $_REQUEST['number'] ) >$limit_p &&exit("{"errorContent":"\\u5BF9\\u4E0D\\u8D77\\uFF0C\\u60A8\\u5F53\\u524D\\u7684\\u7B49\\u7EA7\\u6700\\u591A\\u80FD\\u9972\\u517B" . $limit_p . "\\u53EA\\u52A8\\u7269\\u3002\\uFF08\\u5DF2\\u9972\\u517B" . $Got_nump . "\\u53EA\\uFF09","errorType":"1011"}");
- }
- else
- {
- ( $Got_numw + $_REQUEST['number'] ) >$limit_w &&exit("{"errorContent":"\\u5BF9\\u4E0D\\u8D77\\uFF0C\\u60A8\\u5F53\\u524D\\u7684\\u7B49\\u7EA7\\u6700\\u591A\\u80FD\\u9972\\u517B" . $limit_w . "\\u53EA\\u52A8\\u7269\\u3002\\uFF08\\u5DF2\\u9972\\u517B" . $Got_numw . "\\u53EA\\uFF09","errorType":"1011"}");
- }
-
-
- $grade = intval(sqrt( ($list[0][mc_exp] + 25)/100 ) - 0.5);
- // $grade_animal = grade_animal( $grade );
- // ( $Got_num + $_REQUEST['number'] ) > $grade_animal && exit("{"errorContent":"\\u5BF9\\u4E0D\\u8D77\\uFF0C\\u60A8\\u5F53\\u524D\\u7684\\u7B49\\u7EA7\\u6700\\u591A\\u80FD\\u9972\\u517B" . $grade_animal . "\\u53EA\\u52A8\\u7269\\u3002\\uFF08\\u5DF2\\u9972\\u517B" . $Got_num . "\\u53EA\\uFF09","errorType":"1011"}");
- intval($shop[$_REQUEST['cId']][cLevel]) > $grade && exit("{"errorContent":"\\u4E0D\\u80FD\\u8D8A\\u7EA7\\u9886\\u517B\\u52A8\\u7269\\uFF01","errorType":"1011"}");
- //限制越级购买动物
- $number = 0;
- foreach ( $animal[animal] as $key => $value )
- {
- if ( ( $value->cId == 0 ) && ( $number < $_REQUEST['number'] ) )
- {
- $value->buyTime = $_SGLOBAL['timestamp'];
- $value->cId = $_REQUEST['cId'];
- $value->tou = "";
- ++$number;
- $buyanimal[] = ( ( "{"buyTime":".$_SGLOBAL['timestamp'].","cId":".$_REQUEST['cId'].","createTime":0,"feedTime":".( $_SGLOBAL['timestamp'] - 14400 ) ).","growTime":0,"growTimeNext":".( $animaltime[$_REQUEST['cId']][0] - 1 ) ).","postTime":0,"productNum":0,"serial":".$key.","status":1,"statusNext":2,"totalCome":0}";
- }
- }
- $animal = json_encode( $animal );
- $animal = str_replace( ""{", "{", $animal );
- $animal = str_replace( "}"", "}", $animal );
- $_SGLOBAL['db']->query( ( "UPDATE ".tname( "plug_newfarm" )." set animal='".$animal."',money=money-".$shop[$_REQUEST['cId']][price] * $_REQUEST['number'].",mc_exp=mc_exp+".$_REQUEST['number'] * 5 )." where uid=".$_SGLOBAL['supe_uid'] );
- $buyanimal = json_encode( $buyanimal );
- $buyanimal = str_replace( ""{", "{", $buyanimal );
- $buyanimal = str_replace( "}"", "}", $buyanimal );
- echo stripslashes( ( "{"addExp":".$_REQUEST['number'] * 5 ).","animal":".$buyanimal.","code":0,"money":".$shop[$_REQUEST['cId']][price] * $_REQUEST['number'].","msg":"success","num":".$_REQUEST['number'].","uin":""}" );
- exit( );
- }
复制代码 |