.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   Dominions 2: The Ascension Wars (http://forum.shrapnelgames.com/forumdisplay.php?f=55)
-   -   2.08 and Incompatible Battle Reports (http://forum.shrapnelgames.com/showthread.php?t=17878)

Taqwus February 25th, 2004 08:26 PM

Re: 2.08 and Incompatible Battle Reports
 
There may be #pragmas or compiler options to change reordering behavior, but I'm not too familiar with MSVC.
Wrapping the randomizer in an object and making sure that the "get a random number" method (perhaps as a static method, even) might serve as a hint to the compiler; could be more work than it's worth.

[edit] Making sure that it's not flagged as constant, that is. IOW to encourage the compiler to consider side-effects of function invocation.

[ February 25, 2004, 18:51: Message edited by: Taqwus ]

Pocus February 25th, 2004 08:46 PM

Re: 2.08 and Incompatible Battle Reports
 
I have often battle inconstancies message now, with solo play on windows platform.

Gandalf Parker February 25th, 2004 08:57 PM

Re: 2.08 and Incompatible Battle Reports
 
Way outside of my area but I was thinking that the Devs might have to write their own randomizing routine, and have the host create a seed. Then pass the seed its using inside each of the player files so that the players copy of Dom would definetly use the same routine on the same seed. I never figured on different OSs doing standard math in different orders. Thats insane.

[ February 25, 2004, 18:58: Message edited by: Gandalf Parker ]

Johan K February 25th, 2004 09:06 PM

Re: 2.08 and Incompatible Battle Reports
 
Quote:

Originally posted by Pocus:
I have often battle inconstancies message now, with solo play on windows platform.
<font size="2" face="sans-serif, arial, verdana">Bah, can't you let me be happy for more than 1 hour and 13 minutes. http://forum.shrapnelgames.com/images/icons/tongue.gif

Peter Ebbesen February 25th, 2004 09:15 PM

Re: 2.08 and Incompatible Battle Reports
 
Quote:

Originally posted by Saber Cherry:
So the moral is actually not to trust Microsoft products, since they take away your control http://forum.shrapnelgames.com/images/icons/icon10.gif [/QB]
<font size="2" face="sans-serif, arial, verdana">No, the moral is to be damn careful when using random numbers in sync. http://forum.shrapnelgames.com/images/icons/icon10.gif

NTJedi February 25th, 2004 09:16 PM

Re: 2.08 and Incompatible Battle Reports
 
I have seen this bug about 3 times for all of the games I have played. It is very rare... and definitely a bizarre bug.

It has worked both ways for me... One battle it showed me losing... yet on the map I won. Another battle it showed me winnning... yet on the map I lost.

2 of these were seen with patch 2.08 installed.

[ February 25, 2004, 19:17: Message edited by: NTJedi ]

Taqwus February 25th, 2004 09:29 PM

Re: 2.08 and Incompatible Battle Reports
 
*scratches head*
'volatile' may also help. The MSDN C++ Language Reference states, "Objects declared as volatile are not used in optimizations because their value can change at any time". Perhaps creating an 'int volatile do_not_reorder_me = 0;' declaration, explicitly separating the computations into multiple lines e.g.
int lhs = lhs_base + invoke_2d6() + do_not_reorder_me;
int rhs = rhs_base + invoke_2d6() + do_not_reorder_me;
would work. I haven't played around with that keyword much however -- been awhile since I wrote MT code.

Arryn February 25th, 2004 11:12 PM

Re: 2.08 and Incompatible Battle Reports
 
Quote:

Originally posted by Saber Cherry:
</font><blockquote><font size="1" face="sans-serif, arial, verdana">quote:</font><hr /><font size="2" face="sans-serif, arial, verdana">Originally posted by PhilD:
Don't use two function calls in the same expression, is the lesson.

<font size="2" face="sans-serif, arial, verdana">Compliers do strange things. A poorly-written compiler could rearrange consecutive lines if there is no obvious dependancy.

1: a=2d6+penetration
2: b=2d6+mrst
3: if(a>b){do c}

Lines 1 & 2 could be rearranged by a compiler if, for example, mrst is more local (already in a register) and penetration has to be fetched. That would have the same effect. I think C has some commands that let you force the complier to not rearrange things, though.

So the moral is actually not to trust Microsoft products, since they take away your control http://forum.shrapnelgames.com/images/icons/icon10.gif
</font><hr /></blockquote><font size="2" face="sans-serif, arial, verdana">Having done quite a bit of compiler beta-testing in my younger days, what this basically amounts to is an issue of (no offense to IW intended) somewhat sloppy coding practice by programmers. If you want to force the compiler to evaluate things a certain way, then make liberal use of parenthesis and local-scope intermediate variables. But what I see all too often is programmers that try to cram as much code as possible into a single line. That's just begging for trouble. And it's an absolute no-no when writing cross-platform code.

BTW, the MSVC compiler is actually very good. A bit odd at times, but good nonetheless. You just have to be very well acquainted with all it's various switches, directives, etc. The compiler doesn't really take control away from you. It's settings default to newbie usage. Which can be overridden. And should be, by professional coders.

My $0.02 worth on the subject.

Saber Cherry February 25th, 2004 11:14 PM

Re: 2.08 and Incompatible Battle Reports
 
Quote:

Originally posted by Taqwus:
*scratches head*
'volatile' may also help.

<font size="2" face="sans-serif, arial, verdana">Yeah, volatile was what I was thinking about. I suspect there are similar commands as well. Volatile, IIRC, is mainly used in multithreading and i/o. It can prevent a variable from being replaced by a constant, or ignored, but I'm not sure if it can prevent reordering.

Microsoft strives to prevent inter-os compatibility; maybe using an Intel compiler would be best=)

Saber Cherry February 25th, 2004 11:23 PM

Re: 2.08 and Incompatible Battle Reports
 
Quote:

Originally posted by Arryn:
what this basically amounts to is an issue of (no offense to IW intended) somewhat sloppy coding practice by programmers... all too often (programmers) try to cram as much code as possible into a single line. That's just begging for trouble.
<font size="2" face="sans-serif, arial, verdana">Hahaha... My lines are rarely less than 5X that long, and would be longer with a bigger monitor. Parenthesis do not help you if a compiler ignores your instruction ordering.

The problem here is that the lines are NOT LONG ENOUGH! The Microsoft compiler sees a simple rearrangement it can do to break inter-OS compatibility, and does it. If the lines are so long and confusing that the compiler can't figure out how to mutate them without breaking the program, it will just process them in order like it is supposed to http://forum.shrapnelgames.com/images/icons/icon10.gif

Really! I promise! http://forum.shrapnelgames.com/images/icons/tongue.gif


All times are GMT -4. The time now is 04:05 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.