Im having problem with IS_PIT.Work.
When I try to get every PitWork done, I dont know how to do it..
What im trying is:
if ((pit.Work & PitWorkFlags.PSE_NOTHING) == PitWorkFlags.PSE_NOTHING)
insim.Send(new IS_MTC { Msg = verde + "PSE_NOTHING detectado0", PLID = pit.PLID });
if ((pit.Work & PitWorkFlags.PSE_STOP) == PitWorkFlags.PSE_STOP)
insim.Send(new IS_MTC { Msg = verde + "PSE_STOP detectado0", PLID = pit.PLID });
if ((pit.Work & PitWorkFlags.PSE_FR_DAM) == PitWorkFlags.PSE_FR_DAM)
insim.Send(new IS_MTC { Msg = verde + "PSE_FR_DAM detectado0", PLID = pit.PLID });
if ((pit.Work & PitWorkFlags.PSE_FR_WHL) == PitWorkFlags.PSE_FR_WHL)
insim.Send(new IS_MTC { Msg = verde + "PSE_FR_WHL detectado0", PLID = pit.PLID });
if ((pit.Work & PitWorkFlags.PSE_LE_FR_DAM) == PitWorkFlags.PSE_LE_FR_DAM)
insim.Send(new IS_MTC { Msg = verde + "PSE_LE_FR_DAM detectado0", PLID = pit.PLID });
if ((pit.Work & PitWorkFlags.PSE_LE_FR_WHL) == PitWorkFlags.PSE_LE_FR_WHL)
insim.Send(new IS_MTC { Msg = verde + "PSE_LE_FR_WHL detectado0", PLID = pit.PLID });
if ((pit.Work & PitWorkFlags.PSE_RI_FR_DAM) == PitWorkFlags.PSE_RI_FR_DAM)
insim.Send(new IS_MTC { Msg = verde + "PSE_RI_FR_DAM detectado0", PLID = pit.PLID });
if ((pit.Work & PitWorkFlags.PSE_RI_FR_WHL) == PitWorkFlags.PSE_RI_FR_WHL)
insim.Send(new IS_MTC { Msg = verde + "PSE_RI_FR_WHL detectado0", PLID = pit.PLID });
if ((pit.Work & PitWorkFlags.PSE_LE_RE_DAM) == PitWorkFlags.PSE_LE_RE_DAM)
insim.Send(new IS_MTC { Msg = verde + "PSE_LE_RE_DAM detectado0", PLID = pit.PLID });
if ((pit.Work & PitWorkFlags.PSE_LE_RE_WHL) == PitWorkFlags.PSE_LE_RE_WHL)
insim.Send(new IS_MTC { Msg = verde + "PSE_LE_RE_WHL detectado0", PLID = pit.PLID });
if ((pit.Work & PitWorkFlags.PSE_RI_RE_DAM) == PitWorkFlags.PSE_RI_RE_DAM)
insim.Send(new IS_MTC { Msg = verde + "PSE_RI_RE_DAM detectado0", PLID = pit.PLID });
if ((pit.Work & PitWorkFlags.PSE_RI_RE_WHL) == PitWorkFlags.PSE_RI_RE_WHL)
insim.Send(new IS_MTC { Msg = verde + "PSE_RI_RE_WHL detectado0", PLID = pit.PLID });
if ((pit.Work & PitWorkFlags.PSE_SETUP) == PitWorkFlags.PSE_SETUP)
insim.Send(new IS_MTC { Msg = verde + "PSE_SETUP detectado0", PLID = pit.PLID });
if ((pit.Work & PitWorkFlags.PSE_REFUEL) == PitWorkFlags.PSE_REFUEL)
insim.Send(new IS_MTC { Msg = verde + "PSE_REFUEL detectado0", PLID = pit.PLID });
But it doesnt work. Looking for a solution, i found this class helper
http://hugoware.net/blog/enums-flags-and-csharp
Very easy and pretty, but didnt worked neither..
if(pit.Work.Has(PitWorkFlags.PSE_NOTHING))
insim.Send(new IS_MTC { Msg = verde + "PSE_NOTHING", PLID = pit.PLID });
if(pit.Work.Has(PitWorkFlags.PSE_STOP))
insim.Send(new IS_MTC { Msg = verde + "PSE_STOP", PLID = pit.PLID });
if (pit.Work.Has(PitWorkFlags.PSE_FR_DAM))
insim.Send(new IS_MTC { Msg = verde + "PSE_FR_DAM", PLID = pit.PLID });
if (pit.Work.Has(PitWorkFlags.PSE_FR_WHL))
insim.Send(new IS_MTC { Msg = verde + "PSE_FR_WHL", PLID = pit.PLID });
if (pit.Work.Has(PitWorkFlags.PSE_RI_FR_DAM))
insim.Send(new IS_MTC { Msg = verde + "PSE_RI_FR_DAM", PLID = pit.PLID });
if (pit.Work.Has(PitWorkFlags.PSE_RE_DAM))
insim.Send(new IS_MTC { Msg = verde + "PSE_RE_DAM", PLID = pit.PLID });
if (pit.Work.Has(PitWorkFlags.PSE_RE_WHL))
insim.Send(new IS_MTC { Msg = verde + "PSE_RE_WHL", PLID = pit.PLID });
if (pit.Work.Has(PitWorkFlags.PSE_RE_WHL))
insim.Send(new IS_MTC { Msg = verde + "PSE_RE_WHL", PLID = pit.PLID });
if (pit.Work.Has(PitWorkFlags.PSE_LE_RE_DAM))
insim.Send(new IS_MTC { Msg = verde + "PSE_LE_RE_DAM", PLID = pit.PLID });
if (pit.Work.Has(PitWorkFlags.PSE_LE_RE_WHL))
insim.Send(new IS_MTC { Msg = verde + "PSE_LE_RE_WHL", PLID = pit.PLID });
if (pit.Work.Has(PitWorkFlags.PSE_RI_RE_DAM))
insim.Send(new IS_MTC { Msg = verde + "PSE_RI_RE_DAM", PLID = pit.PLID });
if (pit.Work.Has(PitWorkFlags.PSE_RI_RE_WHL))
insim.Send(new IS_MTC { Msg = verde + "PSE_RI_RE_WHL", PLID = pit.PLID });
if (pit.Work.Has(PitWorkFlags.PSE_BODY_MINOR))
insim.Send(new IS_MTC { Msg = verde + "PSE_BODY_MINOR", PLID = pit.PLID });
if (pit.Work.Has(PitWorkFlags.PSE_BODY_MAJOR))
insim.Send(new IS_MTC { Msg = verde + "PSE_BODY_MAJOR", PLID = pit.PLID });
if (pit.Work.Has(PitWorkFlags.PSE_SETUP))
insim.Send(new IS_MTC { Msg = verde + "PSE_SETUP", PLID = pit.PLID });
if (pit.Work.Has(PitWorkFlags.PSE_REFUEL))
insim.Send(new IS_MTC { Msg = verde + "PSE_REFUEL", PLID = pit.PLID });
So at this point, I just tought InSim Lib outdated, I were using 2.0.12, updated to 2.0.14b and still with problem..
So I decided to look into the InSimDotNet´s source code, as Im with Visual Studio 2010, I couldnt open 2.0.14b source, I got the .13
I changed InSimDotNet.Packets.PitWorkFlags adding their values, like next:
/// <summary>
/// No work done.
/// </summary>
PSE_NOTHING = 1,
/// <summary>
/// Stopped at pit-box.
/// </summary>
PSE_STOP = 2,
/// <summary>
/// Front damage.
/// </summary>
PSE_FR_DAM = 4,
/// <summary>
/// Front wheels changed.
/// </summary>
PSE_FR_WHL = 8,
/// <summary>
/// Left-front damage.
/// </summary>
PSE_LE_FR_DAM = 16,
/// <summary>
/// Left-front wheels changed.
/// </summary>
PSE_LE_FR_WHL = 32,
/// <summary>
/// Right-front damaged.
/// </summary>
PSE_RI_FR_DAM = 64,
/// <summary>
/// Right-front wheel changed.
/// </summary>
PSE_RI_FR_WHL = 128,
/// <summary>
/// Rear damage.
/// </summary>
PSE_RE_DAM = 256,
/// <summary>
/// Rear wheels changed.
/// </summary>
PSE_RE_WHL = 512,
/// <summary>
/// Left-rear damage.
/// </summary>
PSE_LE_RE_DAM = 1024,
/// <summary>
/// Left-rear wheel changed.
/// </summary>
PSE_LE_RE_WHL = 2048,
/// <summary>
/// Right-rear damage.
/// </summary>
PSE_RI_RE_DAM = 4096,
/// <summary>
/// Right-rear wheel changed.
/// </summary>
PSE_RI_RE_WHL = 8192,
/// <summary>
/// Minor body damage.
/// </summary>
PSE_BODY_MINOR = 16384,
/// <summary>
/// Major body damage.
/// </summary>
PSE_BODY_MAJOR = 32768,
/// <summary>
/// Setup changed.
/// </summary>
PSE_SETUP = 65536,
/// <summary>
/// Refuelled.
/// </summary>
PSE_REFUEL = 131072,
I tryied again, and first code I posted worked fine, but as It was so verbose, I tryied the second one.. But that one didnt worked..
So, I want to know, Im doing it wrong since first code, its a bug of InSimDotNet?? And, Its there a way I can use the second way to check every flag?
Thanks in advance
PS. Sorry for that long code posting, but I want to help C&P for if someone want to try easy..