[committed] Type of GameNPC.Flags and some minor changes

A place to submit .patch fixes for the DOL SVN

Moderator: Developer Team

[committed] Type of GameNPC.Flags and some minor changes

Postby Dre » Tue Sep 28, 2010 9:11 am

Hello,

I changed type of "GameNPC.Flags" from "uint" to "GameNPC.eFlags" (that changed to "uint" instead of "int" too) so there are less cast when we use GameNPC.Flags.
I did minor changes in GameServer/WorldMgr/Region.cs (cast and catching exception changed to use of operator "as").

Sorry for my bad english.

PS: The patch was created in "DOLSharp/trunk/"

gamenpc_flags.patch
(33.31 KiB) Downloaded 23 times
Dre
Developer
 
Posts: 206
Joined: Fri Oct 29, 2004 6:24 pm
Website: https://amtenael.fr

Re: Type of GameNPC.Flags and some minor changes

Postby Graveen » Tue Sep 28, 2010 4:02 pm

Accepted, thank you, soon in SVN.

Please, try to check the whole DOL solutions, i had to fix scripts in GameServerScripts :)
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: [committed] Type of GameNPC.Flags and some minor changes

Postby Kadorien » Wed Sep 29, 2010 2:28 pm

I just applied this patch (and after fixing over 90 entries in my scripts) I have come across a source file that I didn't modify from trunk but is not functioning with this new code.

I haven't look into it too much

foreach (Mob mob in mobs)
{
if ((mob.Flags & (uint)GameNPC.eFlags.PEACE) == 0)
{
mob.Flags ^= (uint)GameNPC.eFlags.PEACE;

}

Error 46 Operator '^=' cannot be applied to operands of type 'uint' and 'DOL.GS.GameNPC.eFlags' Source\GameServer\dbconverters\Version002.cs 60 6 GameServer

Error 47 Cannot implicitly convert type 'DOL.GS.GameNPC.eFlags' to 'uint'. An explicit conversion exists (are you missing a cast?) Source\GameServer\dbconverters\Version002.cs 60 19 GameServer

Not sure if this is the right fix but it did get it compiled for me

if ((mob.Flags & (uint)GameNPC.eFlags.PEACE) == 0)
{
mob.Flags ^= (int)GameNPC.eFlags.PEACE;
}
Kadorien
DOL Novice
 
Posts: 57
Joined: Wed Sep 08, 2010 1:14 am

Re: [committed] Type of GameNPC.Flags and some minor changes

Postby Graveen » Wed Sep 29, 2010 4:13 pm

no, you have to remove the cast aka '(uint)'.

Also, a lot of ^ are in the code. They are generally wrong (bad copy paste) although they work perfectly.
They should be replaced with |

I don't see the benefits to XOR something. Here it clearly hides code clarity.
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: [committed] Type of GameNPC.Flags and some minor changes

Postby Kadorien » Wed Sep 29, 2010 4:54 pm

Graveen wrote:no, you have to remove the cast aka '(uint)'.

Also, a lot of ^ are in the code. They are generally wrong (bad copy paste) although they work perfectly.
They should be replaced with |

I don't see the benefits to XOR something. Here it clearly hides code clarity.


Okay, so it should be

Code: Select all
if ((mob.Flags & GameNPC.eFlags.PEACE) == 0)
{
mob.Flags |= GameNPC.eFlags.PEACE;


I tried setting the mob.Flags & GameNPC.eFlags.PEACE like that and it drew another error. I am just bringing it to everyones attention because currently in the 'live' source it won't compile the way it is set (at least not for me with this addition).
??
Kadorien
DOL Novice
 
Posts: 57
Joined: Wed Sep 08, 2010 1:14 am

Re: [committed] Type of GameNPC.Flags and some minor changes

Postby Kadorien » Wed Sep 29, 2010 4:58 pm

Code: Select all
                if ((mob.Flags & GameNPC.eFlags.PEACE) == 0)
                {
                    mob.Flags |= GameNPC.eFlags.PEACE;
                }


Throws the following errors:

Error 46 Operator '&' cannot be applied to operands of type 'uint' and 'DOL.GS.GameNPC.eFlags' Source\GameServer\dbconverters\Version002.cs 58 10 GameServer
Error 47 Operator '|=' cannot be applied to operands of type 'uint' and 'DOL.GS.GameNPC.eFlags' Source\GameServer\dbconverters\Version002.cs 60 6 GameServer
Error 48 Cannot implicitly convert type 'DOL.GS.GameNPC.eFlags' to 'uint'. An explicit conversion exists (are you missing a cast?) Source\GameServer\dbconverters\Version002.cs 60 19 GameServer

I don't know what this code does, I'm just under the impression that if you SVN Update right now you will not be able to compile your source.

https://dolserver.svn.sourceforge.net/s ... sion002.cs

Current Source has the code as:

Code: Select all
            if ((mob.Flags & (uint)GameNPC.eFlags.PEACE) == 0)
            {
               mob.Flags ^= (uint)GameNPC.eFlags.PEACE;
            }
Kadorien
DOL Novice
 
Posts: 57
Joined: Wed Sep 08, 2010 1:14 am

Re: [committed] Type of GameNPC.Flags and some minor changes

Postby Tolakram » Wed Sep 29, 2010 5:19 pm

I updated and was able to compile. Check your SVN update log, did you have any files in a conflicted state that did not update?
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: [committed] Type of GameNPC.Flags and some minor changes

Postby Graveen » Wed Sep 29, 2010 5:20 pm

Sorry, do not change uint in DB002.cs. Anyway it must compile as-is, from unmodifyed SVN.

You 'll have to tune custom code in some occasions. If you need, remove (uint) cast.
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: [committed] Type of GameNPC.Flags and some minor changes

Postby Kadorien » Wed Sep 29, 2010 5:21 pm

Tolakram wrote:I updated and was able to compile. Check your SVN update log, did you have any files in a conflicted state that did not update?


I changed it back to what's in trunk and it compiles now for me no problem. I am very confused by that. Sorry for the confusion guys :(
Kadorien
DOL Novice
 
Posts: 57
Joined: Wed Sep 08, 2010 1:14 am


Return to “%s” DOL Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest