• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Fatal Error

Status
Not open for further replies.

GLB

GLB

Level 8
Joined
Jan 30, 2009
Messages
233
Good Day you awesome people,

I am currently working on a little project of mine and encountered a tough fatal error. I tested the map four times in multiplayer with friends and we had the same fatal error twice. I am not sure if I have correctly located the source problem.

The exact same situation occured in two of the fours games we played:
1. We 've been playing for more than 40 minutes (not sure if this is relevant)
2. A player had an item with the avatar ability on cooldown
3. the player with the avatar item dropped an item (in the first game with this fatal error he dropped the "avatar item" and in the second game with this fatal error the player dropped another item and kept the avatar item in the inventory)
This situation was the only common point between these two games before they crashed.

In the fourth game I told them not to purchase the avatar item and everything went great and we've been playing for more than 1 hour.

So I'd like to ask you if there are any known issues with the avatar ability that under certain circumstances can cause fatal errors?

Thank you in advance.
 
Last edited by a moderator:

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
There are multiple reasons why game could crash; time is not relevant unless you were experiencing lag issues. You would have to show some kind of code, test map or so.
Game can be crashed by simply performing given procedure with forbidden parameters e. g. GetPlayerName expects numbers from 0 to 15. If you provide let's say -1, the next thing you gonna see will surely be your desktop.

Might be usefull.
 

GLB

GLB

Level 8
Joined
Jan 30, 2009
Messages
233
There are multiple reasons why game could crash; time is not relevant unless you were expiriencing lag issues. You would have to show some kind of code, test map or so.
Game can be crashed by simply performing given procedure with forbidden parameters like GetPlayerName expects numbers from 0 to 15. If you provide let's say -1, the next thing you gonna see will surely be your desktop.

Might be usefull.

hi. Yes I know. there were absolutely no lag issues during the game and I am 100% positive that there are no forbidden parameters in my code. I am pretty sure it is somehow linked to the avatar ability. Maybe it interfers with my "Item Ownership Management System" that I implemented to restrict use of other players' items.




Code:
//############################################################
//############################################################
//##                                                        ##
//##             Item Ownership Management                  ##
//##                                                        ##
//############################################################
//############################################################

//##########################################################
//#                                                        #
//#         Modification Functions                         #
//#                                                        #
//##########################################################

function SetItemOwner takes item i, unit u returns nothing
 call SaveUnitHandle(udg_ItemOwner, GetHandleId(i), 0, u)
endfunction

function GetItemOwner takes item i returns unit
 if LoadUnitHandle(udg_ItemOwner, GetHandleId(i), 0) != null then
  return LoadUnitHandle(udg_ItemOwner, GetHandleId(i), 0)
 endif
  return null
endfunction

function ClearItemOwner takes item i returns nothing
 call FlushChildHashtable(udg_ItemOwner, GetHandleId(i))
endfunction

//##########################################################
//#                                                        #
//#          Item Ownership Conditions                     #
//#                                                        #
//##########################################################

function ItemReceptionCond takes nothing returns boolean
 return GetItemType(GetManipulatedItem()) != ITEM_TYPE_POWERUP and GetItemType(GetManipulatedItem()) != ITEM_TYPE_CHARGED and GetItemType(GetManipulatedItem()) != ITEM_TYPE_CAMPAIGN and GetItemType(GetManipulatedItem()) != ITEM_TYPE_PURCHASABLE
endfunction

function ItemSoldCond takes nothing returns boolean
 return GetItemType(GetManipulatedItem()) != ITEM_TYPE_POWERUP and GetItemType(GetManipulatedItem()) != ITEM_TYPE_CHARGED and GetItemType(GetManipulatedItem()) != ITEM_TYPE_CAMPAIGN and GetItemType(GetManipulatedItem()) != ITEM_TYPE_PURCHASABLE
endfunction

//##########################################################
//#                                                        #
//#          Hero receives item                            #
//#                                                        #
//##########################################################

function ItemReceivedAction takes nothing returns nothing
 local unit u = GetTriggerUnit()
 local item i = GetManipulatedItem()
 if GetItemOwner( i ) == null then
    call SetItemOwner( i , u )
 else
    if GetItemOwner( i ) != u then
       call UnitDropItemPoint(u, i, GetUnitX( u ), GetUnitY( u ) )
    endif
 endif
 set u = null
 set i = null
endfunction

//##########################################################
//#                                                        #
//#          Hero sells item                               #
//#                                                        #
//##########################################################

function ItemSoldAction takes nothing returns nothing
 call ClearItemOwner( GetSoldItem () )
endfunction

//##########################################################
//#                                                        #
//#           Item Owner Management Initiation             #
//#                                                        #
//##########################################################

function InitTrig_Item_Ownership takes nothing returns nothing

 // Hero sells items

 local trigger t = CreateTrigger()
 call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_PAWN_ITEM )
 call TriggerAddAction( t, function ItemSoldAction )
 call TriggerAddCondition( t , Condition( function ItemSoldCond ) )

 set t = null

 // Hero gets items

 set gg_trg_Item_Ownership = CreateTrigger(  )
 call TriggerRegisterAnyUnitEventBJ( gg_trg_Item_Ownership, EVENT_PLAYER_UNIT_PICKUP_ITEM )
 call TriggerAddAction( gg_trg_Item_Ownership, function ItemReceivedAction )
 call TriggerAddCondition( gg_trg_Item_Ownership, Condition( function ItemReceptionCond ) )

endfunction

EDIT : You can test the map (see below my signature)
 

Zwiebelchen

Hosted Project GR
Level 35
Joined
Sep 17, 2009
Messages
7,236
You maybe caused an infinite loop by dropping that item.
It's a very common mistake made by inexperienced mappers.

example:
trigger a) uses the acquire item event and drops it (because of condition x).
trigger b) uses the drop item event and adds it back in (because of condition y)
--> if both conditions x and y are true, you create an infinite loop, the game crashes.

This is just the most obvious example. There are a lot more that are less obvious, but 90% of game crashes are related to this.

If you use both an acquire and a drop event in your map, make sure both conditions that are instantly re-dropping or re-adding the item can never be true at the same time.
Also notice that a lot of other situations cause the drop/acquire event that are not so obvious (passing the items between units directly, buying/selling items, powerups, removing items temporarily (i.e. because of a swappable-inventory system)).
 

GLB

GLB

Level 8
Joined
Jan 30, 2009
Messages
233
Solved

Removing activated avatar from a unit will crash the game. I guess this applies for the item ability aswell.
Aslong as the unit is in avatar it must also have the ability.

yes this is the answer I expected! I removed that specific item and now everything goes smoothly well. We played like three games without any problems. I was not aware of that issue but I am glad somebody confirmed what I guessed. Thank you

Thread can closed!
 
Status
Not open for further replies.
Top