Skip to content
This repository has been archived by the owner on Apr 17, 2022. It is now read-only.

removeTimer #4663

Closed
wzdev-ci opened this issue Oct 26, 2017 · 6 comments
Closed

removeTimer #4663

wzdev-ci opened this issue Oct 26, 2017 · 6 comments

Comments

@wzdev-ci
Copy link
Contributor

resolution_fixed type_patch (an actual patch, not a request for one) | by Prot


Function removeTimer() - not remove timer in "this scope", but remove the timer with same name in first matched bot-player.
For example: we are create simple bot-player, who eveery second send message with his number player:

function eventStartLevel(){
    queue("init", 1000);
    queue("stopTimer", 5000);
}

function init(){
    setTimer("debugMsg", 1000);
}

function stopTimer(){
    if(me==2){
        removeTimer("debugMsg");
        debug("["+(Math.floor(gameTime/1000))+"] i'm #"+me+", stopTimer()");
    } else {
        debug("["+(Math.floor(gameTime/1000))+"] i'm #"+me+", continue");
    }
}

function debugMsg(){
    debug("["+(Math.floor(gameTime/1000))+"] I'm #"+me);
}

Then after 5 second we removeTimer only on second bot-player, and we see this result:

[2] I'm #1
[2] I'm #2
[2] I'm #3
[3] I'm #1
[3] I'm #2
[3] I'm #3
[4] I'm #1
[4] I'm #2
[4] I'm #3
[5] i'm #1, continue
[5] i'm #2, stopTimer()
[5] i'm #3, continue
[5] I'm #1
[5] I'm #2
[5] I'm #3
[6] I'm #2
[6] I'm #3
[7] I'm #2
[7] I'm #3
[8] I'm #2
[8] I'm #3
[9] I'm #2
[9] I'm #3
[10] I'm #2
[10] I'm #3

As we can see, the player 2 try to remove his timer, but timer stop on player 1 only.
Problem has in 3.1.5, 3.2.3 and master version.
I found the problem in qtscript.cpp and make this patch


Issue migrated from trac:4663 at 2022-04-16 12:56:41 -0700

@wzdev-ci
Copy link
Contributor Author

Prot uploaded file 47a2b6c86f6744285c6f3e1a632cda69cf6e0ea6.patch (1.0 KiB)

@wzdev-ci
Copy link
Contributor Author

NoQ commented


This is spot-on, thanks! I guess nobody has used removeTimer() before, at least not in AI scripts.

@wzdev-ci
Copy link
Contributor Author

Prot EuPhobos <prot@...> changed status from new to closed

@wzdev-ci
Copy link
Contributor Author

Prot EuPhobos <prot@...> changed owner from `` to Prot EuPhobos <prot@euphobos.ru>

@wzdev-ci
Copy link
Contributor Author

Prot EuPhobos <prot@...> changed resolution from `` to fixed

@wzdev-ci
Copy link
Contributor Author

Prot EuPhobos <prot@...> committed [4]


In Warzone2100/warzone2100@4a24e8e:

#CommitTicketReference repository="" revision="4a24e8e2753d02775b6732d59c23a75a79b83f72"
fixed removeTimer function

Fixed incorrect timer deletion.
Closes #4663.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant