Skip to content

Commit

Permalink
Simplify kdreams/id_mm.c:MM_GetPtr for the 2015 port's data.
Browse files Browse the repository at this point in the history
Good chances are the scan, even if modified, was wrong, anyway.
  • Loading branch information
NY00123 committed Jul 27, 2021
1 parent 63872b9 commit 02c2eeb
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/kdreams/id_mm.c
Expand Up @@ -436,6 +436,18 @@ void MM_GetPtr (memptr *baseptr,id0_unsigned_long_t size)
mmnew->useptr = baseptr;
mmnew->attributes = BASEATTRIBUTES;

if (refkeen_current_gamever == BE_GAMEVER_KDREAMS2015)
{
// Add a few more bytes as a workaround for vanilla bugs
// in places like CA_HuffExpand
*baseptr = malloc(size+16);
if (*baseptr == NULL)
Quit ("Out of memory! Please make sure you have enough free memory.");
mmnew->next = mmrover->next;
mmrover->next = mmnew;
return;
}

for (search = 0; search<3; search++)
{
//
Expand Down Expand Up @@ -469,7 +481,7 @@ void MM_GetPtr (memptr *baseptr,id0_unsigned_long_t size)

while (scan != endscan)
{
if ((refkeen_current_gamever == BE_GAMEVER_KDREAMS2015) || (scan->start - startseg >= needed))
if (scan->start - startseg >= needed)
{
//
// got enough space between the end of lastscan and
Expand All @@ -478,19 +490,8 @@ void MM_GetPtr (memptr *baseptr,id0_unsigned_long_t size)
//
purge = lastscan->next;
lastscan->next = mmnew;
if (refkeen_current_gamever == BE_GAMEVER_KDREAMS2015)
{
// Add a few more bytes as a workaround for vanilla bugs
// in places like CA_HuffExpand
*baseptr = malloc(size+16);
if (*baseptr == NULL)
Quit ("Out of memory! Please make sure you have enough free memory.");
}
else
{
mmnew->start /*= *(id0_unsigned_t *)baseptr*/ = startseg;
*baseptr = BE_Cross_BGetPtrFromSeg(startseg);
}
mmnew->start /*= *(id0_unsigned_t *)baseptr*/ = startseg;
*baseptr = BE_Cross_BGetPtrFromSeg(startseg);
mmnew->next = scan;
while ( purge != scan)
{ // free the purgable block
Expand Down

0 comments on commit 02c2eeb

Please sign in to comment.