ID:903818
 
(See the best response by LordAndrew.)

runtime error: bad del
proc name: Instant Transmission (/mob/learn/verb/Instant_Transmission)
source file: Instant Transmittion2.dm,108
Undefined variable /obj/x10_kame/var/insz
proc name: Exited (/turf/Floors/Safe_Zone/Exited)
source file: Floors.dm,132
runtime error: undefined variable /obj/x10_kame/var/e_db_1
proc name: Entered (/turf/Floors/Safe_Zone/Entered)
source file: Floors.dm,120
Undefined variable /obj/x10_kame/var/insz
Warning: further proc crash messages are being suppressed to prevent overload...
Undefined variable /obj/Distructo_Disk/var/insz
Undefined variable /obj/Distructo_Disk/var/insz
Undefined variable /obj/Distructo_Disk/var/insz
Undefined variable /obj/Distructo_Disk/var/insz


Problem description:Alright, before I begin, I know what variables are and how they work in the code. I've also fixed other runtime errors, but I can't seem to get to the bottom of this one. When I run the game, its working perfectly fine and all for hours sometimes (it actually stayed up running all night yesterday), but sometimes theres a huge lag spike and the server crashes. Within minutes the server is back up. At first we(our team) blamed it on the server, which is Virpus, because the VPS was also offline when the major hour long crashes happened. But it got progressively worse since the last update, so i decided to check the game logs. Theres A LOT of the "Undefined variable /obj/[different object names]/var/insz, and quite a few "proc name:Entered/Exited". While reading through the entire log, I found only one line that says, "Warning: further proc crash messages are being suppressed to prevent overload...". Now I am led to believe that the server crashing has to do with runtime errors. Any ideas on what I can do to fix this? Any help will be greatly appreciated. Thank you.

        Entered(mob/PC/M)
if(M.e_db_1==1||M.e_db_2==1||M.e_db_3==1||M.e_db_4==1||M.e_db_5==1||M.e_db_6==1||M.e_db_7==1)
M<<"<font color=red><b>You are being punished for attempting to bring dragonballs into the SZ!</font color></b>"
world<<"<font size = 3><font color = red><b>[M] has been Automatically Bitch Slapped for attempting to bring dragonballs into the SZ!"
AutoBS(M)
if(M.buku)
M.buku = 0
M.density = 1
M.doing = 0
M.icon_state = ""
return
M.insz=1
Exited(mob/PC/M)
M.insz=0


mob/var/insz=0



(And Ill include the whole Instant Transmission since its marking it as another runtime error)

mob/var/it_blocked = 0
var/list/This_is_what_i_did = list()
mob/var/itable = 0


mob/learn
verb
Instant_Transmission()
set category = "Techniques"
set name = "Instant Transmission"
if(src.doing)
src << "You are already doing something!"
return
if(src.dead)
src << "You are dead."
return
if(src.buku)
return

if(src.dead)
return

if(src.bslapped)
return

if(src.it_lock)
src << "Cannot use this Technique at his time"
return

if(src.ki_lock)
src << "Cannot use this Technique at his time"
return
var/list/ITMenu = list()
var/list/NITMenu = list()
for(var/mob/M in world)
if(!M.client) continue
if(M.name != usr.name)
ITMenu.Add(M)
for(var/mob/N in world)
if(N.itable == 1)
NITMenu.Add(N)
switch(alert("Who would you like to IT to?","Instant Transmission","NPCs","Players","Cancel"))
if("NPCs")
var/mob/N = input("Which NPC would you like to IT to?", "",text) as null | anything in NITMenu
if(!N)return
if(istype(N,/mob/NPC))
if(usr.it_lock == 0)
if(usr.dead == 0)
if(usr.e_db_1==1||usr.e_db_2==1||usr.e_db_3==1||usr.e_db_4==1||usr.e_db_5==1||usr.e_db_6==1||usr.e_db_7==1)
if(!(N.z==1))
usr<<"<font color=red><b>You cannot IT outside the planet with the dragonballs!</font color></b>!"
return
if(N.insz==1)
usr<<"<font color=red><b>You cannot IT to someone that is in the safe zone</font color></b>!"
return
if(usr.n_db_1==1||usr.n_db_2==1||usr.n_db_3==1||usr.n_db_4==1||usr.n_db_5==1||usr.n_db_6==1||usr.n_db_7==1)
if(!(N.z==2))
usr<<"<font color=red><b>You cannot IT outside the planet with the dragonballs!</font color></b>!"
return
usr.icon_state = "IT"
sleep(6)
usr.icon_state = ""
usr.x = N:x
usr.y = N:y-1
usr.z = N:z
usr.icon_state = "IT"
sleep(6)
usr.icon_state = ""
else
return
if("Players")
var/mob/M = input("Who would you like to IT to?","Instant Transmission",text) as null | anything in ITMenu
if(!M) return
if(istype(M,/mob))
if(M.it_lock == 0)
if(usr.it_lock == 0)
if(usr.dead == 0)
if(M.dead == 0)
if(!M.GMLevel)
if(!M.it_blocked)
if(M.z==11 || M.z==12 || M.z==9 || M.z==3 || M.z==15)
src << "You cannot seem to get a clear lock on [M]'s energy signal..."
return
if(M.powerlevel<=M.powerlevel_max/10)
src << "You cannot seem to get a clear lock on [M]'s energy signal..."
return
if(usr.e_db_1==1||usr.e_db_2==1||usr.e_db_3==1||usr.e_db_4==1||usr.e_db_5==1||usr.e_db_6==1||usr.e_db_7==1)
if(!(M.z==1))
usr<<"<font color=red><b>You cannot IT outside the planet with the dragonballs!</font color></b>"
return
if(M.insz==1)
usr<<"<font color=red><b>You cannot IT to someone that is in the safe zone!</font color></b>"
return
if(usr.n_db_1==1||usr.n_db_2==1||usr.n_db_3==1||usr.n_db_4==1||usr.n_db_5==1||usr.n_db_6==1||usr.n_db_7==1)
if(!(M.z==2))
usr<<"<font color=red><b>You cannot IT outside the planet with the dragonballs!</font color></b>"
return
usr.icon_state = "IT"
sleep(6)
usr.icon_state = ""
usr.x = M:x
usr.y = M:y-1
usr.z = M:z
view(6) << "<font size=1><B>[usr.name] appears from nowhere!"
usr.icon_state = "IT"
sleep(6)
usr.icon_state = ""
del(M in ITMenu)
return
else
return
if(M.GMLevel >= 1)
src << "You cannot seem to get a clear lock on [M]'s energy signal..."
return
if("Cancel")
return


Best response
Don't use Zeta's God awful source code. That'd probably fix all of your issues.
Lmao, This is what I got when I got offered the code for that particular DBZ game. So I am just working with what I have /: I am working on my own personal projects from scratch though...Don't like Zeta either xD
But seriously...Can I get some help here? /:
Your first problem is that you're assuming everything being passed to Entered()/Exited() is your player mob. Any movable atom may be passed to those processes (as any movable atom may walk onto a turf). You need to use istype() to check that it really is the type you think it is before trying to access type-specific variables.

The second problem is because of completely invalid syntax. It's like someone's just making up code and then forgot to check if it actually worked:
del(M in ITMenu)

I'm not even sure why you would bother to (presumably) remove 'M' from the ITMenu list, as the verb returns right after that anyways.
I see. The second problem I had noticed, but I wasn't completely sure... But that seems to work out.

As for the first problem,

    Safe_Zone
density = 0
Entered(var/obj/O)
if(istype(O,/obj/Kamehameha/))
del(O)
if(istype(O,/obj/Distructo_Disk/))
del(O)
if(istype(O,/obj/Fat_Wrap/))
del(O)
Entered(mob/PC/M)
if(M.e_db_1==1||M.e_db_2==1||M.e_db_3==1||M.e_db_4==1||M.e_db_5==1||M.e_db_6==1||M.e_db_7==1)
M<<"<font color=red><b>You are being punished for attempting to bring dragonballs into the SZ!</font color></b>"
world<<"<font size = 3><font color = red><b>[M] has been Automatically Bitch Slapped for attempting to bring dragonballs into the SZ!"
AutoBS(M)
if(M.buku)
M.buku = 0
M.density = 1
M.doing = 0
M.icon_state = ""
return
M.insz=1
Exited(mob/PC/M)
M.insz=0


(Just adding the whole turf code for referencing.)

Would I have to go at it like this:

Entered()
istype(M,/mob/PC)
if(M.e_db_1 == 1 .......)
.....


OR

Entered()
if(istype(M,/mob/PC))
.......

?

I apologize for the late reply. I had to go out.
No need to apologize for having a life ;)

Anyways, what I think is confusing you is that BYOND doesn't support "operator overloading". In other words, it doesn't take the type of a process's arguments into account when deciding which version to call, it just calls the last one.

So, when you have both Entered(var/obj/O) and Entered(mob/PC/M), they're actually conflicting, and the second one covers the first one. Because you didn't call the parent process (or in this case, the sibling process) with ..(), your version of Entered() for /objs was never being called. This led to those projectiles not being deleted, and errors when trying to access them as if they were players.

The solution is to make no assumptions (beyond when the reference specifies, which is /atom/movable in Entered()'s case) about the argument's type until you've tested it, and to not define the same process for the same type multiple times:
    Safe_Zone
density = 0

Entered(atom/movable/A)

if(istype(A,/obj/Kamehameha/) || istype(A,/obj/Distructo_Disk/) || istype(A,/obj/Fat_Wrap/))
del(A)

else if(istype(A,/mob/PC))
var/mob/PC/M = A

if(M.e_db_1==1||M.e_db_2==1||M.e_db_3==1||M.e_db_4==1||M.e_db_5==1||M.e_db_6==1||M.e_db_7==1)
M<<"<font color=red><b>You are being punished for attempting to bring dragonballs into the SZ!</font color></b>"
world<<"<font size = 3><font color = red><b>[M] has been Automatically Bitch Slapped for attempting to bring dragonballs into the SZ!"
AutoBS(M)

if(M.buku)
M.buku = 0
M.density = 1
M.doing = 0
M.icon_state = ""
return

M.insz=1

Exited(mob/PC/M)
M.insz=0


Also, you should define all of your projectiles under one parent type (such as /obj/projectile) so you can more easily check for them (and you can better organize/reuse your code)
I see...Is this one of those occasions where I hit the limits of the DM programming? And I plan on defining the objects as projectiles one day...Whoever coded this before me, or originally created this, has things everywhere that makes it really messy at times. Could this be a possible reason to why the game crashes so much?
In response to Chiwy8
Chiwy8 wrote:
I see...Is this one of those occasions where I hit the limits of the DM programming? And I plan on defining the objects as projectiles one day...Whoever coded this before me, or originally created this, has things everywhere that makes it really messy at times. Could this be a possible reason to why the game crashes so much?

Actually, I think its the other way around. BYOND is one of only a few loosely-typed programming language which would continue to let a piece of software which is so obviously full of bugs and issues run :)

If you're using a source from a DBZ game, theres a pretty high chance that you'll be refactoring most of the code, before the game runs as it should. I would suggest profiling it, and looking at anything that isn't an icon operation that takes more than a hundredth of a second to run. And then after you've fixed most/all of that, look at optimizing stuff dealing with icon operations if you can (By caching, f.ex).
In response to Chiwy8
Chiwy8 wrote:
I see...Is this one of those occasions where I hit the limits of the DM programming?

I wouldn't say that. It's just that DM is a very loosely-type and dynamic language, so if you've ever used a strictly-typed language like C++, you might not be used to having to check the types of your data. You just have to know how it works.

And I plan on defining the objects as projectiles one day...Whoever coded this before me, or originally created this, has things everywhere that makes it really messy at times. Could this be a possible reason to why the game crashes so much?

Poor organization may have led to poor programming, but won't in itself cause a crash. It will definitely make it harder to track down the actual causes, though. Generally, bugs come out of basic flaws in logic or bad assumptions (like the assumption that your Entered() was receiving a mob).

If all of the code is as bad as you seem to be suggesting, I would advise that you start fresh. It'll take longer to fix it piece by piece than write it out correctly in the first place. Plus, you'll learn more.
I see... Well, I am working on my own personal projects that are not related to any anime. Anime games here are to common and unoriginal in my opinion. The only reason im coding for it is because im vetting great practice after finishing the dm guide 2 weeks ago lol. One last question though, wouldn the Exited proc also have to be rewritten with the istype commands since its also assuming that mobs are the only things exiting? I feel that just leaving the exited as it is will also cause a runtime error
In response to Chiwy8
Chiwy8 wrote:
One last question though, wouldn the Exited proc also have to be rewritten with the istype commands since its also assuming that mobs are the only things exiting? I feel that just leaving the exited as it is will also cause a runtime error

Yes! Nice catch, I missed that. I'll just pretend I was testing you ;)

Anyways, good to know you're taking the time to read and understand everything. If you want good learning material, I would suggest playing with some demos/libraries instead of leaked DBZ source code. Forum_account has some good ones for games.
Awesome. haha.

Way ahead of you. Been reading a lot of demos, guides, and the forums here. That dbz source is actually a game thats been running for a couple of years, not a leaked source. Im just messing with it for a friend. Thank you!