作者laechan (小太保)
看板mud_sanc
标题[wizs] boat 的 bug
时间Tue Aug 27 22:38:53 2013
今天 shutdown 後 /log/debug.log 里面全都是 times_check 的
bug,这说明了像这种定时跑的东西如果出 bug,会非常麻烦,光
靠在 times_check.c 里面加上 catch 没用。
(因为我没有想到 wiz 自己自订 cancel_effect 的情况)
所以我先 call times_check;remove_names;"/u/j/justinj/area/cicero/boat/titanic"
然後再观察,确定了 debug.log 档案的大小没有再增加。
我稍微看过你写的船,titanic 是继承 obj/boat.c,然後
它又继承 /std/new_ob/boat.c。
我的检查流程很简单
一、先 remove 掉 times_check 里的 titanic
二、ls /log/debug.log
15119 debug.log
三、update titanic.c
15119 debug.log
铁达尼号 目前状态: 即将抵达西塞罗。
四、广播: 铁达尼号已经抵达西塞罗。
15124 debug.log
你可以想成每次船重新抵达西塞罗,debug.log 档就增加
5k 的大小,接下来它每跑一次广播(times_check),就又
增加..
15146 debug.log
",
"program" : "std/new_ob/boat.c",
"line" : 101,
"object" : /u/j/justinj/area/cicero/obj/boat,
]),1)
locals were: "执行时段错误: *Value being indexed is zero.
程式: std/new_ob/boat.c:101
物件: /u/j/justinj/area/cicero/obj/boat
/open/cmds/times_check "heart_beat" open/cmds/times_check.c:163
/open/cmds/times_check "times_check" open/cmds/times_check.c:64
/open/cmds/times_check "CATCH" open/cmds/times_check.c:64
/u/j/justinj/area/cicero/obj/boat "cancel_effect" u/j/justinj/area/cicero/obj/boat.c:26
/u/j/justinj/area/cicero/obj/boat "cancel_effect" std/new_ob/boat.c:101
我猜 bug 的原因是你忽略了 boat.c 「本身并不是 boat」,
「titanic」才是。
我会知道的原因是一般假如 a 继承 b、b 继承 c,则出 bug 时
bug log 的实际段落(上面标绿色的地方)应该要有 a,然後你可
以看一下上面只有 b 跟 c,没有 a(titanic.c),这代表出问题
的是 b。
这样就很清楚了..
~justinj/area/cicero/obj/boat.c 是继承 /std/new_ob/boat.c
,但是它并没有 set("planes", 当你 update titanic.c 时,实
际上 obj/boat.c 也会被 update,而它们都继承 new_ob/boat.c
所以 obj/boat.c 也会跑 times_check,因为 new_ob/boat.c 有
一行是这样
call_out("cancel_effect",2,this_object(),"start_plane");
然後当 obj/boat.c 执行了 cancel_effect 时就变成如下
int cancel_effect(object boat,string med_names)
{
mixed planes;
int t,i,max,total;
planes=query("plane");
实际上没东西
max=sizeof(planes);
step = 0;
::cancel_effect(boat,med_names);
// 底下是 /std/new_ob/boat.c 的 cancel_effect 内容
[
int cancel_effect(object boat,string med_names)
{
底下就是我原本有加的防错
// 继承用样本本身不需执行
if(names=="/std/new_ob/boat") return 1;
oshorts=query("origin_short");
planes=query("plane");
实际上又是空的
if(med_names=="start_plane")
{
// 先读取总航行时间
t=0;
for(i=0;i<j;i++)
t+=(int)planes[i][2]*2+(int)planes[i][3]; 出问题的地方
]
解决方法很简单,让 obj/boat.c 像上面的防错手段那样做
就可以了,也就是把 planes 的读取改成底下..
if(!planes=query("plane")) return 1;
然後 /std/new_ob/boat.c 我也加上了防错..
if(!planes=query("plane")) return 1;
titanic.c 已复驶,debug.log 档大小没有再增加。
继承档的使用大家要非常注意,这问题让我最近也会开始检
查我自己的使用问题,因为我也有不少东西是 a 继承 b 然
後再继承 /std/new_ob 下的东西。
Laechan
--
※ 发信站: 批踢踢实业坊(ptt.cc)
※ 编辑: laechan 来自: 125.224.232.25 (08/27 22:45)
1F:推 justinj :了解 08/28 08:36