타워 이외의 건물을 건설할 수 없는 문제 수정
Lv1만 보이게 하면서, 보이는 index와 실제 index가 달라져서 발생
This commit is contained in:
@@ -185,7 +185,7 @@ namespace Northbound
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 건물 배치 요청 (클라이언트에서 호출)
|
/// 건물 배치 요청 (클라이언트에서 호출)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void RequestPlaceBuilding(int buildingIndex, Vector3 position, int rotation)
|
public void RequestPlaceBuilding(string buildingDataName, Vector3 position, int rotation)
|
||||||
{
|
{
|
||||||
if (!NetworkManager.Singleton.IsClient)
|
if (!NetworkManager.Singleton.IsClient)
|
||||||
{
|
{
|
||||||
@@ -194,11 +194,11 @@ namespace Northbound
|
|||||||
}
|
}
|
||||||
|
|
||||||
ulong clientId = NetworkManager.Singleton.LocalClientId;
|
ulong clientId = NetworkManager.Singleton.LocalClientId;
|
||||||
PlaceBuildingServerRpc(buildingIndex, position, rotation, clientId);
|
PlaceBuildingServerRpc(buildingDataName, position, rotation, clientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
|
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
|
||||||
private void PlaceBuildingServerRpc(int buildingIndex, Vector3 position, int rotation, ulong requestingClientId)
|
private void PlaceBuildingServerRpc(string buildingDataName, Vector3 position, int rotation, ulong requestingClientId)
|
||||||
{
|
{
|
||||||
// 보안 검증 1: 유효한 클라이언트인지 확인
|
// 보안 검증 1: 유효한 클라이언트인지 확인
|
||||||
if (!NetworkManager.Singleton.ConnectedClients.ContainsKey(requestingClientId))
|
if (!NetworkManager.Singleton.ConnectedClients.ContainsKey(requestingClientId))
|
||||||
@@ -206,17 +206,18 @@ namespace Northbound
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 보안 검증 2: 건물 인덱스 유효성 확인
|
// 보안 검증 2: 건물 데이터 찾기 (이름으로 검색)
|
||||||
if (buildingIndex < 0 || buildingIndex >= availableBuildings.Count)
|
TowerData data = availableBuildings.Find(b => b != null && b.name == buildingDataName);
|
||||||
|
if (data == null)
|
||||||
{
|
{
|
||||||
|
Debug.LogWarning($"[BuildingManager] 건물 데이터를 찾을 수 없습니다: {buildingDataName}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TowerData data = availableBuildings[buildingIndex];
|
// 보안 검증 3: 프리팹 확인
|
||||||
|
if (data.prefab == null)
|
||||||
// 보안 검증 3: 건물 데이터 유효성 확인
|
|
||||||
if (data == null || data.prefab == null)
|
|
||||||
{
|
{
|
||||||
|
Debug.LogWarning($"[BuildingManager] 건물 프리팹이 없습니다: {buildingDataName}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +343,7 @@ namespace Northbound
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 건물 토대 배치 요청 (클라이언트에서 호출)
|
/// 건물 토대 배치 요청 (클라이언트에서 호출)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void RequestPlaceFoundation(int buildingIndex, Vector3 position, int rotation)
|
public void RequestPlaceFoundation(string buildingDataName, Vector3 position, int rotation)
|
||||||
{
|
{
|
||||||
if (!NetworkManager.Singleton.IsClient)
|
if (!NetworkManager.Singleton.IsClient)
|
||||||
{
|
{
|
||||||
@@ -351,11 +352,11 @@ namespace Northbound
|
|||||||
}
|
}
|
||||||
|
|
||||||
ulong clientId = NetworkManager.Singleton.LocalClientId;
|
ulong clientId = NetworkManager.Singleton.LocalClientId;
|
||||||
PlaceFoundationServerRpc(buildingIndex, position, rotation, clientId);
|
PlaceFoundationServerRpc(buildingDataName, position, rotation, clientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
|
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
|
||||||
private void PlaceFoundationServerRpc(int buildingIndex, Vector3 position, int rotation, ulong requestingClientId)
|
private void PlaceFoundationServerRpc(string buildingDataName, Vector3 position, int rotation, ulong requestingClientId)
|
||||||
{
|
{
|
||||||
// 보안 검증 1: 유효한 클라이언트인지 확인
|
// 보안 검증 1: 유효한 클라이언트인지 확인
|
||||||
if (!NetworkManager.Singleton.ConnectedClients.ContainsKey(requestingClientId))
|
if (!NetworkManager.Singleton.ConnectedClients.ContainsKey(requestingClientId))
|
||||||
@@ -363,17 +364,11 @@ namespace Northbound
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 보안 검증 2: 건물 인덱스 유효성 확인
|
// 보안 검증 2: 건물 데이터 찾기 (이름으로 검색)
|
||||||
if (buildingIndex < 0 || buildingIndex >= availableBuildings.Count)
|
TowerData data = availableBuildings.Find(b => b != null && b.name == buildingDataName);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TowerData data = availableBuildings[buildingIndex];
|
|
||||||
|
|
||||||
// 보안 검증 3: 건물 데이터 유효성 확인
|
|
||||||
if (data == null)
|
if (data == null)
|
||||||
{
|
{
|
||||||
|
Debug.LogWarning($"[BuildingManager] 건물 데이터를 찾을 수 없습니다: {buildingDataName}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -603,7 +603,7 @@ namespace Northbound
|
|||||||
var coreResourceManager = CoreResourceManager.Instance;
|
var coreResourceManager = CoreResourceManager.Instance;
|
||||||
if (coreResourceManager == null || coreResourceManager.CanAfford(selectedData.mana))
|
if (coreResourceManager == null || coreResourceManager.CanAfford(selectedData.mana))
|
||||||
{
|
{
|
||||||
BuildingManager.Instance.RequestPlaceFoundation(selectedBuildingIndex, groundPosition, currentRotation);
|
BuildingManager.Instance.RequestPlaceFoundation(selectedData.name, groundPosition, currentRotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -620,7 +620,7 @@ namespace Northbound
|
|||||||
|
|
||||||
foreach (var position in dragBuildingPositions)
|
foreach (var position in dragBuildingPositions)
|
||||||
{
|
{
|
||||||
BuildingManager.Instance.RequestPlaceFoundation(selectedBuildingIndex, position, currentRotation);
|
BuildingManager.Instance.RequestPlaceFoundation(selectedData.name, position, currentRotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -659,8 +659,8 @@ namespace Northbound
|
|||||||
|
|
||||||
if (BuildingManager.Instance.IsValidPlacement(selectedData, hit.point, currentRotation, out Vector3 groundPosition))
|
if (BuildingManager.Instance.IsValidPlacement(selectedData, hit.point, currentRotation, out Vector3 groundPosition))
|
||||||
{
|
{
|
||||||
// 토대 배치 요청
|
// 토대 배치 요청 (건물 이름 사용)
|
||||||
BuildingManager.Instance.RequestPlaceFoundation(selectedBuildingIndex, groundPosition, currentRotation);
|
BuildingManager.Instance.RequestPlaceFoundation(selectedData.name, groundPosition, currentRotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user