PPQ_Purple
Purple Cube (retired)
- Joined
- Oct 11, 2008
- Messages
- 5,764
It is however a good starting point for him if he wants to delve into the DLL to do it.
This sounds like a difficult problem to work around - if the unmodified game chokes on extra data in the user profile but the mod needs that data to stop the option from being reset each time that the mod is loaded.[...] it seems that when the number of options is different, the stored preferences become incompatible, so that they reset to the defaults for all game related settings (e.g. low resolution etc.) when switching to a different mod.
So if I want to get rid of this:I think you'd have to do that through the DLL, specifically CvTeam::setHasTech or, if you want to get rid of all change-civics popups CvDLLButtonPopup::launchChangeCivicsPopup.
CivicOptionTypes eCivicOptionType = (CivicOptionTypes)info.getData1();
CivicTypes eCivicType = (CivicTypes)info.getData2();
bool bValid = false;
if (eCivicType != NO_CIVIC)
{
for (int iI = 0; iI < GC.getNumCivicOptionInfos(); iI++)
{
if (iI == eCivicOptionType)
{
paeNewCivics[iI] = eCivicType;
}
else
{
paeNewCivics[iI] = GET_PLAYER(GC.getGameINLINE().getActivePlayer()).getCivics((CivicOptionTypes)iI);
}
}
if (GET_PLAYER(GC.getGameINLINE().getActivePlayer()).canRevolution(paeNewCivics))
{
bValid = true;
}
}
else
{
bValid = true;
}
/*
if (bValid)
{
CvWString szBuffer;
if (eCivicType != NO_CIVIC)
{
szBuffer = gDLL->getText("TXT_KEY_POPUP_NEW_CIVIC", GC.getCivicInfo(eCivicType).getTextKeyWide());
if (!CvWString(GC.getCivicInfo(eCivicType).getStrategy()).empty())
{
CvWString szTemp;
szTemp.Format(L" (%s)", GC.getCivicInfo(eCivicType).getStrategy());
szBuffer += szTemp;
}
szBuffer += gDLL->getText("TXT_KEY_POPUP_START_REVOLUTION");
gDLL->getInterfaceIFace()->popupSetBodyString(pPopup, szBuffer);
szBuffer = gDLL->getText("TXT_KEY_POPUP_YES_START_REVOLUTION");
int iAnarchyLength = GET_PLAYER(GC.getGameINLINE().getActivePlayer()).getCivicAnarchyLength(paeNewCivics);
if (iAnarchyLength > 0)
{
szBuffer += gDLL->getText("TXT_KEY_POPUP_TURNS_OF_ANARCHY", iAnarchyLength);
}
gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, szBuffer, NULL, 0, WIDGET_GENERAL);
}
else
{
gDLL->getInterfaceIFace()->popupSetBodyString(pPopup, gDLL->getText("TXT_KEY_POPUP_FIRST_REVOLUTION"));
}
gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, gDLL->getText("TXT_KEY_POPUP_OLD_WAYS_BEST").c_str(), NULL, 1, WIDGET_GENERAL);
gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, gDLL->getText("TXT_KEY_POPUP_SEE_BIG_PICTURE").c_str(), NULL, 2, WIDGET_GENERAL);
gDLL->getInterfaceIFace()->popupSetPopupType(pPopup, POPUPEVENT_CIVIC, ARTFILEMGR.getInterfaceArtInfo("INTERFACE_POPUPBUTTON_CIVICS")->getPath());
gDLL->getInterfaceIFace()->popupLaunch(pPopup, false, POPUPSTATE_MINIMIZED);
}
*/
SAFE_DELETE_ARRAY(paeNewCivics);
return (bValid);
}
Well, probably better not to return true when the popup wasn't actually launched. So I'd comment out the whole body and return false instead – which will hopefully cause the EXE to (immediately) free the memory allocated for the popup.Is that right or am I missing something?
Well, I tested it and seemed to work fine: No popup, no crash. Though I played only 1 turn to test it.Well, probably better not to return true when the popup wasn't actually launched. So I'd comment out the whole body and return false instead – which will hopefully cause the EXE to (immediately) free the memory allocated for the popup.
Given this uncertainty about memory deallocation, I would actually feel more at ease commenting out the player loop in CvTeam::setHasTech (and leaving launchChangeCivicsPopup alone). Even if that means that the change-civics popup shown at the end of Advanced Start needs to be commented out as well. That seems to be the only place other than setHasTech where a change-civics popup gets triggered. (I see no other place in Rise of Mankind either.)
Yes, I realize that, and killing the popup shouldn't be complicated to do. Regardless of where you remove code for handling BUTTONPOPUP_CHANGECIVIC, the observable result should be the same – no popup.I can try what you suggest but to make clear: It's only the popup I want to get rid of. Players should be able to change civics on the civic screen.
const CvWString& getGameName() const
{
if (...?)
{
static CvWString szModVersion = "mod build 1.07.9";
return szModVersion;
}
return m_szGameName;
}
With this approach, come to think of it, you'll need to ensure that the version string gets appended only once. So, I guess, a string-ends-with check inOh, using the game name would be a good solution, I think. I agree that appending to the player selected game name would not be too bad.
CvInitCore::setGameName
is needed – append only if that check fails. And rather than keep the original game name in a separate data member, one could just use string operations to discard the version part in CvDLLButtonPopup::launchAdminPopup – unless Game Details is really the best place for showing version information. (Most mods seem to show it in the hover text of the big flag button, i.e. CvDLLWidgetData::parseFlagHelp
.)Oh, right, not every change will involve the DLL. So my notion of a "build number" is also a little off-target.What I don't like about this approach is it necessitates recompiling the DLL whenever the version is supposed to be updated.
Should just be a matter of adding a couple of lines to CvXMLLoadUtility::SetGlobalDefines. Those files all use the GlobalDefines schema (Is it possible to add an extra file containing XML defines? If possible I would like to render the entire file instead of regex manipulating one entry in the larger existing file.
Civ4GlobalDefinesSchema.xml
).Only a Python call comes to mind. (I don't see an advantage over the XML approach.)Or is there another useful mechanism of getting external definitions into the DLL?
I see, the parent commit (current head) would be potentially ambiguous, and the version only needs to be updated before a push. But interesting to know, for me, that "githooks" would be the topic to look into for an automatic mechanism. (In fact, my local repos already have a sample file with a comment 'To enable this hook, rename this file to "pre-commit".' Nothing to be afraid of, it seems.)I think the next best thing is to have a shell script that just creates an autoincrementing version number (or just the current datetime), creates a corresponding tag containing the version number, and then templates it into the corresponding file. That wouldn't even need to happen on a commit hook, I think it's fine to get into the habit of running this script before pushing my code.