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

