About Store Forum Documentation Contact



Post Reply 
New error since patch changing the combobox functions
Author Message
Spikelife Offline
Member

Post: #1
New error since patch changing the combobox functions
I'm working with multiple worlds and a created a convenient way for me to jump between worlds and to the waypoint locs within the known worlds. I have been using a structure "jump table" of sorts with the worlds and the waypoint names to do this. I use a gui window in-game that uses combo-boxes to select the world and waypoint. All compiled and worked fine until the patch that changed the names of the combobox function/structure names (for example "ListGroup" to "ListColumn" and the rest of those).

The problem now is the table structures won't compile; I get this wierd message about EE::Str illegal sizeof operand. Here is the sample code:

Code:
struct JumpBoxElms
{
    Str name;
    Str waypoint;
    int x;
    int z;
};

JumpBoxElms gm_island_003[]=
{
    {"Start", "gmi003_start", 0, 0},
    {"End", "gmi003_end", 0, 0},
};

struct JumpAreaElms
{
    Str name;
    Str worldName;
    Int xTiles;
    Int zTiles;
    JumpBoxElms *jumpBox;
    Int nLocs;
};

JumpAreaElms jumpAreaElms[]=
{
    {"GM Island", "gm_island_003", 256, 256, gm_island_003, Elms(gm_island_003)},
};

And here is the error message at compile ...

Quote:1> Teleport.cpp
1>g:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\Misc/Member.h(115): error C2070: 'EE::Str (JumpBoxElms &)': illegal sizeof operand
1> g:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\Misc/Member.h(73) : see reference to function template instantiation 'EE::MemberDesc &EE::MemberDesc::setDefault<TYPE>(EE::DATA_TYPE,TYPE (__cdecl &))' being compiled
1> with
1> [
1> TYPE=EE::Str (JumpBoxElms &)
1> ]
1> g:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\Misc/Member.h(66) : see reference to function template instantiation 'EE::MemberDesc &EE::MemberDesc::set<TYPE>(TYPE (__cdecl &))' being compiled
1> with
1> [
1> TYPE=EE::Str (JumpBoxElms &)
1> ]
1> g:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\Gui/Objects/List.h(52) : see reference to function template instantiation 'EE::MemberDesc::MemberDesc<TYPE>(TYPE (__cdecl &))' being compiled
1> with
1> [
1> TYPE=EE::Str (JumpBoxElms &)
1> ]
1> Client\Teleport.cpp(265) : see reference to function template instantiation 'EE::ListColumn::ListColumn<EE::Str(JumpBoxElms &)>(TYPE (__cdecl &),Flt,CChar *)' being compiled
1> with
1> [
1> TYPE=EE::Str (JumpBoxElms &)
1> ]

Any ideas what this compile error is ? and a solution ?
(This post was last modified: 10-22-2011 03:51 PM by Spikelife.)
10-22-2011 03:48 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #2
RE: New error since patch changing the combobox functions
http://www.esenthel.com/community/showth...6#pid27896

-all custom Compare functions that want to be passed to memory containers search methods, and Map constructors now need to accept parameters in const mode "Compare(C TYPE &a, C TYPE &b)"
-custom functions passed to MemberDesc converting data to text, must now accept object parameter in const mode "Str Func(C TYPE &obj)"
10-22-2011 03:53 PM
Find all posts by this user Quote this message in a reply
Spikelife Offline
Member

Post: #3
RE: New error since patch changing the combobox functions
I guess I'm just being dense : there are no functions and there are no compares; there are only structures and data elements of structures.

So you changed Visual C++ defs so it can't compile any structure pointers within other structures ??
10-22-2011 04:06 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #4
RE: New error since patch changing the combobox functions
the code you have pasted compiles fine for me

the errors point to MemberDesc and ListColumn
in Teleport.cpp

you should read the error messages, and locate the error location more precisely, and paste it here
10-22-2011 04:12 PM
Find all posts by this user Quote this message in a reply
Spikelife Offline
Member

Post: #5
RE: New error since patch changing the combobox functions
Worked on it for 2 days : no success. I can't figure out what broke the templates. Don't think I've seen a template change/code update that broke code quite so effectively in a long time. I am (well ... was) using it with MMO as a really crude way to jump around to different worlds and places within the worlds. The code is not pretty but it did work. Teleport.h is added to the list of <includes> in Main.h in the Client folder of MMO.

Teleport.h:
Code:
struct JumpBoxElm
{
    CChar8 *name;
    CChar8 *waypoint;
    int x;
    int z;
};

struct JumpAreaElm
{
    CChar8 *name;
    CChar8 *worldName;
    Int xTiles;
    Int zTiles;
    JumpBoxElm *jumpBox;
    Int nLocs;
};

struct Teleport
{
private:
    // static functions
    static Str ComboBoxAreaFunc(JumpAreaElm &elm);
    static Str ComboBoxElmFunc(JumpBoxElm &elm);
    static void jumpAreaElmChanged(Ptr user);
    static void bJumpFunc(Ptr user);
    static void bCancelFunc(Ptr user);

    static void InjectPlayer(void);

    // members
private:
    static bool isInited;

    static ComboBox *cmb;
    static ComboBox *ar;
    static Button *bJump;
    static Button *bCancel;
    static Vec newPos;
    static File tempSave;
    static Net::World *current_world;
    static GuiObjs gui_jumpbox;    // to access the jump box window

public:
    // methods
    Teleport(void);
    ~Teleport(void);

public:
    static void Update(void);
    static bool Init(void);
    static GuiObjs GetJumpbox(void);
    static Net::World *GetCurrentWorld(void);
};

Teleport.cpp:
Code:
#include "StdAfx.h"
#include "Main.h"

extern Game::ObjMemx<Player> Players;

static JumpBoxElm gm_island_003[]=
{
    {"Start", "gmi003_start", 0, 0},
    {"End", "gmi003_end", 0, 0},
};

static JumpBoxElm guild_hall_island_001[]=
{
    {"Start", "start", 0, 0},
    {"End", "ghi001_end", 0, 0},
};

static JumpAreaElm jumpAreaElms[]=
{
    {"GM Island", "gm_island_003", 256, 256, gm_island_003, Elms(gm_island_003)},
    {"Guild Hall Island 001", "guild_hall_island_001", 256, 256, guild_hall_island_001, Elms(guild_hall_island_001)},
};

Teleport::Teleport(void)
{
    isInited = false;
}

Teleport::~Teleport(void)
{
}

Str Teleport::ComboBoxElmFunc(JumpBoxElm &elm)
{
    Int area = ar ? (*ar)() : -1;
    Int sel = cmb ? (*cmb)() : -1;

    if ((area < 0) | (sel < 0))
        bJump->disabled(true);
    else
        bJump->disabled(false);

    return S + elm.name;
}

Str Teleport::ComboBoxAreaFunc(JumpAreaElm &elm)
{
    Int area = ar ? (*ar)() : -1;
    Int sel = cmb ? (*cmb)() : -1;

    if (area >= 0 && sel >= 0)
    {
        C JumpBoxElm *jb = jumpAreaElms[area].jumpBox;
        cmb->setData(jb, jumpAreaElms[area].nLocs);
    }

    if ((area < 0) | (sel < 0))
        bJump->disabled(true);
    else
        bJump->disabled(false);

    return S + elm.name;
}

void Teleport::jumpAreaElmChanged(Ptr user)
{
    Int area = ar ? (*ar)() : -1;
    Int sel = cmb ? (*cmb)() : -1;

    //area = area < 0 ? 0 : area;
    if (area >= 0 && sel >= 0)
    {
        C JumpBoxElm *jb = jumpAreaElms[area].jumpBox;
        cmb->setData(jb, jumpAreaElms[area].nLocs);
        sel = 0;
        cmb->set(sel);
    }

    if ((area < 0) | (sel < 0))
        bJump->disabled(true);
    else
        bJump->disabled(false);
}

void Teleport::bCancelFunc(Ptr user)
{
    if (true)
    {
        gui_jumpbox.hide();
        bJump->disabled(true);
    }
}

