Skip to content

Conversation

@ststl-s
Copy link
Contributor

@ststl-s ststl-s commented Sep 8, 2022

In a multiplayer map, set trigger owner as '4475'-'4482' is player@A-player@G. If player nonexist, trigger will be desotroyed.

@github-actions
Copy link

github-actions bot commented Sep 8, 2022

Nightly build for this pull request:

@secsome
Copy link
Member

secsome commented Sep 9, 2022

The current approach is not quite good in fact, we don't need a std::map for just 8 fixed-size players.

@ststl-s
Copy link
Contributor Author

ststl-s commented Sep 10, 2022

The current approach is not quite good in fact, we don't need a std::map for just 8 fixed-size players.

It is a mapping from TriggerType to MP. Is there any better way?

@secsome
Copy link
Member

secsome commented Sep 16, 2022

// PR #746: [QOL] Trigger owner can set as player of multiplayer game map.
DEFINE_HOOK(0x7272B5, TriggerTypeClass_FillIn_HouseType, 0x6)
{
	GET(int, nIndex, EAX);

	// Only if the house wasn't found
	if (nIndex == -1)
	{
		GET(const char*, pString, ECX);
		nIndex = HouseClass::GetPlayerAtFromString(pString);
		if (nIndex == -1)
		{
			nIndex = atoi(pString);

			if (nIndex == -1)
				nIndex = 0; // process it like <none>
		}

		if (HouseClass::IsPlayerAtType(nIndex))
		{
			if (auto pHouse = HouseClass::FindByPlayerAt(nIndex))
				nIndex = pHouse->Type->ArrayIndex;
		}
		else
			nIndex = 0;

		R->EAX(nIndex);
	}

	return 0;
}

@ststl-s
Copy link
Contributor Author

ststl-s commented Sep 17, 2022

// PR #746: [QOL] Trigger owner can set as player of multiplayer game map.
DEFINE_HOOK(0x7272B5, TriggerTypeClass_FillIn_HouseType, 0x6)
{
	GET(int, nIndex, EAX);

	// Only if the house wasn't found
	if (nIndex == -1)
	{
		GET(const char*, pString, ECX);
		nIndex = HouseClass::GetPlayerAtFromString(pString);
		if (nIndex == -1)
		{
			nIndex = atoi(pString);

			if (nIndex == -1)
				nIndex = 0; // process it like <none>
		}

		if (HouseClass::IsPlayerAtType(nIndex))
		{
			if (auto pHouse = HouseClass::FindByPlayerAt(nIndex))
				nIndex = pHouse->Type->ArrayIndex;
		}
		else
			nIndex = 0;

		R->EAX(nIndex);
	}

	return 0;
}

I don't quite understand this method. Two players from the same country can only find the first player to select this country through HouseClass:: FindByCountryIndex, so I need to establish a corresponding relationship between TriggerType and Player. The TriggerType's member is HouseTypeClass*, and it is not sure which player it is. Unless I directly assign an MP reference like 4475 to this pointer, although this can be achieved, it seems that it is not a good practice to assign integer values to pointer types.

@ststl-s
Copy link
Contributor Author

ststl-s commented Sep 17, 2022

我不太能理解这个。。据我所知,多人游戏里如果按照国家类型只能找到第一个选择了这个国家的玩家,所以我才需要建立一个TriggerType 到玩家的对应关系,而TriggerType的成员只有一个HouseTypeClass* House,这样没法对应到具体的一个玩家上。当然也可以直接把4475这些值赋值到这个HouseTypeClass* House上并且保留TriggerClass::FireActionsTriggerClass::RaiseEvent中关于寻找House实体的钩子,这样可以省去额外用一个map或者其它什么容器的麻烦,只是觉得把整形赋值给指针不太好。

@Starkku Starkku force-pushed the develop branch 2 times, most recently from aae92fd to a32076e Compare June 3, 2023 10:14
@Metadorius Metadorius requested a review from ZivDero July 7, 2024 14:13
@Starkku Starkku force-pushed the develop branch 2 times, most recently from b429215 to 280b1c8 Compare June 29, 2025 19:13
@TaranDahl TaranDahl added ⚙️T1 T1 maintainer review is sufficient Needs discussion ❓Unhardcoding / Customization Make something more tweakable labels Nov 27, 2025
@TaranDahl
Copy link
Contributor

To discuss: whether this is a duplicate of #1853

@TaranDahl
Copy link
Contributor

After communicating with the author @ststl-s, I decided to close this PR. The relevant functions will be implemented in PR 1853.

@TaranDahl TaranDahl closed this Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs testing ⚙️T1 T1 maintainer review is sufficient ❓Unhardcoding / Customization Make something more tweakable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants