1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "zone_util.h"
24 #include "pacs_client.h"
25 #include "client_cfg.h"
28 using namespace NLMISC
;
29 using namespace NLPACS
;
32 // ***************************************************************************
38 // ***************************************************************************
44 // ***************************************************************************
45 COutpost::COutpost(const COutpost
&other
)
47 for(uint i
=0;i
<RZ_MAX_BUILDING_PER_OUTPOST
;i
++)
48 _Buildings
[i
]= other
._Buildings
[i
];
49 // must not have addedprims, else dtor crash
50 nlassert(other
._AddedPrims
.empty());
51 _OutpostId
= other
._OutpostId
;
52 _Village
= other
._Village
;
55 // ***************************************************************************
56 bool COutpost::setupOutpost(const CContinentParameters::CZC
&zone
, sint32 outpostId
, CVillage
*village
)
58 // Yoyo. legacy code. should no more be needed now. Still let for check (useful?)
59 NLMISC::CVector2f zonePos
;
60 if (!getPosFromZoneName(zone
.Name
, zonePos
))
62 nlwarning("Outpost : invalid zone name (%s)", zone
.Name
.c_str());
67 _OutpostId
= outpostId
;
69 // set the village for ruins display (if any)
76 // ***************************************************************************
77 void COutpost::setBuildingPosition (uint building
, const NLMISC::CQuat
&rot
, const NLMISC::CVector
&pos
)
79 // Set the building position and rotation
80 if (building
<RZ_MAX_BUILDING_PER_OUTPOST
)
82 _Buildings
[building
].Rotation
= rot
;
83 _Buildings
[building
].Position
= pos
;
86 // if a village is setuped for ruins display, setup it
88 _Village
->setBuildingPosition(building
, rot
, pos
);
91 // ***************************************************************************
92 void COutpost::initOutpost ()
94 // remove the outpost from col, if any
97 // Add collisions, if correclty setuped
100 // Register RZ_MAX_BUILDING_PER_OUTPOST observers for the RZ_MAX_BUILDING_PER_OUTPOST buildings
102 for (i
=0; i
<RZ_MAX_BUILDING_PER_OUTPOST
; i
++)
104 // Put the ZC pacs_prim
105 TPacsPrimMap::iterator pbIt
= PacsPrims
.find(NLMISC::toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension(ClientCfg
.ZCPacsPrim
)));
106 if (pbIt
!= PacsPrims
.end())
108 // Build the building matrix
109 NLMISC::CMatrix instanceMatrix
;
110 instanceMatrix
.identity();
111 instanceMatrix
.setRot(_Buildings
[i
].Rotation
);
112 instanceMatrix
.setPos(_Buildings
[i
].Position
);
114 // Compute orientation and position
117 NLPACS::UMoveContainer::getPACSCoordsFromMatrix(pos
, angle
, instanceMatrix
);
119 // insert the matching primitive block
121 PACS
->addCollisionnablePrimitiveBlock(pbIt
->second
, 0, 1, &_AddedPrims
, angle
, pos
, true, CVector(1,1,1));
128 _Village
->initOutpost();
131 // ***************************************************************************
132 void COutpost::removeOutpost ()
137 for(uint i
=0; i
<_AddedPrims
.size(); i
++)
139 PACS
->removePrimitive(_AddedPrims
[i
]);
146 _Village
->removeOutpost();