void Teleport::bJumpFunc(Ptr user)
{
    Int area = ar ? (*ar)() : -1;
    Int sel = cmb ? (*cmb)() : -1;

    if ((area < 0) | (sel < 0))
    {
        // cannot jump if the things are out of range
        area = area < 0 ? 0 : area;
        sel = sel < 0 ? 0 : sel;
        bJump->disabled(true);
        return;
    }
    C JumpBoxElm *jb = jumpAreaElms[area].jumpBox;
    Str wp = jb[sel].waypoint;

    //need to be sure we have the correct world
    C Str wdp = Game::World.worldDir();
    Str wd = GetBase(GetExtNot(wdp));

    if (wd != jumpAreaElms[area].worldName)
    {
        // here to load a new world if needed
        C Str wn = S + "world/" + jumpAreaElms[area].worldName + ".world";
        Net::World *world = Net::Worlds(wn);
        Game::Waypoint *waypoint = world->getWaypoint(wp);
        if(!waypoint->points.elms())
            Exit(S +"No points in starting waypoint in new world:" + wn);

        current_world = world;
        Flt scale = ChrData.scale;
        ChrData.setWorld(world, waypoint->points[0].pos+Vec(0,0.5f*scale,0)); // set world and position
    }
    Game::Waypoint *waypoint = Game::World.getWaypoint(wp);

   if(!waypoint->points.elms())
    {
        // here if the waypoint is invalid -- some sort of error
           Exit(S+"Cannot find waypoint:" + wp + " in world: " + wd);
   }

   gui_jumpbox.hide();

   if (Players.elms())
   {
       tempSave.writeMem();
       Players[0].save(tempSave);
       Players.removeValid(0);
       newPos.x = waypoint->points[0].pos.x;
       newPos.y = waypoint->points[0].pos.y + .5f;
       newPos.z = waypoint->points[0].pos.z;

       Cam.at = newPos;
       Game::World.update(newPos);
       Cam.setFromAt(newPos, newPos);
       InjectPlayer();
   }
}

bool Teleport::Init()
{
    static ListColumn lg[] =
    {
        ListColumn(ComboBoxElmFunc, 0.5f, L"Function"),    // make it .5 wide to show the major part of the line in the dropdown box width
    };

    static ListColumn alg[]=
    {
        ListColumn(ComboBoxAreaFunc, 0.5f, L"Function"),
    };

    if (isInited)
        return true;

       if (gui_jumpbox.load("gui/jump table.gobj"))
    {
        Gui += gui_jumpbox;
        gui_jumpbox.hide();

        cmb = &gui_jumpbox.getComboBox("comboJumpList");
        ar = &gui_jumpbox.getComboBox("comboAreaList");
        bJump = &gui_jumpbox.getButton("btnJump");
        bCancel = &gui_jumpbox.getButton("btnCancel");

        ar->setColumns(alg, Elms(alg));
        ar->setData(jumpAreaElms, Elms(jumpAreaElms));
        ar->func(jumpAreaElmChanged);

        cmb->setColumns(lg, Elms(lg));
        cmb->setData(guild_hall_island_001, Elms(guild_hall_island_001));

        bJump->func(bJumpFunc);
        bCancel->func(bCancelFunc);

        bJump->disabled(true);
        isInited = true;
        return true;
    }
    return false;
};

void Teleport::InjectPlayer()
{
    tempSave.pos(0);
    Game::World.objInject(OBJ_PLAYER, tempSave, &newPos);
    tempSave.reset();
};

void Teleport::Update(void)
{
   //do the jump box
   if (Kb.b(KB_RALT) & Kb.bp(KB_NPDEL))
   {
       gui_jumpbox.show();
   }
}

GuiObjs Teleport::GetJumpbox()
{
    return gui_jumpbox;
}

Net::World *Teleport::GetCurrentWorld()
{
    return current_world;
}
10-23-2011 11:35 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #6
RE: New error since patch changing the combobox functions
one error:
Code:
C JumpBoxElm *jb = jumpAreaElms[area].jumpBox;
         cmb->setData(jb, jumpAreaElms[area].nLocs);
remove const ->
Code:
JumpBoxElm *jb = jumpAreaElms[area].jumpBox;
         cmb->setData(jb, jumpAreaElms[area].nLocs);

2nd error:

Code:
GuiObjs Teleport::GetJumpbox()
{
     return gui_jumpbox;
}
I believe you should return reference instead?

those bugs aren't caused by changes in the engine.

the only thing that was changed is this:
Code:
static ListColumn lg[] =
     {
         ListColumn(ComboBoxElmFunc, 0.5f, L"Function"),    // make it .5 wide to show the major part of the line in the dropdown box width
     };

    static ListColumn alg[]=
     {
         ListColumn(ComboBoxAreaFunc, 0.5f, L"Function"),
     };
you need to make sure that those functions take const parameter
Str Teleport::ComboBoxAreaFunc(JumpAreaElm &elm)
to
Str Teleport::ComboBoxAreaFunc(C JumpAreaElm &elm)

reorganize your functions so they do not modify JumpAreaElm inside:
you should not call
cmb->setData(jb, jumpAreaElms[area].nLocs);
inside the function, call it somewhere else if you need it
10-24-2011 05:13 PM
Find all posts by this user Quote this message in a reply
Post Reply