madmax Posted April 6, 2013 Report Share Posted April 6, 2013 (edited) Ok and I guess there is no way to set a global variable kind of in JS that holds the user's player id. Then this can be used to check in parts of the JS code ?What I need is something like bool doesEntityBelongToPlayer(entityid, player id)I see some of the components call back to the script like:virtual bool MoveToTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange){ return m_Script.Call<bool>("MoveToTargetRange", target, minRange, maxRange);}Maybe if such a function is there in JS that messages.js is using, I could call back there. Edited April 6, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
zoot Posted April 6, 2013 Author Report Share Posted April 6, 2013 No, the sim needs to stay 'player neutral', I believe. It is used for all sorts of validation (anti-cheat, network sync, etc.), so the engine needs to be able to rely on two different hosts reporting the same values. Quote Link to comment Share on other sites More sharing options...
madmax Posted April 6, 2013 Report Share Posted April 6, 2013 (edited) I see this in ICmpPlayerManager/*** Player manager. This maintains the list of players that exist in the game.*/class ICmpPlayerManager : public IComponent{public:virtual void AddPlayer(entity_id_t ent) = 0;virtual int32_t GetNumPlayers() = 0;virtual entity_id_t GetPlayerByID(int32_t id) = 0;DECLARE_INTERFACE_TYPE(PlayerManager)};Will try to use it. But then what the user's player id...hmm Maybe it's always 0 or 1 ? Edited April 6, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
madmax Posted April 6, 2013 Report Share Posted April 6, 2013 Also some interesting stuff in ICmpOwnership wonder what that interface is for. Quote Link to comment Share on other sites More sharing options...
zoot Posted April 6, 2013 Author Report Share Posted April 6, 2013 ICmpPlayerManager is also in the sim, so it will be player neutral too. In messages.js, I used the Engine.GetPlayerID() call. Perhaps you could track down how that works. Quote Link to comment Share on other sites More sharing options...
zoot Posted April 6, 2013 Author Report Share Posted April 6, 2013 (edited) It's defined here: https://github.com/0ad/0ad/blob/master/source/gui/scripting/ScriptFunctions.cpp#L167 Edited April 6, 2013 by zoot Quote Link to comment Share on other sites More sharing options...
madmax Posted April 6, 2013 Report Share Posted April 6, 2013 (edited) Yes I have the player id now. Hopefully in a multiplayer it will return the player id of the current user's player correctlycase MT_EntityAttacked: { const CMessageEntityAttacked& data = static_cast<const CMessageEntityAttacked&> (msg); if (!g_Game) break; int player = g_Game->GetPlayerID(); m_Active = true; m_X = data.x; m_Z = data.z; m_PingEntity = true; m_PingCount = MAX_PING_FRAMES; LOGWARNING(L"E:%d, Message received of Attack ! x:%d, z:%d", data.entity, data.x, data.z); break; }Now to verify if the attacked entity belongs to this player. Is it possible to pass the player who was attacked from JS ? Then all I would need to do is a simple comparison. Edited April 6, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
zoot Posted April 6, 2013 Author Report Share Posted April 6, 2013 (edited) Yes, that can be done. I'll get on it in a sec (pending coffee ). Edited April 6, 2013 by zoot Quote Link to comment Share on other sites More sharing options...
madmax Posted April 6, 2013 Report Share Posted April 6, 2013 no problemo Enjoy your coffee Quote Link to comment Share on other sites More sharing options...
zoot Posted April 6, 2013 Author Report Share Posted April 6, 2013 https://github.com/zootzoot/0ad/commit/0f2aa3e2a9efcb057493dba4e627250059b54740 Quote Link to comment Share on other sites More sharing options...
madmax Posted April 6, 2013 Report Share Posted April 6, 2013 (edited) ok committed the change: https://github.com/l...e56deb19968385dWe do not use the x & z values currently, but they seems to be rather high :WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798)WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798)WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798)WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166)WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875)WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166)WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166)WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798)WARNING: User Player:1: Message received of Attack on entity 136 of player 1 at (5811604, 8604536)WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798)Are they being passed as this high from JS or is it a conversion problem I wonder. Edited April 6, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
zoot Posted April 6, 2013 Author Report Share Posted April 6, 2013 ok committed the change: https://github.com/l...e56deb19968385dLooks awesome! Only tiny problem I can find is that the ping time seems way too long. The blinking should at most continue a few secs after the entity is no longer being hit.Are they being passed as this high from JS or is it a conversion problem I wonder.Hmm. I'm not sure, but I think they are that high. These are 'pixel' or sub-tile positions, not coarse terrain tile positions. Quote Link to comment Share on other sites More sharing options...
madmax Posted April 6, 2013 Report Share Posted April 6, 2013 (edited) ok, yeah I 'll reduce MAX_PING_FRAMES. Edited April 6, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
zoot Posted April 6, 2013 Author Report Share Posted April 6, 2013 If x and z are unused, I guess we can drop them from the message: https://github.com/zootzoot/0ad/commit/d7b90aee4de7c60d530c8277173e5eb481ce1439 Quote Link to comment Share on other sites More sharing options...
madmax Posted April 6, 2013 Report Share Posted April 6, 2013 ok. Whats the time parameter. Is it the number of turns ?WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:4800WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:5000WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:5000WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:5200WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875), time:5400WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:5400WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:5400WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:5800WARNING: User Player:1: Message received of Attack on entity 136 of player 1 at (5811604, 8604536), time:6800WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:7000WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:7200WARNING: User Player:1: Message received of Attack on entity 33 of player 1 at (5765249, 8206359), time:7400WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875), time:7400WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:7400WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:7600WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:9000WARNING: User Player:1: Message received of Attack on entity 89 of player 1 at (7070392, 7018728), time:9200WARNING: User Player:1: Message received of Attack on entity 135 of player 1 at (5695624, 8374201), time:9400WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875), time:9400WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:11000WARNING: User Player:1: Message received of Attack on entity 33 of player 1 at (5765249, 8206359), time:11400WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875), time:11400WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:11400WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:11400WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875), time:11400WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:12600WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:13200WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875), time:13400WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:13400WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875), time:15400WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:15400WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:15400Engine exited successfully on 2013-04-06 at 15:22:29 with 363 message(s), 0 error(s) and 32 warning(s). Quote Link to comment Share on other sites More sharing options...
zoot Posted April 6, 2013 Author Report Share Posted April 6, 2013 I don't know, actually. But it is based on turns, I believe (not real-time). Quote Link to comment Share on other sites More sharing options...
madmax Posted April 6, 2013 Report Share Posted April 6, 2013 ok, well lets keep that then. I ll remove x & z from the C++ side.So what next ? I have done the template modifications too. Quote Link to comment Share on other sites More sharing options...
zoot Posted April 6, 2013 Author Report Share Posted April 6, 2013 (edited) I seem to be getting an issue where the 'dots' turn black for a while before they begin blinking:(Three frames depicted; match start, dot turns black, dot begins blinking.)Any idea what that might be? Edited April 6, 2013 by zoot Quote Link to comment Share on other sites More sharing options...
madmax Posted April 6, 2013 Report Share Posted April 6, 2013 Probably the alpha setting. Let me check the code in this region again. Alpha blending is turned off though, so I wonder. Quote Link to comment Share on other sites More sharing options...
madmax Posted April 6, 2013 Report Share Posted April 6, 2013 ok, committed: https://github.com/laxmax/0ad/commits/attack-notification Quote Link to comment Share on other sites More sharing options...
zoot Posted April 6, 2013 Author Report Share Posted April 6, 2013 The black dot issue is fixed. Is still get ping times up to 15-20 secs, though. Is that intentional? Or is it my frame rate that is being weird, perhaps? Quote Link to comment Share on other sites More sharing options...
madmax Posted April 6, 2013 Report Share Posted April 6, 2013 reduced max ping frames to 500 Quote Link to comment Share on other sites More sharing options...
zoot Posted April 6, 2013 Author Report Share Posted April 6, 2013 Seems good. About the 'time' parameter, we can remove that if you aren't using it (since no one else are). Should we? Quote Link to comment Share on other sites More sharing options...
madmax Posted April 6, 2013 Report Share Posted April 6, 2013 yep shore ! Quote Link to comment Share on other sites More sharing options...
zoot Posted April 6, 2013 Author Report Share Posted April 6, 2013 https://github.com/zootzoot/0ad/commit/6a36d3e514e91151ad6065c7116d462f3ff9d04a Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.