Объявления |
---|
Друзья, если не получается зарегистрироваться, напишите на почту vdv_forever@bk.ru. Я оторву свою задницу от всех дел и обязательно Вас активирую! Добро пожаловать на геройский форум! |
Re: Энциклопедия алгоритмов HoMM 3Это Герои 2 с сигнатурами. Просто пример того, что получится на выходе, если, например, когда-нибудь появится декомпилятор SuperH4, подхватывающий сигнатуры.
|
Re: Энциклопедия алгоритмов HoMM 3Ааа! Герои 2.
Кстати жалко, что бараторч не сделал HD-Mod для двойки. |
Re: Энциклопедия алгоритмов HoMM 3Восстановленный хедер array.h
https://twitter.com/DiskBlitz/status/92 ... 69/photo/1 и шаблон CAutoArray<...> оттуда. По крайней мере в Dreamcast-базе использовались следующие экземпляры шаблона: CAutoArray<int> CAutoArray<CDPlayConnection> CAutoArray<CDPlayGroup> CAutoArray<CDPlayPlayer> CAutoArray<CDPlaySession> CAutoArray<CDPlayAddressElement> Шаблон класса представляет из себя автоматический массив указателей на какие-либо данные.
Последний раз редактировалось void_17 28 ноя 2021, 17:42, всего редактировалось 1 раз.
|
|
Re: Энциклопедия алгоритмов HoMM 3There is an issue here with your virtual destructor, or more precisely with the Destroy() function.
A virtual destructor does a few extra things so that the user need not to, among others is pass a flag value which can take 2 meanings: delete the class itself if it was allocated, delete the class which was allocated as an array. See here for more, I will quote the relevant part : Цитата: When class has a virtual destructor, compiler generates a helper function - deleting destructor. Its purpose is to make sure that a proper _operator delete_ gets called when destructing a class. Pseudo-code for a deleting destructor looks like following: virtual void * A::'scalar deleting destructor'(uint flags) { this->~A(); if (flags&1) A::operator delete(this); }; The address of this function is placed into the vftable instead of the destructor's address. This way, if another class overrides the virtual destructor, _operator delete_ of that class will be called. Though in real code _operator delete_ gets overriden quite rarely, so usually you see a call to the default delete(). Sometimes compiler can also generate a vector deleting destructor. Its code looks like this: virtual void * A::'vector deleting destructor'(uint flags) { if (flags&2) //destructing a vector { array = ((int*)this)-1; //array size is stored just before the this pointer count = array[0]; 'eh vector destructor iterator'(this,sizeof(A),count,A::~A); if (flags&1) A::operator delete(array); } else { this->~A(); if (flags&1) A::operator delete(this); } }; Therefore, you should not write the delete operation yourself in the destructor because the compiler does it itself - you would be invoking double delete operation and be looking for trouble. pArray should be TClass**, not DWORD*. Allocate is called Add in the symbols, there is no virtual function for allocation only. |
Re: Энциклопедия алгоритмов HoMM 3I reconstructed this according to an old C++ standard via Ghidra dreamcast decompiler. Of course the language changed.
Последний раз редактировалось void_17 28 ноя 2021, 15:22, всего редактировалось 1 раз.
|
Re: Энциклопедия алгоритмов HoMM 3Цитата: I just rewrote it the way NWC have probably done it. Btw, pArray should be DWORD*, since it stores a pointer(32 bit) to it, not the copy of the data itself. pArray is just DWORD pArray[]; |
|
Re: Энциклопедия алгоритмов HoMM 3This has nothing to do with the age of the language, it's a core part of new[] and delete[].
You can check the date of the original article which is 2006. TClass** is a 32 bit pointer itself, and so would TClass* be, at least in x86 Anyhow, that's my $0.02, you're free to do as you wish but this is not how C++ is written, and definitely not by NWC. |
Re: Энциклопедия алгоритмов HoMM 3Alright, I will remove Destroy function but I feel like it will cause a memory leak sometimes
check this. It works fine. Almost the same way as the original dreamcast (THEY HAD DESTROY FUNCTION!) and SoD game. You can check this in Dreamcast database if you do not believe me. |
|
Re: Энциклопедия алгоритмов HoMM 3I did not say there was no Destroy() method, I said there was no virtual Allocate() method in the original, only 7 virtual methods but you have 8.
You do need to clear data in the destructor, but you should not be forcing the delete flag in general if you want non-allocated data as in your example: you passed a pointer to a non-allocated message. If you had done:
then you need the delete flag. In your case, forcing the delete flag would attempt to free non-allocated data and possibly crash. |
Re: Энциклопедия алгоритмов HoMM 3It works fine now.
Btw, Allocate() method were inlined in RoE. You can verify this in Ghidra. Check this now! No problems at all. (It was just a bad example, but trust me, it works the same as in the original game)
|
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 9