diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llinventory/lleconomy.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llinventory/lleconomy.cpp')
-rw-r--r-- | linden/indra/llinventory/lleconomy.cpp | 246 |
1 files changed, 246 insertions, 0 deletions
diff --git a/linden/indra/llinventory/lleconomy.cpp b/linden/indra/llinventory/lleconomy.cpp new file mode 100644 index 0000000..2337a3e --- /dev/null +++ b/linden/indra/llinventory/lleconomy.cpp | |||
@@ -0,0 +1,246 @@ | |||
1 | /** | ||
2 | * @file lleconomy.cpp | ||
3 | * | ||
4 | * Copyright (c) 2002-2007, Linden Research, Inc. | ||
5 | * | ||
6 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
7 | * to you under the terms of the GNU General Public License, version 2.0 | ||
8 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
9 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
10 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
11 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
12 | * | ||
13 | * There are special exceptions to the terms and conditions of the GPL as | ||
14 | * it is applied to this Source Code. View the full text of the exception | ||
15 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
16 | * online at http://secondlife.com/developers/opensource/flossexception | ||
17 | * | ||
18 | * By copying, modifying or distributing this software, you acknowledge | ||
19 | * that you have read and understood your obligations described above, | ||
20 | * and agree to abide by those obligations. | ||
21 | * | ||
22 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
23 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
24 | * COMPLETENESS OR PERFORMANCE. | ||
25 | */ | ||
26 | |||
27 | #include "linden_common.h" | ||
28 | |||
29 | #include "lleconomy.h" | ||
30 | #include "llerror.h" | ||
31 | #include "message.h" | ||
32 | #include "v3math.h" | ||
33 | |||
34 | LLGlobalEconomy::LLGlobalEconomy() | ||
35 | : mObjectCount( -1 ), | ||
36 | mObjectCapacity( -1 ), | ||
37 | mPriceObjectClaim( -1 ), | ||
38 | mPricePublicObjectDecay( -1 ), | ||
39 | mPricePublicObjectDelete( -1 ), | ||
40 | mPriceEnergyUnit( -1 ), | ||
41 | mPriceUpload( -1 ), | ||
42 | mPriceRentLight( -1 ), | ||
43 | mTeleportMinPrice( -1 ), | ||
44 | mTeleportPriceExponent( -1 ), | ||
45 | mPriceGroupCreate( -1 ) | ||
46 | { } | ||
47 | |||
48 | LLGlobalEconomy::~LLGlobalEconomy() | ||
49 | { } | ||
50 | |||
51 | // static | ||
52 | void LLGlobalEconomy::processEconomyData(LLMessageSystem *msg, void** user_data) | ||
53 | { | ||
54 | S32 i; | ||
55 | F32 f; | ||
56 | |||
57 | LLGlobalEconomy *this_ptr = (LLGlobalEconomy*)user_data; | ||
58 | |||
59 | msg->getS32Fast(_PREHASH_Info, _PREHASH_ObjectCapacity, i); | ||
60 | this_ptr->setObjectCapacity(i); | ||
61 | msg->getS32Fast(_PREHASH_Info, _PREHASH_ObjectCount, i); | ||
62 | this_ptr->setObjectCount(i); | ||
63 | msg->getS32Fast(_PREHASH_Info, _PREHASH_PriceEnergyUnit, i); | ||
64 | this_ptr->setPriceEnergyUnit(i); | ||
65 | msg->getS32Fast(_PREHASH_Info, _PREHASH_PriceObjectClaim, i); | ||
66 | this_ptr->setPriceObjectClaim(i); | ||
67 | msg->getS32Fast(_PREHASH_Info, _PREHASH_PricePublicObjectDecay, i); | ||
68 | this_ptr->setPricePublicObjectDecay(i); | ||
69 | msg->getS32Fast(_PREHASH_Info, _PREHASH_PricePublicObjectDelete, i); | ||
70 | this_ptr->setPricePublicObjectDelete(i); | ||
71 | msg->getS32Fast(_PREHASH_Info, _PREHASH_PriceUpload, i); | ||
72 | this_ptr->setPriceUpload(i); | ||
73 | msg->getS32Fast(_PREHASH_Info, _PREHASH_PriceRentLight, i); | ||
74 | this_ptr->setPriceRentLight(i); | ||
75 | msg->getS32Fast(_PREHASH_Info, _PREHASH_TeleportMinPrice, i); | ||
76 | this_ptr->setTeleportMinPrice(i); | ||
77 | msg->getF32Fast(_PREHASH_Info, _PREHASH_TeleportPriceExponent, f); | ||
78 | this_ptr->setTeleportPriceExponent(f); | ||
79 | msg->getS32Fast(_PREHASH_Info, _PREHASH_PriceGroupCreate, i); | ||
80 | this_ptr->setPriceGroupCreate(i); | ||
81 | } | ||
82 | |||
83 | S32 LLGlobalEconomy::calculateTeleportCost(F32 distance) const | ||
84 | { | ||
85 | S32 min_cost = getTeleportMinPrice(); | ||
86 | F32 exponent = getTeleportPriceExponent(); | ||
87 | F32 divisor = 100.f * pow(3.f, exponent); | ||
88 | S32 cost = (U32)(distance * pow(log10(distance), exponent) / divisor); | ||
89 | if (cost < 0) | ||
90 | { | ||
91 | cost = 0; | ||
92 | } | ||
93 | else if (cost < min_cost) | ||
94 | { | ||
95 | cost = min_cost; | ||
96 | } | ||
97 | |||
98 | return cost; | ||
99 | } | ||
100 | |||
101 | S32 LLGlobalEconomy::calculateLightRent(const LLVector3& object_size) const | ||
102 | { | ||
103 | F32 intensity_mod = llmax(object_size.magVec(), 1.f); | ||
104 | return (S32)(intensity_mod * getPriceRentLight()); | ||
105 | } | ||
106 | |||
107 | void LLGlobalEconomy::print() | ||
108 | { | ||
109 | llinfos << "Global Economy Settings: " << llendl; | ||
110 | llinfos << "Object Capacity: " << mObjectCapacity << llendl; | ||
111 | llinfos << "Object Count: " << mObjectCount << llendl; | ||
112 | llinfos << "Claim Price Per Object: " << mPriceObjectClaim << llendl; | ||
113 | llinfos << "Claim Price Per Public Object: " << mPricePublicObjectDecay << llendl; | ||
114 | llinfos << "Delete Price Per Public Object: " << mPricePublicObjectDelete << llendl; | ||
115 | llinfos << "Release Price Per Public Object: " << getPricePublicObjectRelease() << llendl; | ||
116 | llinfos << "Price Per Energy Unit: " << mPriceEnergyUnit << llendl; | ||
117 | llinfos << "Price Per Upload: " << mPriceUpload << llendl; | ||
118 | llinfos << "Light Base Price: " << mPriceRentLight << llendl; | ||
119 | llinfos << "Teleport Min Price: " << mTeleportMinPrice << llendl; | ||
120 | llinfos << "Teleport Price Exponent: " << mTeleportPriceExponent << llendl; | ||
121 | llinfos << "Price for group creation: " << mPriceGroupCreate << llendl; | ||
122 | } | ||
123 | |||
124 | LLRegionEconomy::LLRegionEconomy() | ||
125 | : LLGlobalEconomy(), | ||
126 | mPriceObjectRent( -1.f ), | ||
127 | mPriceObjectScaleFactor( -1.f ), | ||
128 | mEnergyEfficiency( -1.f ), | ||
129 | mBasePriceParcelClaimDefault(-1), | ||
130 | mBasePriceParcelClaimActual(-1), | ||
131 | mPriceParcelClaimFactor(-1.f), | ||
132 | mBasePriceParcelRent(-1), | ||
133 | mAreaOwned(-1.f), | ||
134 | mAreaTotal(-1.f) | ||
135 | { } | ||
136 | |||
137 | LLRegionEconomy::~LLRegionEconomy() | ||
138 | { } | ||
139 | |||
140 | BOOL LLRegionEconomy::hasData() const | ||
141 | { | ||
142 | return (mBasePriceParcelRent != -1); | ||
143 | } | ||
144 | |||
145 | // static | ||
146 | void LLRegionEconomy::processEconomyData(LLMessageSystem *msg, void** user_data) | ||
147 | { | ||
148 | S32 i; | ||
149 | F32 f; | ||
150 | |||
151 | LLGlobalEconomy::processEconomyData(msg, user_data); | ||
152 | |||
153 | LLRegionEconomy *this_ptr = (LLRegionEconomy*)user_data; | ||
154 | |||
155 | msg->getS32Fast(_PREHASH_Info, _PREHASH_PriceParcelClaim, i); | ||
156 | this_ptr->setBasePriceParcelClaimDefault(i); | ||
157 | msg->getF32(_PREHASH_Info, _PREHASH_PriceParcelClaimFactor, f); | ||
158 | this_ptr->setPriceParcelClaimFactor(f); | ||
159 | msg->getF32Fast(_PREHASH_Info, _PREHASH_EnergyEfficiency, f); | ||
160 | this_ptr->setEnergyEfficiency(f); | ||
161 | msg->getF32Fast(_PREHASH_Info, _PREHASH_PriceObjectRent, f); | ||
162 | this_ptr->setPriceObjectRent(f); | ||
163 | msg->getF32Fast(_PREHASH_Info, _PREHASH_PriceObjectScaleFactor, f); | ||
164 | this_ptr->setPriceObjectScaleFactor(f); | ||
165 | msg->getS32Fast(_PREHASH_Info, _PREHASH_PriceParcelRent, i); | ||
166 | this_ptr->setBasePriceParcelRent(i); | ||
167 | } | ||
168 | |||
169 | // static | ||
170 | void LLRegionEconomy::processEconomyDataRequest(LLMessageSystem *msg, void **user_data) | ||
171 | { | ||
172 | LLRegionEconomy *this_ptr = (LLRegionEconomy*)user_data; | ||
173 | |||
174 | msg->newMessageFast(_PREHASH_EconomyData); | ||
175 | msg->nextBlockFast(_PREHASH_Info); | ||
176 | msg->addS32Fast(_PREHASH_ObjectCapacity, this_ptr->getObjectCapacity()); | ||
177 | msg->addS32Fast(_PREHASH_ObjectCount, this_ptr->getObjectCount()); | ||
178 | msg->addS32Fast(_PREHASH_PriceEnergyUnit, this_ptr->getPriceEnergyUnit()); | ||
179 | msg->addS32Fast(_PREHASH_PriceObjectClaim, this_ptr->getPriceObjectClaim()); | ||
180 | msg->addS32Fast(_PREHASH_PricePublicObjectDecay, this_ptr->getPricePublicObjectDecay()); | ||
181 | msg->addS32Fast(_PREHASH_PricePublicObjectDelete, this_ptr->getPricePublicObjectDelete()); | ||
182 | msg->addS32Fast(_PREHASH_PriceParcelClaim, this_ptr->mBasePriceParcelClaimActual); | ||
183 | msg->addF32Fast(_PREHASH_PriceParcelClaimFactor, this_ptr->mPriceParcelClaimFactor); | ||
184 | msg->addS32Fast(_PREHASH_PriceUpload, this_ptr->getPriceUpload()); | ||
185 | msg->addS32Fast(_PREHASH_PriceRentLight, this_ptr->getPriceRentLight()); | ||
186 | msg->addS32Fast(_PREHASH_TeleportMinPrice, this_ptr->getTeleportMinPrice()); | ||
187 | msg->addF32Fast(_PREHASH_TeleportPriceExponent, this_ptr->getTeleportPriceExponent()); | ||
188 | |||
189 | msg->addF32Fast(_PREHASH_EnergyEfficiency, this_ptr->getEnergyEfficiency()); | ||
190 | msg->addF32Fast(_PREHASH_PriceObjectRent, this_ptr->getPriceObjectRent()); | ||
191 | msg->addF32Fast(_PREHASH_PriceObjectScaleFactor, this_ptr->getPriceObjectScaleFactor()); | ||
192 | msg->addS32Fast(_PREHASH_PriceParcelRent, this_ptr->getPriceParcelRent()); | ||
193 | msg->addS32Fast(_PREHASH_PriceGroupCreate, this_ptr->getPriceGroupCreate()); | ||
194 | |||
195 | msg->sendReliable(msg->getSender()); | ||
196 | } | ||
197 | |||
198 | |||
199 | S32 LLRegionEconomy::getPriceParcelClaim() const | ||
200 | { | ||
201 | //return (S32)((F32)mBasePriceParcelClaim * (mAreaTotal / (mAreaTotal - mAreaOwned))); | ||
202 | return (S32)((F32)mBasePriceParcelClaimActual * mPriceParcelClaimFactor); | ||
203 | } | ||
204 | |||
205 | S32 LLRegionEconomy::getPriceParcelRent() const | ||
206 | { | ||
207 | return mBasePriceParcelRent; | ||
208 | } | ||
209 | |||
210 | |||
211 | void LLRegionEconomy::print() | ||
212 | { | ||
213 | this->LLGlobalEconomy::print(); | ||
214 | |||
215 | llinfos << "Region Economy Settings: " << llendl; | ||
216 | llinfos << "Land (square meters): " << mAreaTotal << llendl; | ||
217 | llinfos << "Owned Land (square meters): " << mAreaOwned << llendl; | ||
218 | llinfos << "Daily Object Rent: " << mPriceObjectRent << llendl; | ||
219 | llinfos << "Daily Land Rent (per meter): " << getPriceParcelRent() << llendl; | ||
220 | llinfos << "Energey Efficiency: " << mEnergyEfficiency << llendl; | ||
221 | } | ||
222 | |||
223 | |||
224 | void LLRegionEconomy::setBasePriceParcelClaimDefault(S32 val) | ||
225 | { | ||
226 | mBasePriceParcelClaimDefault = val; | ||
227 | if(mBasePriceParcelClaimActual == -1) | ||
228 | { | ||
229 | mBasePriceParcelClaimActual = val; | ||
230 | } | ||
231 | } | ||
232 | |||
233 | void LLRegionEconomy::setBasePriceParcelClaimActual(S32 val) | ||
234 | { | ||
235 | mBasePriceParcelClaimActual = val; | ||
236 | } | ||
237 | |||
238 | void LLRegionEconomy::setPriceParcelClaimFactor(F32 val) | ||
239 | { | ||
240 | mPriceParcelClaimFactor = val; | ||
241 | } | ||
242 | |||
243 | void LLRegionEconomy::setBasePriceParcelRent(S32 val) | ||
244 | { | ||
245 | mBasePriceParcelRent = val; | ||
246 | } | ||