-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to play with 10.0 data #1114
Comments
Same issue occurs for me. |
Hello, There are a few ways to debug the situation. First: I have no clue about the data structure of this specific .dat file, or basically anything that involves anything from newer Tibia (anything above 7.7). I'm pretty familiar with OTClients source code though. I don't think someone will come over with ready to implement code and share it, so I'll just try and help you guys to get this running so we can drop a PR later on. in There we have this lovely piece of code someone I don't know wrote: if(g_game.getClientVersion() >= 1000) {
/* In 10.10+ all attributes from 16 and up were
* incremented by 1 to make space for 16 as
* "No Movement Animation" flag.
*/
if(attr == 16)
attr = ThingAttrNoMoveAnimation;
else if(attr > 16)
attr -= 1;
} Maybe we should check how the real tibia client reads the .dat file, or any other open source software capable of reading and processing the file. I think though, reading through the comments of that if statement, that versions I'd just rewrite the if statment like below and try it out: if(g_game.getClientVersion() >= 1010) {
/* In 10.10+ all attributes from 16 and up were
* incremented by 1 to make space for 16 as
* "No Movement Animation" flag.
*/
if(attr == 16)
attr = ThingAttrNoMoveAnimation;
else if(attr > 16)
attr -= 1;
} If any of you can test that I'd be very grateful. Best Wishes |
Hi Okke, I made the change as advised and recompiled. The below error is the newest.
A different ID and lastAttr now. I then tried and change line 65 and recompiled again, with the same result as above.
to I look forward to your future contributions! |
Hello again boys, I think I found the missing part, I'm not sure though, anyways: I came up with a suggestion. Please reroll the code on Now on bool ThingTypeManager::loadDat(std::string file)
{
m_datLoaded = false;
m_datSignature = 0;
m_contentRevision = 0;
try {
file = g_resources.guessFilePath(file, "dat");
FileStreamPtr fin = g_resources.openFile(file);
m_datSignature = fin->getU32();
m_contentRevision = static_cast<uint16_t>(m_datSignature);
for(int category = 0; category < ThingLastCategory; ++category) {
int count = fin->getU16() + 1;
m_thingTypes[category].clear();
m_thingTypes[category].resize(count, m_nullThingType);
}
m_marketCategories.clear();
for(int category = 0; category < ThingLastCategory; ++category) {
uint16 firstId = 1;
if(category == ThingCategoryItem)
firstId = 100;
for(uint16 id = firstId; id < m_thingTypes[category].size(); ++id) {
ThingTypePtr type(new ThingType);
type->unserialize(id, (ThingCategory)category, fin);
m_thingTypes[category][id] = type;
if (type->isMarketable()) {
auto marketData = type->getMarketData();
m_marketCategories.insert(marketData.category);
}
}
}
m_datLoaded = true;
g_lua.callGlobalField("g_things", "onLoadDat", file);
return true;
} catch(stdext::exception& e) {
g_logger.error(stdext::format("Failed to read dat '%s': %s'", file, e.what()));
return false;
}
} After testing this please let me know what happened. Thanks in advance, |
Hi @okk3 I did as you suggested and 2 errors when building.
|
Add this Oh, also add |
Hi @okk3
thingtypemanager.cpp
thingtypemanager.h
|
Alright, we're on a good path, now add this to your std::set<int> getMarketCategories()
{
return m_marketCategories;
} Oh and by the way, on your |
Added this - provides the same result when building. I feel like we're closing in!
|
Sorry, new log file, looks like they are different this time round
|
Alright, now let's add to your // set
template<typename T>
int push_luavalue(const std::set<T>& vec);
template<typename T>
bool luavalue_cast(int index, std::set<T>& vec); below: // vector
template<typename T>
int push_luavalue(const std::vector<T>& vec);
template<typename T>
bool luavalue_cast(int index, std::vector<T>& vec); and also we want this: template<typename T>
int push_luavalue(const std::set<T>& set)
{
g_lua.createTable(set.size(), 0);
int i = 1;
for (const T& v : set) {
push_internal_luavalue(v);
g_lua.rawSeti(i);
i++;
}
return 1;
}
template<typename T>
bool luavalue_cast(int index, std::set<T>& set)
{
if (g_lua.isTable(index)) {
g_lua.pushNil();
while (g_lua.next(index < 0 ? index - 1 : index)) {
T value;
if (luavalue_cast(-1, value))
set.insert(value);
g_lua.pop();
}
return true;
}
return false;
} below: template<typename T>
bool luavalue_cast(int index, std::vector<T>& vec)
{
if(g_lua.isTable(index)) {
g_lua.pushNil();
while(g_lua.next(index < 0 ? index-1 : index)) {
T value;
if(luavalue_cast(-1, value))
vec.push_back(value);
g_lua.pop();
}
return true;
}
return false;
} |
Added both to client\luavaluecasts.h You got this @okk3 I have faith! :) |
Oh my god, I think there might be an issue with the code you pasted in: it's not inside Stupidity of mine to not define it properly. Please re-read the comment I've edited before this one. It's the plague of doing stuff on the issues page of GitHub in a very fast-paced rythm, I'm sorry. |
No problem at all. I've added your final changes to Build errors continue... |
Okay that's a plus already, I'll read some more source code and come back at you when I find something "feasible". |
Honestly, I appreciate everything you're doing @okk3. Once again, I am more than happy to pay a small sum of $20 for not only the resolution, but your contribution to the community. I look forward to hearing back from you soon! |
Any update on this @okk3 ? |
Need help with same issue :) |
Steps to reproduce (include any configuration/script required to reproduce)
ERROR: Failed to read dat '/things/1000/Tibia.dat': corrupt data (id: 625, category: 0, count: 255, lastAttr: 3)'
Expected behaviour
Should work.
Actual behaviour
Doesn't work.
Environment
Compiled for Linux from commit c6d0fc0
The text was updated successfully, but these errors were encountered: