Skip to content

Commit

Permalink
[10599] Attempt fix data corruption for some localization structures …
Browse files Browse the repository at this point in the history
…with GCC use.

By unknown reason GCC generate wrong code for locale structures declared in header after pack pragma.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
  • Loading branch information
cyberbrest2 authored and VladimirMangos committed Oct 9, 2010
1 parent 9c0d767 commit 4144e06
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
13 changes: 7 additions & 6 deletions src/game/GameObject.h
Expand Up @@ -516,19 +516,20 @@ struct GameObjectInfo
}
};

// By unknown reason GCC generate wrong code for locale structures declared in header after pack pragma
struct GameObjectLocale
{
std::vector<std::string> Name;
std::vector<std::string> CastBarCaption;
};

// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
#if defined( __GNUC__ )
#pragma pack()
#else
#pragma pack(pop)
#endif

struct GameObjectLocale
{
std::vector<std::string> Name;
std::vector<std::string> CastBarCaption;
};

// client side GO show states
enum GOState
{
Expand Down
1 change: 1 addition & 0 deletions src/game/ItemPrototype.h
Expand Up @@ -656,6 +656,7 @@ struct ItemPrototype
bool IsConjuredConsumable() const { return Class == ITEM_CLASS_CONSUMABLE && (Flags & ITEM_FLAGS_CONJURED); }
};

// By unknown reason GCC generate wrong code for locale structures declared in header after pack pragma
struct ItemLocale
{
std::vector<std::string> Name;
Expand Down
26 changes: 14 additions & 12 deletions src/game/NPCHandler.h
Expand Up @@ -34,6 +34,20 @@ struct PageText
uint32 Next_Page;
};

// By unknown reason GCC generate wrong code for locale structures declared in header after pack pragma
struct PageTextLocale
{
std::vector<std::string> Text;
};

struct NpcTextLocale
{
NpcTextLocale() { Text_0.resize(8); Text_1.resize(8); }

std::vector<std::vector<std::string> > Text_0;
std::vector<std::vector<std::string> > Text_1;
};

// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
#if defined( __GNUC__ )
#pragma pack()
Expand Down Expand Up @@ -61,16 +75,4 @@ struct GossipText
GossipTextOption Options[8];
};

struct PageTextLocale
{
std::vector<std::string> Text;
};

struct NpcTextLocale
{
NpcTextLocale() { Text_0.resize(8); Text_1.resize(8); }

std::vector<std::vector<std::string> > Text_0;
std::vector<std::vector<std::string> > Text_1;
};
#endif
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10598"
#define REVISION_NR "10599"
#endif // __REVISION_NR_H__

15 comments on commit 4144e06

@Axxus
Copy link

@Axxus Axxus commented on 4144e06 Oct 9, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks u so much!!

@LordJZ
Copy link
Contributor

@LordJZ LordJZ commented on 4144e06 Oct 9, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of problem do you speak about?
I haven't had any problems with GCC 4.1.

@Axxus
Copy link

@Axxus Axxus commented on 4144e06 Oct 9, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its related to locales_gameobject an locales_pagetext tables. Not affect if u are using english or russian as default language.

@kero99
Copy link

@kero99 kero99 commented on 4144e06 Oct 9, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!, finally crash in esES locales fixed ;-)

@VladimirMangos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't had any problems with GCC 4.1.

This only affect servers with localization data... and possible not all GCC versions have problem.

@Ankso
Copy link

@Ankso Ankso commented on 4144e06 Oct 9, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot ^^

@LordJZ
Copy link
Contributor

@LordJZ LordJZ commented on 4144e06 Oct 10, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why english or russian? Are we special? :P

@Axxus
Copy link

@Axxus Axxus commented on 4144e06 Oct 10, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One missing case with Gossip Locales. http://pastebin.com/izfbZNZp crashdump. Not clean source but we know where the problem is.

@kero99
Copy link

@kero99 kero99 commented on 4144e06 Oct 10, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need move Gossip locales too...

@narma
Copy link

@narma narma commented on 4144e06 Oct 10, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kero99, +1.
My backtrace: http://gist.github.com/619376

@SeTM
Copy link

@SeTM SeTM commented on 4144e06 Oct 10, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this commit fix ^ http://gist.github.com/619376 crash. very strange.

@VladimirMangos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you and any who have locale related crashes before test this patch: http://gist.github.com/619398

If i understand problem right (mixed code use in packed/unpacked libstdc++ structures) then this resolve old and new porbelms

@rsa
Copy link
Contributor

@rsa rsa commented on 4144e06 Oct 10, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be version of GCC related? I also has crushes after this commit...

@kero99
Copy link

@kero99 kero99 commented on 4144e06 Oct 10, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Vlad, patch http://gist.github.com/619398 work perfect, no locales crashes for client esES, Gameobject Ok, Items OK, PageText OK and Gossip OK. (GCC version 4.4.1)

Thanks soo much.

@VladimirMangos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for testing :)

Please sign in to comment.