From 39988751610a392b49cd36c0b92bcc1f3f070b78 Mon Sep 17 00:00:00 2001 From: seth Date: Fri, 22 Sep 2017 12:19:02 +0000 Subject: [PATCH] (note: Dink requires a Proton svn commit as well, but I haven't done it yet, it needs a bit more testing first) * Fixed issue where launching dmods from DFArc with a dmod path not in DFArc's dir or Dink HD's dmod dir would fail * Fixed compatibility so Freedink.exe and the dink.exe from 1.08 can be run from Dink HD's dir (previously, start.c had been hacked to skip stuff for the HD version, it now checks version and if it's being run as a dmod or not and does it right) * If you run the HD "dink" dir as a mod it now works as expected (it plays the normal game, including the old start up screen) * Now including story/*.c instead of the .d files. No reason to hide them, right? (note: if you install over HD without uninstalling, the old .d files will still be there. But .c files are checked first so it should be ok anyway) * DMODs now default to the original .midi files rather than the .ogg CD music, as it changed the desired "feel" of some DMODs to switch to CD music. Running with -game dink causes Dink itself to not use CD music as well, so for people who don't like CD music at all there's an option to play the original game with midis only * (Bugfix) Dink HD will no longer try to grab missing sprites from the base dink dir, this fixes Dink's pushing anim in Zoltron * (Bugfix) dmod installer no longer chokes on zero byte files (I'm looking at you, 9gems) * (Bugfix) Fixed memory leak and possible crash related to script loading * (Bugfix) Fixed issue with the checkerboard shadow processing where the 8 bit RLE decoder failed because it was expecting an 8 bit target (most bmps don't use RLE, but Alliance does in places) * Went ahead and decided to accept 252,252,252 as alpha if it's index 255 on an 8bit sprite. This fixed the white background issue with Alliance dmod as well as Dinkcraft * FEATURE: Can now download all DMODs from Dink Network directly from inside the game via Dan's php interface. Can sort by rating, latest update date, or alphabetically git-svn-id: svn://rtsoft.com/rtsvn/projects/RTDink@1502 353e56fe-9613-0410-8469-b96ad8e6f29c --- script/win_installer/readme.txt | 18 ++ source/App.cpp | 21 +- source/GUI/BrowseMenu.cpp | 299 +++++++++++++++++++++----- source/GUI/BrowseMenu.h | 4 +- source/GUI/DMODMenu.cpp | 8 +- source/GUI/PopUpMenu.cpp | 9 +- source/dink/FFReader.cpp | 28 ++- source/dink/FFReader.h | 2 +- source/dink/dink.cpp | 59 ++--- source/video_gl.cpp | 1 + source/video_gl.h | 3 +- windows_vs2017/winRTDink.vcxproj | 1 + windows_vs2017/winRTDink.vcxproj.user | 2 +- 13 files changed, 343 insertions(+), 112 deletions(-) diff --git a/script/win_installer/readme.txt b/script/win_installer/readme.txt index b731f3f..358e3b0 100644 --- a/script/win_installer/readme.txt +++ b/script/win_installer/readme.txt @@ -166,3 +166,21 @@ if it was last used as fullscreen - Note: Just to be safe, save state version has changed, so old save states won't load +------ Change log for 1.7.8 ---------- + +* Fixed issue where launching dmods from DFArc with a dmod path not in DFArc's dir or Dink HD's dmod dir would fail +* Fixed compatibility so Freedink.exe and the dink.exe from 1.08 can be run from Dink HD's dir (previously, start.c had been hacked to skip stuff for the HD version, + it now checks version and if it's being run as a dmod or not and does it right) +* If you run the HD "dink" dir as a mod it now works as expected (it plays the normal game, including the old start up screen) +* Now including story/*.c instead of the .d files. No reason to hide them, right? (note: if you install over HD without uninstalling, the old .d files will still be there. But .c files are checked +first so it should be ok anyway) +* DMODs now default to the original .midi files rather than the .ogg CD music, as it changed the desired "feel" of some DMODs to switch to CD music. Running with -game dink causes Dink itself to + not use CD music as well, so for people who don't like CD music at all there's an option to play the original game with midis only +* (Bugfix) Dink HD will no longer try to grab missing sprites from the base dink dir, this fixes Dink's pushing anim in Zoltron +* (Bugfix) dmod installer no longer chokes on zero byte files (I'm looking at you, 9gems) +* (Bugfix) Fixed memory leak and possible crash related to script loading +* (Bugfix) Fixed issue with the checkerboard shadow processing where the 8 bit RLE decoder failed because it was expecting an 8 bit target (most bmps don't use RLE, but Alliance does in places) +* Went ahead and decided to accept 252,252,252 as alpha if it's index 255 on an 8bit sprite. This fixed the white background issue with Alliance dmod as well as Dinkcraft +* FEATURE: Can now download all DMODs from Dink Network directly from inside the game via Dan's php interface. Can sort by rating, latest update date, or alphabetically + +- Note: Just to be safe, save state version has changed, so old save states won't load \ No newline at end of file diff --git a/source/App.cpp b/source/App.cpp index be92e26..1a547f8 100644 --- a/source/App.cpp +++ b/source/App.cpp @@ -182,8 +182,8 @@ App::App() m_bDidPostInit = false; m_bHasDMODSupport = true; //for mobiles - m_version = 1.77f; - m_versionString = "V1.7.7"; + m_version = 1.78f; + m_versionString = "V1.7.8"; m_build = 1; m_bCheatsEnabled = false; @@ -749,19 +749,20 @@ void App::Update() AddKeyBinding(pComp, "Speedup", 9, 9); //handle tab AddKeyBinding(pComp, "Quicksave", VIRTUAL_KEY_F1, VIRTUAL_KEY_F1); AddKeyBinding(pComp, "Quickload", VIRTUAL_KEY_F8, VIRTUAL_KEY_F8); - - } + if (GetVar("check_icade")->GetUINT32() == 0) + { + AddDroidKeyboardKeys(); + } -if (GetVar("check_icade")->GetUINT32() == 0) -{ - - AddDroidKeyboardKeys(); -} - +#ifdef _DEBUG +// BrowseMenuCreate(pGUIEnt); + MainMenuCreate(pGUIEnt); +#else MainMenuCreate(pGUIEnt); +#endif } else { diff --git a/source/GUI/BrowseMenu.cpp b/source/GUI/BrowseMenu.cpp index 4b0a7ca..cc95b90 100644 --- a/source/GUI/BrowseMenu.cpp +++ b/source/GUI/BrowseMenu.cpp @@ -15,21 +15,47 @@ #include "Entity/HTTPComponent.h" +enum DMODSortEnum +{ + DMOD_SORT_RATING, + DMOD_SORT_DATE, + DMOD_SORT_ALPHABETICAL, + //add above here + DMOD_SORT_COUNT +}; + +int g_dmodSorting = DMOD_SORT_RATING; +int g_dmods_per_screen = 5; +int g_dmod_cur_page = 0; + struct DMODEntry { + + bool operator < (const DMODEntry& str) const + { + return (m_rating < str.m_rating); + } string m_name; string m_url; string m_author; float m_size; float m_rating; string m_description; - uint32 m_date; - float m_version; + string m_date; + string m_version; + string m_thumb; }; -void BrowseMenuAddScrollContent(Entity *pParent, TextScanner &t); +vector g_dmodData; + +void BrowseMenuAddScrollContent(Entity *pParent, TextScanner *t); Entity * ShowScoreMessage(Entity *pMenu, string msg); +int SmartModulo(int a, int b) +{ + return (((a % b) + b) % b); +} + void BrowseMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from { Entity *pEntClicked = pVList->m_variant[1].GetEntity(); @@ -45,6 +71,35 @@ void BrowseMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity s DMODMenuCreate(pEntClicked->GetParent()->GetParent(), true); return; } + + int totalDMODPages = g_dmodData.size() / g_dmods_per_screen; + + + if (pEntClicked->GetName() == "Next") + { + g_dmod_cur_page++; + g_dmod_cur_page = SmartModulo(g_dmod_cur_page, totalDMODPages+1); + BrowseMenuAddScrollContent(pMenu, NULL); + return; + } + + + if (pEntClicked->GetName() == "Prev") + { + g_dmod_cur_page--; + g_dmod_cur_page = SmartModulo(g_dmod_cur_page, totalDMODPages+1); + BrowseMenuAddScrollContent(pMenu, NULL); + return; + } + + if (pEntClicked->GetName() == "Label") + { + g_dmodSorting = ( (g_dmodSorting + 1) % DMOD_SORT_COUNT); + g_dmod_cur_page = 0; + BrowseMenuAddScrollContent(pMenu, NULL); + return; + } + //they must have clicked on a DMOD if they got this far if (pEntClicked->GetName() == "install") @@ -65,15 +120,6 @@ void BrowseMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity s } - /* - if (pEntClicked->GetName() == "rtsoft") - { - PopUpCreate(pEntClicked->GetParent()->GetParent()->GetParent(), "Leave the game and visit `wrtsoft.com``?", "http://www.rtsoft.com/iphone", - "cancel", "`wCancel", "url", "`wLaunch", true); - return; - } - */ - //GetEntityRoot()->PrintTreeAsText(); //useful for debugging } @@ -91,19 +137,65 @@ string VersionToString(float v) return string(tmp); } -void AddEntryBar(Entity *pParent, float &x, float &y, DMODEntry &s, int count) +void AddEntryBar(Entity *pParent, float &x, float &y, DMODEntry &s, int index) { - Entity *pBG = CreateOverlayEntity(pParent, s.m_name, ReplaceWithLargeInFileName("interface/iphone/browse_dmod_bar.rttex"),x, y); + Entity *pBG = CreateOverlayEntity(pParent, s.m_name, ReplaceWithLargeInFileName("interface/iphone/browse_dmod_bar.rttex"), x, y); y += pBG->GetVar("size2d")->GetVector2().y; pBG->GetVar("dmodurl")->Set(s.m_url); //save for later pBG->GetVar("dmodtitle")->Set(s.m_name); //save for later //title + + string displayName = s.m_name; + int maxNameChars = 30; + int maxDescripChars = 57; + + + switch (g_dmodSorting) + { + + case DMOD_SORT_DATE: + break; + + default: + maxNameChars = 37; + break; + } + + + if (displayName.length() > maxNameChars) + { + TruncateString(displayName, maxNameChars); + displayName += "..."; + } + + string displayDescription = s.m_description; + + if (displayDescription.length() > maxDescripChars) + { + TruncateString(displayDescription, maxDescripChars); + displayDescription += "..."; + } + char stTemp[512]; - sprintf(stTemp, "`6%s ``V%s`6%s - ``%.2f mb``", s.m_name.c_str(), VersionToString(s.m_version).c_str(), s.m_author.c_str(), s.m_size); + + + switch (g_dmodSorting) + { + + case DMOD_SORT_DATE: + sprintf(stTemp, "#%d %s `6%s`` R:`6%.1f``", index+1, s.m_date.c_str(), displayName.c_str(), s.m_rating); + break; + + default: + sprintf(stTemp, "#%d `6%s`` R:`6%.1f``", index+1, displayName.c_str(), s.m_rating); + break; + } + + Entity *pTitle = CreateTextLabelEntity(pBG, "title", iPhoneMapX2X( 16) ,iPhoneMapY2X( 13), stTemp); - Entity *pDescription = CreateTextBoxEntity(pBG, "descrip", iPhoneMap2X(16, 34), iPhoneMap2X(425, 54), "`6"+s.m_description); + Entity *pDescription = CreateTextBoxEntity(pBG, "descrip", iPhoneMap2X(16, 34), iPhoneMap2X(425, 54), "`6"+ displayDescription); //Entity *pIcon = CreateButtonHotspot(pBG, "icon_hotspot", GetDMODBarIconOffset(), GetDMODBarIconSize(), Button2DComponent::BUTTON_STYLE_CLICK_ON_TOUCH_IGNORE_DRAGGING); //SetTouchPaddingEntity(pIcon, CL_Rectf(0,iPhoneMapY2X(5),0,iPhoneMapY2X(5))); @@ -122,11 +214,61 @@ void AddEntryBar(Entity *pParent, float &x, float &y, DMODEntry &s, int count) } //add animation effect - ZoomToPositionFromThisOffsetEntity(pBG, CL_Vec2f(GetScreenSizeXf(), 0), 500, INTERPOLATE_EASE_TO, 10); + //ZoomToPositionFromThisOffsetEntity(pBG, CL_Vec2f(GetScreenSizeXf(), 0), 500, INTERPOLATE_EASE_TO, 10); } +void UpdateBrowseControlButtons(Entity *pParent) +{ + Entity *pEnt = NULL; -void BrowseMenuAddScrollContent(Entity *pParent, TextScanner &t) + pParent->RemoveEntityByName("Prev"); + pParent->RemoveEntityByName("Next"); + pParent->RemoveEntityByName("Label"); + + int totalDMODPages = g_dmodData.size() / g_dmods_per_screen; + + //if (g_dmod_cur_page > 0) + { + pEnt = CreateTextButtonEntity(pParent, "Prev", iPhoneMapX(25 + 50 * 1), iPhoneMapY(BACK_BUTTON_Y), "`6<<``Prev", false); + pEnt->GetFunction("OnButtonSelected")->sig_function.connect(&BrowseMenuOnSelect); + SetButtonRepeatDelayMS(pEnt, 50); + } + + //if (g_dmod_cur_page < totalDMODPages) + { + pEnt = CreateTextButtonEntity(pParent, "Next", iPhoneMapX(25 + 50 * 2), iPhoneMapY(BACK_BUTTON_Y), "Next`6>>``", false); + pEnt->GetFunction("OnButtonSelected")->sig_function.connect(&BrowseMenuOnSelect); + SetButtonRepeatDelayMS(pEnt, 50); + } + + + string sorting; + + switch (g_dmodSorting) + { + + case DMOD_SORT_DATE: + sorting = "newest"; + break; + case DMOD_SORT_ALPHABETICAL: + sorting = "alphabetical"; + break; + case DMOD_SORT_RATING: + sorting = "ratings"; + break; + + default: + sorting = "error"; + break; + } + string label = "Page `6" + toString(g_dmod_cur_page+1) + "``/`6" + toString(totalDMODPages+1) + "`` - Sorting by `6<``"+ sorting+"`6>``"; + + pEnt = CreateTextButtonEntity(pParent, "Label", iPhoneMapX(25 + 50 * 4), iPhoneMapY(BACK_BUTTON_Y), label, false); + pEnt->GetFunction("OnButtonSelected")->sig_function.connect(&BrowseMenuOnSelect); + +} + +void BrowseMenuAddScrollContent(Entity *pParent, TextScanner *t) { pParent = pParent->GetEntityByName("scroll_child"); @@ -136,58 +278,98 @@ void BrowseMenuAddScrollContent(Entity *pParent, TextScanner &t) //Entity *pEnt; + int dmodsAdded = 0; - string msg = t.GetMultipleLineStrings("msg", "|"); - vector p = StringTokenize(msg, "|"); - - if (p.size() == 2 && p[1].length() > 1) + if (g_dmodData.empty()) { - - StringReplace("", "\n", p[1]); - //add a message we just downloaded - CL_Vec2f vTextBoxPos(x+iPhoneMapX(5),y); - CL_Vec2f vTextBounds(iPhoneMapX(434), iPhoneMapY(200)); - Entity *pEnt = CreateTextBoxEntity(pParent, "", vTextBoxPos, vTextBounds, p[1]); - y += pEnt->GetVar("size2d")->GetVector2().y; - y += iPhoneMapY(5); + string msg = t->GetMultipleLineStrings("msg", "|"); + vector p = StringTokenize(msg, "|"); - } - - string line; - while ( string(line = t.GetMultipleLineStrings("add", "|")).length() > 0) - { - //LogMsg(line.c_str()); - vector p = StringTokenize(line, "|"); - - if (p.size() < 7) + if (p.size() == 2 && p[1].length() > 1) { - continue; + + StringReplace("", "\n", p[1]); + //add a message we just downloaded + CL_Vec2f vTextBoxPos(x + iPhoneMapX(5), y); + CL_Vec2f vTextBounds(iPhoneMapX(434), iPhoneMapY(200)); + Entity *pEnt = CreateTextBoxEntity(pParent, "", vTextBoxPos, vTextBounds, p[1]); + y += pEnt->GetVar("size2d")->GetVector2().y; + y += iPhoneMapY(5); + } - DMODEntry s; - s.m_name = p[1]; - s.m_url = p[2]; - s.m_author = p[3]; - s.m_size = atof(p[4].c_str()); - s.m_rating = atof(p[5].c_str()); - s.m_description = p[6]; - s.m_version = atof(p[7].c_str()); -// s.m_date = atol(p[5].c_str()); - - //m_onlineScores.push_back(s); - AddEntryBar(pParent, x, y,s, dmodsAdded); - dmodsAdded++; - y += iPhoneMapY(5); + string line; + //populate our internal DB + + g_dmodData.clear(); + + for (int i = 0; i < t->GetLineCount(); i++) + { + + //LogMsg(line.c_str()); + vector p = StringTokenize(t->GetLine(i), "|"); + if (p.size() < 8) continue; //don't care + + DMODEntry s; + s.m_name = p[0]; + if (s.m_name == "Title") continue; + s.m_url = p[1]; + s.m_author = p[2]; + s.m_size = atof(p[3].c_str()); + s.m_rating = atof(p[4].c_str()); + s.m_description = p[5]; + s.m_version = p[6]; + s.m_date = p[7].c_str(); + StringReplace("V", "", s.m_version); + StringReplace("v", "", s.m_version); + + s.m_thumb = atof(p[8].c_str()); + + + g_dmodData.push_back(s); + dmodsAdded++; + + + } } + switch (g_dmodSorting) + { - + case DMOD_SORT_ALPHABETICAL: + sort(g_dmodData.begin(), g_dmodData.end(), [](const DMODEntry& lhs, const DMODEntry& rhs) + { + return lhs.m_name < rhs.m_name; + }); + break; + + case DMOD_SORT_DATE: + + sort(g_dmodData.rbegin(), g_dmodData.rend(), [](const DMODEntry& lhs, const DMODEntry& rhs) + { + return lhs.m_date < rhs.m_date; + }); + break; + + default: + sort(g_dmodData.rbegin(), g_dmodData.rend()); + break; + } + //actually add them to the list + + for (int i = g_dmods_per_screen*(g_dmod_cur_page); i < (g_dmods_per_screen*g_dmod_cur_page)+g_dmods_per_screen && i < g_dmodData.size(); i++) + { + AddEntryBar(pParent, x, y, g_dmodData[i], i); + //y += iPhoneMapY(1); + } + VariantList vList(pParent->GetParent()); ResizeScrollBounds(&vList); DisableHorizontalScrolling(pParent->GetParent()); + UpdateBrowseControlButtons(pParent->GetParent()->GetParent()); } @@ -236,7 +418,7 @@ void OnDownloadHTTPFinish(VariantList *pVList) //GetHighScoreManager()->SetupOnlineScores(t); //GetApp()->GetVar("cur_score")->Set(uint32(0)); //reset score drawing //ScoresAddStuffToScroll(NULL); - BrowseMenuAddScrollContent(pMenu, t); + BrowseMenuAddScrollContent(pMenu, &t); // AddHighScores(pMenu, -1); } @@ -278,9 +460,9 @@ void DownloadDMODList(Entity *pMenu) pComp->GetFunction("OnFinish")->sig_function.connect(&OnDownloadHTTPFinish); - Entity *pEnt = ShowScoreMessage(pMenu, "`6"); + Entity *pEnt = ShowScoreMessage(pMenu, "`6Downloading dmod data"); EntityComponent *pTyper = pEnt->AddComponent(new TyperComponent); - pTyper->GetVar("text")->Set("Downloading add-on list..."); + pTyper->GetVar("text")->Set(".........."); pTyper->GetVar("speedMS")->Set(uint32(50)); //KillScores(); @@ -362,6 +544,7 @@ Entity * BrowseMenuCreate( Entity *pParentEnt ) SetupTextEntity(pEnt, fontID); AddHotKeyToButton(pEnt, VIRTUAL_KEY_BACK); + SlideScreen(pBG, true, 500); pBG->GetFunction("OnPostIntroTransition")->sig_function.connect(&BrowseOnPostIntroTransition); VariantList vList(pBG, string("")); diff --git a/source/GUI/BrowseMenu.h b/source/GUI/BrowseMenu.h index b2024f6..b23c215 100644 --- a/source/GUI/BrowseMenu.h +++ b/source/GUI/BrowseMenu.h @@ -2,6 +2,8 @@ #define BrowseMenu_h__ #include "BaseApp.h" Entity * BrowseMenuCreate(Entity *pParentEnt); - + + + #endif // BrowseMenu_h__ \ No newline at end of file diff --git a/source/GUI/DMODMenu.cpp b/source/GUI/DMODMenu.cpp index b65ca72..1fc3c33 100644 --- a/source/GUI/DMODMenu.cpp +++ b/source/GUI/DMODMenu.cpp @@ -246,7 +246,7 @@ void AddDMODBar(Entity *pParent, float &x, float &y, string title, string descri pBG->GetVar("dmodtitle")->Set(title); //save for later //title Entity *pTitle = CreateTextLabelEntity(pBG, "title", iPhoneMapX2X( 130) ,iPhoneMapY2X( 10), title); - Entity *pDescription = CreateTextBoxEntity(pBG, "descrip", iPhoneMap2X(129, 33), iPhoneMap2X(277, 53), description, 0.7f); + Entity *pDescription = CreateTextBoxEntity(pBG, "descrip", iPhoneMap2X(129, 33), iPhoneMap2X(277, 53), description, 0.7f); Entity *pIcon = CreateButtonHotspot(pBG, "icon_hotspot", GetDMODBarIconOffset(), GetDMODBarIconSize(), Button2DComponent::BUTTON_STYLE_CLICK_ON_TOUCH_IGNORE_DRAGGING); SetTouchPaddingEntity(pIcon, CL_Rectf(0,iPhoneMapY2X(5),0,iPhoneMapY2X(5))); @@ -307,12 +307,9 @@ if (bCanDelete) SetButtonStyleEntity(pIcon, Button2DComponent::BUTTON_STYLE_CLICK_ON_TOUCH_IGNORE_DRAGGING); SetTouchPaddingEntity(pIcon, CL_Rectf(0,0,0,0)); pIcon->GetFunction("OnButtonSelected")->sig_function.connect(&DMODMenuOnSelect); - - } - //add animation effect ZoomToPositionFromThisOffsetEntity(pBG, CL_Vec2f(GetScreenSizeXf(), 0), 500, INTERPOLATE_EASE_TO, 10); } @@ -362,7 +359,7 @@ void GetParsedDMODInfo(string dmodPath, string &nameOut, float versionOut, strin } - int maxChars = 205; + int maxChars = 180; if (description.length() > maxChars) { @@ -426,7 +423,6 @@ void DMODMenuAddScrollContent(Entity *pParent) } files.push_back(GetDMODStaticRootPath()+staticFiles[i]); - } } diff --git a/source/GUI/PopUpMenu.cpp b/source/GUI/PopUpMenu.cpp index 4368290..bed0b9f 100644 --- a/source/GUI/PopUpMenu.cpp +++ b/source/GUI/PopUpMenu.cpp @@ -36,9 +36,12 @@ void PopUpMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity se DisableAllButtonsEntity(pEntClicked->GetParent()->GetParent()); Entity *pDarken = GetEntityRoot()->GetEntityByName("pop_up_darken"); - FadeScreen(pDarken, 0, 0, 400, true); - KillEntity(pDarken, 400); - pDarken->SetName(""); + if (pDarken) + { + FadeScreen(pDarken, 0, 0, 400, true); + KillEntity(pDarken, 400); + pDarken->SetName(""); + } //set the game pause state back to whatever it was originally GetApp()->SetGameTickPause(pEntClicked->GetParent()->GetParent()->GetVar("gamePaused")->GetUINT32() != 0); diff --git a/source/dink/FFReader.cpp b/source/dink/FFReader.cpp index 2d50b80..33e059a 100644 --- a/source/dink/FFReader.cpp +++ b/source/dink/FFReader.cpp @@ -37,14 +37,29 @@ int FFReader::GetFFRecordIndexFromFileName(const string &fName) return -1; } -bool FFReader::DoesFileExist( const string &fName ) +bool FFReader::DoesFileExist( const string &fName, const string &fFirstFrame ) { //LogMsg("Checking for %s", (m_basePath+fName).c_str()); + + bool bUsingDMODDirOnly = false; + + + if (fFirstFrame != fName && !m_dmodGamePath.empty()) + { + //what if load part of a sequence from the DMOD dir, but part from the DInk dir? That would be bad + if (FileExists(m_dmodGamePath + m_basePath + fFirstFrame)) + { + bUsingDMODDirOnly = true; + } + } if (m_fp) { - if (GetFFRecordIndexFromFileName(fName) != -1) return true; + if ( + (!m_bUsingBaseDinkFF || !bUsingDMODDirOnly) && + (GetFFRecordIndexFromFileName(fName) != -1) + ) return true; } if (!m_dmodGamePath.empty()) @@ -52,12 +67,13 @@ bool FFReader::DoesFileExist( const string &fName ) if (FileExists(m_dmodGamePath+m_basePath+fName)) return true; } - if (!FileExists(m_gamePath+m_basePath+fName)) + if (!bUsingDMODDirOnly && FileExists(m_gamePath+m_basePath+fName)) { - //LogMsg("Can't find %s", (m_basePath+fName).c_str()); - return false; + return true; } - return true; + + + return false; } void FFReader::Init( const string &gamePath, const string &dmodGamePath, const string &basePath, bool bUsingDinkPak ) diff --git a/source/dink/FFReader.h b/source/dink/FFReader.h index ad25f96..98d73a6 100644 --- a/source/dink/FFReader.h +++ b/source/dink/FFReader.h @@ -33,7 +33,7 @@ public: FFReader(); virtual ~FFReader(); - bool DoesFileExist(const string &fName); + bool DoesFileExist(const string &fName, const string &fFirstFrame); void Init( const string &gamePath, const string &dmodGamePath, const string &baseDir, bool bUsingDinkPak); byte * LoadFileIntoMemory(string const &fName, int *pSizeout); //you need to delete [] what this gives you on your own eErrorType GetLastError() {return m_error;} diff --git a/source/dink/dink.cpp b/source/dink/dink.cpp index f0d5830..e8efac7 100644 --- a/source/dink/dink.cpp +++ b/source/dink/dink.cpp @@ -16,7 +16,7 @@ bool pre_figure_out(const char *line, int load_seq, bool bLoadSpriteOnly); #define C_DINK_SCREEN_TRANSITION_TIME_MS 400 -const float SAVE_FORMAT_VERSION = 2.5f; +const float SAVE_FORMAT_VERSION = 2.6f; const int C_DINK_FADE_TIME_MS = 300; const float G_TRANSITION_SCALE_TRICK = 1.01f; @@ -1564,7 +1564,7 @@ bool LoadSpriteSingleFrame(string fNameBase, int seq, int oo, int picIndex, eTra { LogMsg("Woah, "); } - if (seq == 192 && oo == 1) + if (seq == 341 && oo == 1) { LogMsg("Woah, "); } @@ -1741,9 +1741,9 @@ bool load_sprites(char org[512], int seq, int speed, int xoffset, int yoffset, r static FFReader reader; #ifdef _DEBUG - if (seq == 56) + if (seq == 314 ) { - LogMsg("Yeah"); + //LogMsg("Yeah"); } #endif reader.Init(g_dglo.m_gameDir, g_dglo.m_dmodGamePathWithDir, GetPathFromString(tempStr), g_dglo.m_bUsingDinkPak); @@ -1756,17 +1756,7 @@ bool load_sprites(char org[512], int seq, int speed, int xoffset, int yoffset, r transType = TRANSPARENT_WHITE; } -#ifdef _DEBUG - if (frame == 0) - { - if (!reader.DoesFileExist(fNameBase+"01.bmp")) - { - LogMsg("Can't find %s", (string(org)+"01.bmp").c_str()); - return true; //might be a serious error, not sure - } - } -#endif - + #ifdef _DEBUG //LogMsg("Loading %s", org); #endif @@ -1817,7 +1807,7 @@ bool load_sprites(char org[512], int seq, int speed, int xoffset, int yoffset, r // LogMsg("Loading seq %d frame %d", seq, oo); } #endif - if (reader.DoesFileExist(fNameBase+string(hold)+toString(oo)+".bmp")) + if (reader.DoesFileExist(fNameBase+string(hold)+toString(oo)+".bmp", fNameBase + "01.bmp")) { g_dglos.g_curPicIndex++; @@ -1927,6 +1917,10 @@ eTransparencyType GetTransparencyOverrideForSequence(eTransparencyType defaultTr return TRANSPARENT_NONE; case 185: //ny- numbers return TRANSPARENT_NONE; + case 190: //health bar + return TRANSPARENT_NONE; + case 451: //health bar + return TRANSPARENT_NONE; } @@ -3102,12 +3096,9 @@ void kill_script(int k) } */ - g_scriptInstance[k] = NULL; - - free(g_scriptInstance[k]); - g_scriptInstance[k] = NULL; - free(g_scriptBuffer[k]); - g_scriptBuffer[k] = NULL; + SAFE_FREE(g_scriptInstance[k]); + SAFE_DELETE_ARRAY(g_scriptBuffer[k]); + g_scriptAccelerator[k].Kill(); } } @@ -4846,8 +4837,8 @@ bool PlayMidi(const char *sFileName) } else { - //try the base dir too - if (FileExists(g_dglo.m_gamePathWithDir+tempName)) + //try the base dir for oggs too, but not if it's a dmod + if (g_dglo.m_dmodGameDir.empty() && FileExists(g_dglo.m_gamePathWithDir+tempName)) { //found it fName = tempName; @@ -8250,6 +8241,16 @@ pass: strcpy(pLineIn, h); return(0); } + + if (compare(ev[1], (char*)"is_base_game")) + { + h = &h[strlen(ev[1])]; + g_dglos.g_returnint = 1; + if (!g_dglo.m_dmodGameDir.empty()) g_dglos.g_returnint = 0; + strcpy(pLineIn, h); + return(0); + } + if (compare(ev[1], (char*)"get_client_version")) { h = &h[strlen(ev[1])]; @@ -16406,7 +16407,15 @@ string GetDMODRootPath(string *pDMODNameOutOrNull) if (!refdir.empty()) { - dmodpath = refdir + dmodpath; + if (dmodpath.find(":") != string::npos) + { + //the dmod dir we got already has a path. Ignore --refdir, it will just break things + } + else + { + //prepend the refdir path so it works with how dfarc does it + dmodpath = refdir + dmodpath; + } } StringReplace("\\", "/", dmodpath); if (dmodpath[dmodpath.size() - 1] != '/') dmodpath += '/'; //need a trailing slash diff --git a/source/video_gl.cpp b/source/video_gl.cpp index 583267a..598008c 100644 --- a/source/video_gl.cpp +++ b/source/video_gl.cpp @@ -355,6 +355,7 @@ int IDirectDrawSurface::BltFast( int x, int y, IDirectDrawSurface *pSrcSurf, rtR case MODE_SHADOW_GL: case MODE_NORMAL: + if (pSrcSurf->m_mode == MODE_PRIMARY_GL) { //we need to copy from what is already on the screen diff --git a/source/video_gl.h b/source/video_gl.h index 3dd87c1..d99cb63 100644 --- a/source/video_gl.h +++ b/source/video_gl.h @@ -44,7 +44,8 @@ enum eTransparencyType TRANSPARENT_NONE, TRANSPARENT_BLACK, TRANSPARENT_WHITE, - TRANSPARENT_MAGENTA + TRANSPARENT_MAGENTA, + TRANSPARENT_CUSTOM_COLOR //set in advance with SetCustomTransparency }; diff --git a/windows_vs2017/winRTDink.vcxproj b/windows_vs2017/winRTDink.vcxproj index b8de760..816ca64 100644 --- a/windows_vs2017/winRTDink.vcxproj +++ b/windows_vs2017/winRTDink.vcxproj @@ -3375,6 +3375,7 @@ true true true + NotUsing diff --git a/windows_vs2017/winRTDink.vcxproj.user b/windows_vs2017/winRTDink.vcxproj.user index 1a6d5de..7d0e966 100644 --- a/windows_vs2017/winRTDink.vcxproj.user +++ b/windows_vs2017/winRTDink.vcxproj.user @@ -7,7 +7,7 @@ $(OutDir) WindowsLocalDebugger - -game dmods/dinkcrft + -game dmods/alliance