Fixing logger and windows version - remove terminal
This commit is contained in:
1 parent
76287dda46
commit
a7d17d9afd
27 files changed
+349
-243
No files matched your search
+51
-51
@@ -148,7 +148,7 @@ namespace ZL
|
||||
player->setTarget(params.playerPosition);
|
||||
player->setupHitSparks(sparkTexture);
|
||||
player->audioPlayer = audioPlayer;
|
||||
std::cout << "Load resurces step 9" << std::endl;
|
||||
logger() << "Load resurces step 9" << std::endl;
|
||||
SDL_PumpEvents();
|
||||
|
||||
// Load NPCs from JSON. Aggressive (canAttack) NPCs need a player target
|
||||
@@ -287,7 +287,7 @@ namespace ZL
|
||||
teleportZones.push_back(std::move(tz));
|
||||
}
|
||||
|
||||
std::cout << "[TELEPORT] Loaded " << teleportZones.size() << " teleport(s) from " << jsonPath << std::endl;
|
||||
logger() << "[TELEPORT] Loaded " << teleportZones.size() << " teleport(s) from " << jsonPath << std::endl;
|
||||
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ namespace ZL
|
||||
}
|
||||
|
||||
|
||||
std::cout << "[TRIGGER] Loaded " << triggerZones.size() << " trigger zone(s) from " << jsonPath << std::endl;
|
||||
logger() << "[TRIGGER] Loaded " << triggerZones.size() << " trigger zone(s) from " << jsonPath << std::endl;
|
||||
}
|
||||
|
||||
void Location::loadPointLights(const std::string& jsonPath, const char* zipFile)
|
||||
@@ -400,7 +400,7 @@ namespace ZL
|
||||
pointLights.push_back(std::move(pl));
|
||||
}
|
||||
|
||||
std::cout << "[LIGHTS] Loaded " << pointLights.size() << " light(s) from " << jsonPath << std::endl;
|
||||
logger() << "[LIGHTS] Loaded " << pointLights.size() << " light(s) from " << jsonPath << std::endl;
|
||||
}
|
||||
|
||||
void Location::updateTriggerZones(const Eigen::Vector3f& playerPos)
|
||||
@@ -500,28 +500,28 @@ namespace ZL
|
||||
if (editorMode == EditorMode::Navigation) {
|
||||
editor.buildNavMeshes();
|
||||
}
|
||||
std::cout << "[NAV] Switched to navigation map " << index << "\n";
|
||||
logger() << "[NAV] Switched to navigation map " << index << "\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
InteractiveObject* Location::raycastInteractiveObjects(const Eigen::Vector3f& rayOrigin, const Eigen::Vector3f& rayDir) {
|
||||
if (interactiveObjects.empty()) {
|
||||
//std::cout << "[RAYCAST] No interactive objects to check" << std::endl;
|
||||
//logger() << "[RAYCAST] No interactive objects to check" << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//std::cout << "[RAYCAST] Starting raycast with " << interactiveObjects.size() << " objects" << std::endl;
|
||||
//std::cout << "[RAYCAST] Ray origin: (" << rayOrigin.x() << ", " << rayOrigin.y() << ", " << rayOrigin.z() << ")" << std::endl;
|
||||
//std::cout << "[RAYCAST] Ray dir: (" << rayDir.x() << ", " << rayDir.y() << ", " << rayDir.z() << ")" << std::endl;
|
||||
//logger() << "[RAYCAST] Starting raycast with " << interactiveObjects.size() << " objects" << std::endl;
|
||||
//logger() << "[RAYCAST] Ray origin: (" << rayOrigin.x() << ", " << rayOrigin.y() << ", " << rayOrigin.z() << ")" << std::endl;
|
||||
//logger() << "[RAYCAST] Ray dir: (" << rayDir.x() << ", " << rayDir.y() << ", " << rayDir.z() << ")" << std::endl;
|
||||
|
||||
float closestDistance = FLT_MAX;
|
||||
InteractiveObject* closestObject = nullptr;
|
||||
|
||||
for (auto& intObj : interactiveObjects) {
|
||||
//std::cout << "[RAYCAST] Checking object: " << intObj.loadedObject.name << " (active: " << intObj.isActive << ")" << std::endl;
|
||||
//logger() << "[RAYCAST] Checking object: " << intObj.loadedObject.name << " (active: " << intObj.isActive << ")" << std::endl;
|
||||
|
||||
if (!intObj.state.isActive || intObj.state.isAnimating) {
|
||||
//std::cout << "[RAYCAST] -> Object inactive or animating, skipping" << std::endl;
|
||||
//logger() << "[RAYCAST] -> Object inactive or animating, skipping" << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -531,7 +531,7 @@ namespace ZL
|
||||
if (!intObj.loadedObject.texture) continue;
|
||||
}
|
||||
|
||||
//std::cout << "[RAYCAST] Position: (" << intObj.position.x() << ", " << intObj.position.y() << ", "
|
||||
//logger() << "[RAYCAST] Position: (" << intObj.position.x() << ", " << intObj.position.y() << ", "
|
||||
// << intObj.position.z() << "), Radius: " << intObj.interactionRadius << std::endl;
|
||||
|
||||
const bool hasBox = !(intObj.state.boundsMin.isZero() && intObj.state.boundsMax.isZero());
|
||||
@@ -581,10 +581,10 @@ namespace ZL
|
||||
}
|
||||
/*
|
||||
if (closestObject) {
|
||||
std::cout << "[RAYCAST] *** RAYCAST SUCCESS: Found object " << closestObject->loadedObject.name << " ***" << std::endl;
|
||||
logger() << "[RAYCAST] *** RAYCAST SUCCESS: Found object " << closestObject->loadedObject.name << " ***" << std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "[RAYCAST] No objects hit" << std::endl;
|
||||
logger() << "[RAYCAST] No objects hit" << std::endl;
|
||||
}
|
||||
*/
|
||||
return closestObject;
|
||||
@@ -600,11 +600,11 @@ namespace ZL
|
||||
Character* closestNpc = nullptr;
|
||||
float closestDist = maxDistance;
|
||||
|
||||
//std::cout << "[RAYCAST_NPC] Starting raycast with " << npcs.size() << " npcs" << std::endl;
|
||||
//logger() << "[RAYCAST_NPC] Starting raycast with " << npcs.size() << " npcs" << std::endl;
|
||||
|
||||
for (auto& npc : npcs) {
|
||||
if (npc->getHp() <= 0.f) {
|
||||
//std::cout << "[RAYCAST_NPC] " << npc->state.npcId << " is dead, skipping" << std::endl;
|
||||
//logger() << "[RAYCAST_NPC] " << npc->state.npcId << " is dead, skipping" << std::endl;
|
||||
continue;
|
||||
}
|
||||
if (!npc->state.enabled) continue;
|
||||
@@ -640,7 +640,7 @@ namespace ZL
|
||||
|
||||
if (entryT > exitT) continue;
|
||||
|
||||
//std::cout << "[RAYCAST_NPC] " << npc->npcId << " hit at t=" << entryT << std::endl;
|
||||
//logger() << "[RAYCAST_NPC] " << npc->npcId << " hit at t=" << entryT << std::endl;
|
||||
|
||||
if (entryT < closestDist) {
|
||||
closestDist = entryT;
|
||||
@@ -649,10 +649,10 @@ namespace ZL
|
||||
}
|
||||
|
||||
if (closestNpc) {
|
||||
//std::cout << "[RAYCAST_NPC] HIT: " << closestNpc->npcId << std::endl;
|
||||
//logger() << "[RAYCAST_NPC] HIT: " << closestNpc->npcId << std::endl;
|
||||
}
|
||||
else {
|
||||
//std::cout << "[RAYCAST_NPC] No NPC hit" << std::endl;
|
||||
//logger() << "[RAYCAST_NPC] No NPC hit" << std::endl;
|
||||
}
|
||||
|
||||
return closestNpc;
|
||||
@@ -1603,7 +1603,7 @@ namespace ZL
|
||||
|
||||
if (npc->state.enabled && npc->state.canAttack && (!npc->state.pathWaypoints.empty() || npc->state.battle_state != 0) && npc->getHp() > 0.f)
|
||||
{
|
||||
//std::cout << "[NPC] NPC '" << npc->state.npcId << "' is attacking target index " << npc->state.attackTargetIndex << std::endl;
|
||||
//logger() << "[NPC] NPC '" << npc->state.npcId << "' is attacking target index " << npc->state.attackTargetIndex << std::endl;
|
||||
npcAttacking = true;
|
||||
}
|
||||
}
|
||||
@@ -1640,17 +1640,17 @@ namespace ZL
|
||||
|
||||
// If player is close enough to pick up the item
|
||||
if (distToObject <= obj->state.approachRadius) {
|
||||
std::cout << "[PICKUP] Player reached object! Distance: " << distToObject << std::endl;
|
||||
std::cout << "[PICKUP] Calling Lua callback for: " << obj->loadedObject.name << std::endl;
|
||||
logger() << "[PICKUP] Player reached object! Distance: " << distToObject << std::endl;
|
||||
logger() << "[PICKUP] Calling Lua callback for: " << obj->loadedObject.name << std::endl;
|
||||
|
||||
// Call custom activate function if specified, otherwise use fallback
|
||||
try {
|
||||
if (!obj->state.activateFunctionName.empty()) {
|
||||
std::cout << "[PICKUP] Using custom function: " << obj->state.activateFunctionName << std::endl;
|
||||
logger() << "[PICKUP] Using custom function: " << obj->state.activateFunctionName << std::endl;
|
||||
scriptEngine.callActivateFunction(obj->state.activateFunctionName);
|
||||
}
|
||||
else {
|
||||
std::cout << "[PICKUP] Using fallback callback" << std::endl;
|
||||
logger() << "[PICKUP] Using fallback callback" << std::endl;
|
||||
scriptEngine.callItemPickupCallback(obj->loadedObject.name);
|
||||
}
|
||||
}
|
||||
@@ -1666,7 +1666,7 @@ namespace ZL
|
||||
if (state.targetInteractNpcIndex >= 0 && player) {
|
||||
float distToNpc = (player->state.position - npcs[state.targetInteractNpcIndex]->state.position).norm();
|
||||
if (distToNpc <= NPC_TALK_DISTANCE) {
|
||||
std::cout << "[NPC] Player reached NPC index " << state.targetInteractNpcIndex
|
||||
logger() << "[NPC] Player reached NPC index " << state.targetInteractNpcIndex
|
||||
<< " (distance " << distToNpc << "); firing on_npc_interact" << std::endl;
|
||||
// Stop the player at the talk distance and have the NPC turn to face them.
|
||||
player->setTarget(player->state.position);
|
||||
@@ -1686,7 +1686,7 @@ namespace ZL
|
||||
if (auto* tz = getTargetTeleportZone(); tz && player) {
|
||||
float dist = (player->state.position - tz->position).norm();
|
||||
if (dist <= tz->radius) {
|
||||
std::cout << "[TELEPORT] Player reached teleport zone '" << tz->id << "'" << std::endl;
|
||||
logger() << "[TELEPORT] Player reached teleport zone '" << tz->id << "'" << std::endl;
|
||||
if (onTeleport) onTeleport(tz->destinationLocation, tz->destinationPosition, tz->destinationRotationY);
|
||||
state.targetTeleportZoneIndex = -1;
|
||||
return;
|
||||
@@ -1710,7 +1710,7 @@ namespace ZL
|
||||
const bool isInside = (dist <= autoR);
|
||||
if (isInside && !tz.automaticPlayerInside) {
|
||||
tz.automaticPlayerInside = true;
|
||||
std::cout << "[TELEPORT] Auto-teleport triggered by zone '" << tz.id << "'" << std::endl;
|
||||
logger() << "[TELEPORT] Auto-teleport triggered by zone '" << tz.id << "'" << std::endl;
|
||||
if (onTeleport) onTeleport(tz.destinationLocation, tz.destinationPosition, tz.destinationRotationY);
|
||||
return;
|
||||
} else if (!isInside) {
|
||||
@@ -1743,10 +1743,10 @@ namespace ZL
|
||||
toTarget.y() = 0.f;
|
||||
if (toTarget.norm() < car.waypointReachRadius) {
|
||||
car.currentWaypoint = car.currentWaypoint + 1;
|
||||
std::cout << "Waypoint current: " << car.currentWaypoint << std::endl;
|
||||
logger() << "Waypoint current: " << car.currentWaypoint << std::endl;
|
||||
if (car.currentWaypoint == car.waypoints.size())
|
||||
{
|
||||
std::cout << "waypointsOver" << std::endl;
|
||||
logger() << "waypointsOver" << std::endl;
|
||||
waypointsOver = true;
|
||||
}
|
||||
}
|
||||
@@ -1895,17 +1895,17 @@ namespace ZL
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "[CLICK] Camera position: (" << camPos.x() << ", " << camPos.y() << ", " << camPos.z() << ")" << std::endl;
|
||||
std::cout << "[CLICK] Ray direction: (" << rayDir.x() << ", " << rayDir.y() << ", " << rayDir.z() << ")" << std::endl;
|
||||
//logger() << "[CLICK] Camera position: (" << camPos.x() << ", " << camPos.y() << ", " << camPos.z() << ")" << std::endl;
|
||||
//logger() << "[CLICK] Ray direction: (" << rayDir.x() << ", " << rayDir.y() << ", " << rayDir.z() << ")" << std::endl;
|
||||
|
||||
// First check if we clicked on interactive object
|
||||
InteractiveObject* clickedObject = raycastInteractiveObjects(camPos, rayDir);
|
||||
if (clickedObject && player && clickedObject->state.isActive) {
|
||||
std::cout << "[CLICK] *** SUCCESS: Clicked on interactive object: " << clickedObject->loadedObject.name << " ***" << std::endl;
|
||||
std::cout << "[CLICK] Object position: (" << clickedObject->state.position.x() << ", "
|
||||
<< clickedObject->state.position.y() << ", " << clickedObject->state.position.z() << ")" << std::endl;
|
||||
std::cout << "[CLICK] Player position: (" << player->state.position.x() << ", "
|
||||
<< player->state.position.y() << ", " << player->state.position.z() << ")" << std::endl;
|
||||
//logger() << "[CLICK] *** SUCCESS: Clicked on interactive object: " << clickedObject->loadedObject.name << " ***" << std::endl;
|
||||
//logger() << "[CLICK] Object position: (" << clickedObject->state.position.x() << ", "
|
||||
// << clickedObject->state.position.y() << ", " << clickedObject->state.position.z() << ")" << std::endl;
|
||||
//logger() << "[CLICK] Player position: (" << player->state.position.x() << ", "
|
||||
// << player->state.position.y() << ", " << player->state.position.z() << ")" << std::endl;
|
||||
|
||||
state.targetInteractiveObjectIndex = findInteractiveObjectIndex(clickedObject);
|
||||
state.targetInteractNpcIndex = -1;
|
||||
@@ -1914,11 +1914,11 @@ namespace ZL
|
||||
? clickedObject->state.interactionPosition
|
||||
: clickedObject->state.position);
|
||||
player->state.attackTargetIndex = CharacterState::kNoTarget;
|
||||
std::cout << "[CLICK] Player moving to object..." << std::endl;
|
||||
//logger() << "[CLICK] Player moving to object..." << std::endl;
|
||||
}
|
||||
else {
|
||||
|
||||
//std::cout << "Raycast npc step 1" << std::endl;
|
||||
//logger() << "Raycast npc step 1" << std::endl;
|
||||
// Check if we clicked on an NPC
|
||||
Character* clickedNpc = raycastNpcs(camPos, rayDir);
|
||||
if (clickedNpc && player) {
|
||||
@@ -1931,25 +1931,25 @@ namespace ZL
|
||||
}
|
||||
}
|
||||
if (npcIndex != -1) {
|
||||
//std::cout << "Raycast npc step 2" << std::endl;
|
||||
//logger() << "Raycast npc step 2" << std::endl;
|
||||
state.targetInteractiveObjectIndex = -1;
|
||||
state.targetTeleportZoneIndex = -1;
|
||||
|
||||
if (clickedNpc->state.canAttack) {
|
||||
//std::cout << "Raycast npc step 3" << std::endl;
|
||||
//std::cout << "player->state.attackTargetIndex=" << player->state.attackTargetIndex << std::endl;
|
||||
//std::cout << "npcIndex=" << npcIndex << std::endl;
|
||||
//logger() << "Raycast npc step 3" << std::endl;
|
||||
//logger() << "player->state.attackTargetIndex=" << player->state.attackTargetIndex << std::endl;
|
||||
//logger() << "npcIndex=" << npcIndex << std::endl;
|
||||
// Hostile NPC: combat logic walks the player in via attackTargetIndex.
|
||||
if (lastPlayerAttackTarget == npcIndex)
|
||||
{
|
||||
//std::cout << "Raycast npc step 4" << std::endl;
|
||||
//logger() << "Raycast npc step 4" << std::endl;
|
||||
player->tryAttackCombo();
|
||||
}
|
||||
player->state.attackTargetIndex = npcIndex;
|
||||
state.targetInteractNpcIndex = -1;
|
||||
|
||||
if (distance <= clickedNpc->state.interactionRadius) {
|
||||
std::cout << "[CLICK] Hostile NPC " << npcIndex << " in range; firing on_npc_interact" << std::endl;
|
||||
//logger() << "[CLICK] Hostile NPC " << npcIndex << " in range; firing on_npc_interact" << std::endl;
|
||||
scriptEngine.callNpcInteractCallback(npcIndex);
|
||||
}
|
||||
}
|
||||
@@ -1959,15 +1959,15 @@ namespace ZL
|
||||
|
||||
if (distance <= NPC_TALK_DISTANCE) {
|
||||
// Already in talk range — fire immediately, stop, and face the player.
|
||||
std::cout << "[CLICK] *** SUCCESS: Clicked on NPC index: " << npcIndex << " (in range) ***" << std::endl;
|
||||
//logger() << "[CLICK] *** SUCCESS: Clicked on NPC index: " << npcIndex << " (in range) ***" << std::endl;
|
||||
player->setTarget(player->state.position);
|
||||
npcs[npcIndex]->state.faceTargetIndex = CharacterState::kPlayerIndex;
|
||||
scriptEngine.callNpcInteractCallback(npcIndex);
|
||||
state.targetInteractNpcIndex = -1;
|
||||
}
|
||||
else {
|
||||
std::cout << "[CLICK] NPC " << npcIndex << " out of talk range (distance " << distance
|
||||
<< " > " << NPC_TALK_DISTANCE << "); walking to NPC..." << std::endl;
|
||||
//logger() << "[CLICK] NPC " << npcIndex << " out of talk range (distance " << distance
|
||||
// << " > " << NPC_TALK_DISTANCE << "); walking to NPC..." << std::endl;
|
||||
player->setTarget(clickedNpc->state.position);
|
||||
state.targetInteractNpcIndex = npcIndex;
|
||||
}
|
||||
@@ -1979,7 +1979,7 @@ namespace ZL
|
||||
// Unproject click to ground plane for walk target / teleport detection
|
||||
float t = -camPos.y() / rayDir.y();
|
||||
Eigen::Vector3f hit = camPos + rayDir * t;
|
||||
std::cout << "[CLICK] Clicked on ground at: (" << hit.x() << ", " << hit.z() << ")" << std::endl;
|
||||
//logger() << "[CLICK] Clicked on ground at: (" << hit.x() << ", " << hit.z() << ")" << std::endl;
|
||||
|
||||
TeleportZone* clickedTeleport = nullptr;
|
||||
for (auto& tz : teleportZones) {
|
||||
@@ -1989,7 +1989,7 @@ namespace ZL
|
||||
}
|
||||
|
||||
if (clickedTeleport) {
|
||||
std::cout << "[CLICK] Clicked teleport zone '" << clickedTeleport->id << "'" << std::endl;
|
||||
//logger() << "[CLICK] Clicked teleport zone '" << clickedTeleport->id << "'" << std::endl;
|
||||
state.targetTeleportZoneIndex = findTeleportZoneIndex(clickedTeleport);
|
||||
state.targetInteractiveObjectIndex = -1;
|
||||
state.targetInteractNpcIndex = -1;
|
||||
@@ -2004,10 +2004,10 @@ namespace ZL
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cout << "[CLICK] No valid target found" << std::endl;
|
||||
//logger() << "[CLICK] No valid target found" << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << "========================================\n" << std::endl;
|
||||
//logger() << "========================================\n" << std::endl;
|
||||
}
|
||||
void Location::handleUp(int64_t fingerId, int mx, int my)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user