HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Different kind of game crash

02-12-2006, 06:02 PM#1
The_AwaKening
I'm getting an odd type of crash in my map lately. The game will just freeze for about 5 seconds and then immediately exit you back to windows and close warcraft down completely. The weird thing is that you don't get any kind of error message at all. It's just gone.

This is about the only trigger I've added into the map in this version. Not saying it is the one causing the problem necessarily, but it's all I can think of.
Collapse JASS:
function Trig_Rax_Bonus_Actions takes nothing returns nothing
local integer i
local integer j=1
local integer k=0
    loop
        exitwhen j>3
        set i=(4*CountUnitsInGroup(udg_BarracksGroup[j])-2)
        loop
            exitwhen k>(3*j-1)
            if i>0 then
                call AdjustPlayerStateBJ( i, Player(k), PLAYER_STATE_RESOURCE_LUMBER )
                call AdjustPlayerStateBJ( i*10, Player(k), PLAYER_STATE_RESOURCE_GOLD )
            endif
            set k=k+1
        endloop
        set j=j+1
    endloop
endfunction

//===========================================================================
function InitTrig_Rax_Bonus takes nothing returns nothing
    set gg_trg_Rax_Bonus = CreateTrigger(  )
    call DisableTrigger( gg_trg_Rax_Bonus )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Rax_Bonus, 20.00 )
    call TriggerAddAction( gg_trg_Rax_Bonus, function Trig_Rax_Bonus_Actions )
endfunction
Could it be a problem that it continues adding resources to players after they have left the game?
02-12-2006, 06:07 PM#2
Anitarf
I think you get this sort of an error when the game hits an infinite loop, don't see it happening in this trigger, though.
02-12-2006, 06:09 PM#3
Jacek
Nope... I think k should be resetted each loop. Probably it is increased 13th time and you don't have Player(13)
02-12-2006, 06:41 PM#4
The_AwaKening
I did wonder about "k" a while back when I made the trigger; however, funny thing is that the game works sometimes without error with this trigger running. I will look at my other loops knowing that this could be the problem.

--edit looking this over again, it looks like k only reaches 8?
02-12-2006, 07:07 PM#5
The_AwaKening
I just realised that I took this trigger from this site.
Collapse JASS:
function Trig_Combine_Items_Actions takes nothing returns nothing
local integer ITEMCOUNT=0
local integer ITEMLOOP=0
local integer CHARGES=0
local integer MAXIMUM=6
local item NEWITEM=GetManipulatedItem()
local unit OURUNIT=GetManipulatingUnit()
    loop
        exitwhen ITEMLOOP > 6
        if ((GetItemTypeId(NEWITEM)) == (GetItemTypeId(UnitItemInSlotBJ(OURUNIT, ITEMLOOP)))) then
            if ((GetItemCharges(UnitItemInSlotBJ(OURUNIT, ITEMLOOP)) + GetItemCharges(NEWITEM)) <= MAXIMUM) then
                if not ( (UnitItemInSlotBJ(OURUNIT, ITEMLOOP)) == (NEWITEM)) then                
                    set CHARGES = (GetItemCharges(UnitItemInSlotBJ(OURUNIT, ITEMLOOP))) + GetItemCharges(NEWITEM)
                    call SetItemCharges( UnitItemInSlotBJ(OURUNIT, ITEMLOOP), CHARGES )
                    call RemoveItem( NEWITEM )
                    set ITEMLOOP=7
                endif
            endif
        endif
        if ( ITEMLOOP < 7 ) then
            set ITEMLOOP = ITEMLOOP + 1
        endif
    endloop
    set NEWITEM=null
    set OURUNIT=null
endfunction
I am thinking though that ITEMLOOP should be initially set to 1 and not 0?
02-12-2006, 07:15 PM#6
Vexorian
It should start with 1 or end with 5 and use natives instead those awful BJ functions that make inventory start with 1 instead of 0.

The first trigger is like full of problems. I will post more info later

Edit: After checking the trigger again it seems it shouldn't cause any problem