[wizs] boat 的 bug
今天 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)
推
08/28 08:36, , 1F
08/28 08:36, 1F
mud_sanc 近期熱門文章
PTT遊戲區 即時熱門文章
15
26