Jump to content

Recommended Posts

By default, wearflags in Metin2 are limited to 32-bit, limiting you to 32 wearflags. To support additional flags, the underlying type must be updated to uint64_t.

 

Run this SQL query in your database:

ALTER TABLE item_proto MODIFY wearflag BIGINT UNSIGNED NOT NULL DEFAULT 0;

common/item_length.h:

// Convert the enum to use uint64_t and make sure to use 1ULL shifts

enum EItemWearableFlag : uint64_t
{
    WEARABLE_BODY    = (1ULL << 0),    // replace 1 with 1ULL and so on...
    ...,
}

 

common/tables.h

// change:
DWORD    dwWearFlags;
// to:
uint64_t    dwWearFlags;    // to make less changes, we can just keep the variable name as dwWearFlags

 

game/item.h:

// change:
DWORD       GetWearFlag()       { return m_pProto ? m_pProto->dwWearFlags : 0; }
// to:
uint64_t    GetWearFlag()        { return m_pProto ? m_pProto->dwWearFlags : 0; }

 

GameLib/ItemData.h:

// Convert the enum to use uint64_t and make sure to use 1ULL shifts
enum EItemWearableFlag : uint64_t
{
    WEARABLE_BODY    = (1ULL << 0),    
    ...,
}

// change:
DWORD    dwWearFlags;
// to:
uint64_t    dwWearFlags;    // to make less changes, we can just keep the variable name as dwWearFlags

// change:
BOOL IsWearableFlag(DWORD dwFlag) const;
// to:
BOOL IsWearableFlag(uint64_t dwFlag) const;

// change:
DWORD GetWearFlags() const;
// to:
uint64_t GetWearFlags() const;

 

GameLib/ItemData.cpp:

// change:
BOOL CItemData::IsWearableFlag(DWORD dwFlag) const
// to:
BOOL CItemData::IsWearableFlag(uint64_t dwFlag) const

// change:
DWORD CItemData::GetWearFlags() const
to:
uint64_t CItemData::GetWearFlags() const

 

UserInterface/PythonItemModule.cpp:

// If you are adding a WEARABLE_XXX constant for python that exceed 2^31, change:
PyModule_AddIntConstant(poModule, "WEARABLE_XXX",                CItemData::WEARABLE_XXX);
// to:
PyObject* pyValue = PyLong_FromUnsignedLongLong(static_cast<uint64_t>(CItemData::WEARABLE_XXX));
PyModule_AddObject(poModule, "WEARABLE_XXX", pyValue);

 

db/ProtoReader.cpp:

/ change:
int get_Item_WearFlag_Value(string inputString) 
// to:
uint64_t get_Item_WearFlag_Value(std::string inputString) 

// change:
int retValue = 0;
// to:
uint64_t retValue = 0;

// change:
retValue = retValue + pow((float)2,(float)i);
// to:
retValue |= (1ULL << i);

// add after int dataArray[35];
uint64_t wearFlags = 0;

// change:
dataArray[i] = get_Item_WearFlag_Value(csvTable.AsStringByIndex(col));
validCheck = dataArray[i];
// to:
wearFlags = get_Item_WearFlag_Value(csvTable.AsStringByIndex(col));
dataArray[i] = 0;
validCheck = 0;

// change:
itemTable->dwWearFlags = dataArray[7];
// to:
itemTable->dwWearFlags = wearFlags;

 

db/ProtoReader.h:

// change:
int get_Item_WearFlag_Value(std::string inputString);
// to:
uint64_t get_Item_WearFlag_Value(std::string inputString);

 

db/ClientManagerBoot.cpp:

// change:
str_to_number(item_table->dwWearFlags, data[col++]);
// to:
item_table->dwWearFlags = strtoull(data[col++], nullptr, 10);

 

If you use dump_proto:

dump_proto.cpp:

// change:
DWORD    dwWearFlags;
// to:
uint64_t    dwWearFlags;

// change:
fprintf(stdout, "ITEM #%-5u %-24s %-24s VAL: %1d %ld %ld %ld %ld %ld WEAR %u ANTI %u IMMUNE %u REFINE %u\n",
// to:
fprintf(stdout, "ITEM #%-5u %-24s %-24s VAL: %ld %ld %ld %ld %ld %ld WEAR %I64u ANTI %u IMMUNE %u REFINE %u\n",

 

ItemCSVReader.h:

// change:
int get_Item_WearFlag_Value(std::string inputString);
// to:
uint64_t get_Item_WearFlag_Value(std::string inputString);

 

ItemCSVReader.cpp:

// change:
int get_Item_WearFlag_Value(std::string inputString)
// to:
uint64_t get_Item_WearFlag_Value(std::string inputString)

// change:
int retValue = 0;
// to:
uint64_t retValue = 0;

// change:
retValue = retValue + pow((float)2,(float)i); 
// to:
retValue |= (1ULL << i);

 

If you use mysql2proto:

mysql2proto.cpp:

// change:
str_to_number(pItemTable->dwWearFlags, data[col++]);
// to:
pItemTable->dwWearFlags = strtoull(data[col++], nullptr, 10);

 

  • Good 1
  • Love 4

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.