aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llworld.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:54 -0500
committerJacek Antonelli2008-08-15 23:44:54 -0500
commitb2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch)
tree3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/newview/llworld.cpp
parentSecond Life viewer sources 1.14.0.1 (diff)
downloadmeta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz
Second Life viewer sources 1.15.0.2
Diffstat (limited to 'linden/indra/newview/llworld.cpp')
-rw-r--r--linden/indra/newview/llworld.cpp310
1 files changed, 147 insertions, 163 deletions
diff --git a/linden/indra/newview/llworld.cpp b/linden/indra/newview/llworld.cpp
index cf85eab..9c71ee4 100644
--- a/linden/indra/newview/llworld.cpp
+++ b/linden/indra/newview/llworld.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -30,6 +31,7 @@
30#include "llworld.h" 31#include "llworld.h"
31 32
32#include "indra_constants.h" 33#include "indra_constants.h"
34#include "llstl.h"
33 35
34#include "llagent.h" 36#include "llagent.h"
35#include "llviewercontrol.h" 37#include "llviewercontrol.h"
@@ -109,8 +111,7 @@ LLWorld::LLWorld(const U32 grids_per_region, const F32 meters_per_grid)
109LLWorld::~LLWorld() 111LLWorld::~LLWorld()
110{ 112{
111 gObjectList.killAllObjects(); 113 gObjectList.killAllObjects();
112 114 for_each(mRegionList.begin(), mRegionList.end(), DeletePointer());
113 mRegionList.deleteAllData();
114} 115}
115 116
116 117
@@ -170,9 +171,9 @@ LLViewerRegion* LLWorld::addRegion(const U64 &region_handle, const LLHost &host)
170 regionp->mCloudLayer.setWidth((F32)mWidth); 171 regionp->mCloudLayer.setWidth((F32)mWidth);
171 regionp->mCloudLayer.setWindPointer(&regionp->mWind); 172 regionp->mCloudLayer.setWindPointer(&regionp->mWind);
172 173
173 mRegionList.addData(regionp); 174 mRegionList.push_back(regionp);
174 mActiveRegionList.addData(regionp); 175 mActiveRegionList.push_back(regionp);
175 mCulledRegionList.addData(regionp); 176 mCulledRegionList.push_back(regionp);
176 177
177 178
178 // Find all the adjacent regions, and attach them. 179 // Find all the adjacent regions, and attach them.
@@ -224,9 +225,10 @@ void LLWorld::removeRegion(const LLHost &host)
224 225
225 if (regionp == gAgent.getRegion()) 226 if (regionp == gAgent.getRegion())
226 { 227 {
227 LLViewerRegion *reg; 228 for (region_list_t::iterator iter = mRegionList.begin();
228 for (reg = mRegionList.getFirstData(); reg; reg = mRegionList.getNextData()) 229 iter != mRegionList.end(); ++iter)
229 { 230 {
231 LLViewerRegion* reg = *iter;
230 llwarns << "RegionDump: " << reg->getName() 232 llwarns << "RegionDump: " << reg->getName()
231 << " " << reg->getHost() 233 << " " << reg->getHost()
232 << " " << reg->getOriginGlobal() 234 << " " << reg->getOriginGlobal()
@@ -249,42 +251,23 @@ void LLWorld::removeRegion(const LLHost &host)
249 from_region_handle(regionp->getHandle(), &x, &y); 251 from_region_handle(regionp->getHandle(), &x, &y);
250 llinfos << "Removing region " << x << ":" << y << llendl; 252 llinfos << "Removing region " << x << ":" << y << llendl;
251 253
252 // This code can probably be blitzed now... 254 mRegionList.remove(regionp);
253 if (!mRegionList.removeData(regionp)) 255 mActiveRegionList.remove(regionp);
254 { 256 mCulledRegionList.remove(regionp);
255 for (regionp = mRegionList.getFirstData(); regionp; regionp = mRegionList.getNextData()) 257 mVisibleRegionList.remove(regionp);
256 { 258
257 llwarns << "RegionDump: " << regionp->getName()
258 << " " << regionp->getHost()
259 << " " << regionp->getOriginGlobal()
260 << llendl;
261 }
262
263 llerrs << "Region list is broken" << llendl;
264 }
265
266 if (!mActiveRegionList.removeData(regionp))
267 {
268 llwarns << "LLWorld.mActiveRegionList is broken." << llendl;
269 }
270 if (!mCulledRegionList.removeData(regionp))
271 {
272 if (!mVisibleRegionList.removeData(regionp))
273 {
274 llwarns << "LLWorld.mCulled/mVisibleRegionList are broken" << llendl;;
275 }
276 }
277 delete regionp; 259 delete regionp;
278 260
279 updateWaterObjects(); 261 updateWaterObjects();
280} 262}
281 263
282 264
283LLViewerRegion *LLWorld::getRegion(const LLHost &host) 265LLViewerRegion* LLWorld::getRegion(const LLHost &host)
284{ 266{
285 LLViewerRegion *regionp; 267 for (region_list_t::iterator iter = mRegionList.begin();
286 for (regionp = mRegionList.getFirstData(); regionp; regionp = mRegionList.getNextData()) 268 iter != mRegionList.end(); ++iter)
287 { 269 {
270 LLViewerRegion* regionp = *iter;
288 if (regionp->getHost() == host) 271 if (regionp->getHost() == host)
289 { 272 {
290 return regionp; 273 return regionp;
@@ -293,16 +276,17 @@ LLViewerRegion *LLWorld::getRegion(const LLHost &host)
293 return NULL; 276 return NULL;
294} 277}
295 278
296LLViewerRegion *LLWorld::getRegionFromPosAgent(const LLVector3 &pos) 279LLViewerRegion* LLWorld::getRegionFromPosAgent(const LLVector3 &pos)
297{ 280{
298 return getRegionFromPosGlobal(gAgent.getPosGlobalFromAgent(pos)); 281 return getRegionFromPosGlobal(gAgent.getPosGlobalFromAgent(pos));
299} 282}
300 283
301LLViewerRegion *LLWorld::getRegionFromPosGlobal(const LLVector3d &pos) 284LLViewerRegion* LLWorld::getRegionFromPosGlobal(const LLVector3d &pos)
302{ 285{
303 LLViewerRegion *regionp; 286 for (region_list_t::iterator iter = mRegionList.begin();
304 for (regionp = mRegionList.getFirstData(); regionp; regionp = mRegionList.getNextData()) 287 iter != mRegionList.end(); ++iter)
305 { 288 {
289 LLViewerRegion* regionp = *iter;
306 if (regionp->pointInRegionGlobal(pos)) 290 if (regionp->pointInRegionGlobal(pos))
307 { 291 {
308 return regionp; 292 return regionp;
@@ -376,11 +360,12 @@ LLVector3d LLWorld::clipToVisibleRegions(const LLVector3d &start_pos, const LLVe
376 return regionp->getPosGlobalFromRegion(LLVector3(final_region_pos)); 360 return regionp->getPosGlobalFromRegion(LLVector3(final_region_pos));
377} 361}
378 362
379LLViewerRegion *LLWorld::getRegionFromHandle(const U64 &handle) 363LLViewerRegion* LLWorld::getRegionFromHandle(const U64 &handle)
380{ 364{
381 LLViewerRegion *regionp; 365 for (region_list_t::iterator iter = mRegionList.begin();
382 for (regionp = mRegionList.getFirstData(); regionp; regionp = mRegionList.getNextData()) 366 iter != mRegionList.end(); ++iter)
383 { 367 {
368 LLViewerRegion* regionp = *iter;
384 if (regionp->getHandle() == handle) 369 if (regionp->getHandle() == handle)
385 { 370 {
386 return regionp; 371 return regionp;
@@ -393,9 +378,10 @@ LLViewerRegion *LLWorld::getRegionFromHandle(const U64 &handle)
393void LLWorld::updateAgentOffset(const LLVector3d &offset_global) 378void LLWorld::updateAgentOffset(const LLVector3d &offset_global)
394{ 379{
395#if 0 380#if 0
396 LLViewerRegion *regionp; 381 for (region_list_t::iterator iter = mRegionList.begin();
397 for (regionp = mRegionList.getFirstData(); regionp; regionp = mRegionList.getNextData()) 382 iter != mRegionList.end(); ++iter)
398 { 383 {
384 LLViewerRegion* regionp = *iter;
399 regionp->setAgentOffset(offset_global); 385 regionp->setAgentOffset(offset_global);
400 } 386 }
401#endif 387#endif
@@ -404,9 +390,10 @@ void LLWorld::updateAgentOffset(const LLVector3d &offset_global)
404 390
405BOOL LLWorld::positionRegionValidGlobal(const LLVector3d &pos_global) 391BOOL LLWorld::positionRegionValidGlobal(const LLVector3d &pos_global)
406{ 392{
407 LLViewerRegion *regionp; 393 for (region_list_t::iterator iter = mRegionList.begin();
408 for (regionp = mRegionList.getFirstData(); regionp; regionp = mRegionList.getNextData()) 394 iter != mRegionList.end(); ++iter)
409 { 395 {
396 LLViewerRegion* regionp = *iter;
410 if (regionp->pointInRegionGlobal(pos_global)) 397 if (regionp->pointInRegionGlobal(pos_global))
411 { 398 {
412 return TRUE; 399 return TRUE;
@@ -571,32 +558,29 @@ void LLWorld::updateVisibilities()
571 558
572 gCamera->setFar(mLandFarClip); 559 gCamera->setFar(mLandFarClip);
573 560
574 LLViewerRegion *regionp;
575
576 F32 diagonal_squared = F_SQRT2 * F_SQRT2 * mWidth * mWidth; 561 F32 diagonal_squared = F_SQRT2 * F_SQRT2 * mWidth * mWidth;
577 // Go through the culled list and check for visible regions 562 // Go through the culled list and check for visible regions
578 for (regionp = mCulledRegionList.getFirstData(); 563 for (region_list_t::iterator iter = mCulledRegionList.begin();
579 regionp; 564 iter != mCulledRegionList.end(); )
580 regionp = mCulledRegionList.getNextData())
581 { 565 {
566 region_list_t::iterator curiter = iter++;
567 LLViewerRegion* regionp = *curiter;
582 F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ(); 568 F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ();
583 F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared); 569 F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared);
584 if (!regionp->getLand().hasZData() 570 if (!regionp->getLand().hasZData()
585 || gCamera->sphereInFrustum(regionp->getCenterAgent(), radius)) 571 || gCamera->sphereInFrustum(regionp->getCenterAgent(), radius))
586 { 572 {
587 mCulledRegionList.removeCurrentData(); 573 mCulledRegionList.erase(curiter);
588 mVisibleRegionList.addDataAtEnd(regionp); 574 mVisibleRegionList.push_back(regionp);
589 } 575 }
590 } 576 }
591 577
592 F32 last_dist_squared = 0.0f; 578 // Update all of the visible regions
593 F32 dist_squared; 579 for (region_list_t::iterator iter = mVisibleRegionList.begin();
594 580 iter != mVisibleRegionList.end(); )
595 // Update all of the visible regions and make single bubble-sort pass
596 for (regionp = mVisibleRegionList.getFirstData();
597 regionp;
598 regionp = mVisibleRegionList.getNextData())
599 { 581 {
582 region_list_t::iterator curiter = iter++;
583 LLViewerRegion* regionp = *curiter;
600 if (!regionp->getLand().hasZData()) 584 if (!regionp->getLand().hasZData())
601 { 585 {
602 continue; 586 continue;
@@ -606,44 +590,35 @@ void LLWorld::updateVisibilities()
606 F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared); 590 F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared);
607 if (gCamera->sphereInFrustum(regionp->getCenterAgent(), radius)) 591 if (gCamera->sphereInFrustum(regionp->getCenterAgent(), radius))
608 { 592 {
593 regionp->calculateCameraDistance();
609 if (!gNoRender) 594 if (!gNoRender)
610 { 595 {
611 regionp->getLand().updatePatchVisibilities(gAgent); 596 regionp->getLand().updatePatchVisibilities(gAgent);
612 } 597 }
613
614 // sort by distance... closer regions to the front
615 // Note: regions use absolute frame so we use the agent's center
616 dist_squared = (F32)(gAgent.getCameraPositionGlobal() - regionp->getCenterGlobal()).magVecSquared();
617 if (dist_squared < last_dist_squared)
618 {
619 mVisibleRegionList.swapCurrentWithPrevious();
620 }
621 else
622 {
623 last_dist_squared = dist_squared;
624 }
625 } 598 }
626 else 599 else
627 { 600 {
628 mVisibleRegionList.removeCurrentData(); 601 mVisibleRegionList.erase(curiter);
629 mCulledRegionList.addData(regionp); 602 mCulledRegionList.push_back(regionp);
630 } 603 }
631 } 604 }
632 605
606 // Sort visible regions
607 mVisibleRegionList.sort(LLViewerRegion::CompareDistance());
608
633 gCamera->setFar(cur_far_clip); 609 gCamera->setFar(cur_far_clip);
634} 610}
635 611
636void LLWorld::updateRegions(F32 max_update_time) 612void LLWorld::updateRegions(F32 max_update_time)
637{ 613{
638 LLViewerRegion *regionp;
639 LLTimer update_timer; 614 LLTimer update_timer;
640 BOOL did_one = FALSE; 615 BOOL did_one = FALSE;
641 616
642 // Perform idle time updates for the regions (and associated surfaces) 617 // Perform idle time updates for the regions (and associated surfaces)
643 for (regionp = mRegionList.getFirstData(); 618 for (region_list_t::iterator iter = mRegionList.begin();
644 regionp; 619 iter != mRegionList.end(); ++iter)
645 regionp = mRegionList.getNextData())
646 { 620 {
621 LLViewerRegion* regionp = *iter;
647 F32 max_time = max_update_time - update_timer.getElapsedTimeF32(); 622 F32 max_time = max_update_time - update_timer.getElapsedTimeF32();
648 if (did_one && max_time <= 0.f) 623 if (did_one && max_time <= 0.f)
649 break; 624 break;
@@ -664,47 +639,45 @@ void LLWorld::updateClouds(const F32 dt)
664 // don't move clouds in snapshot mode 639 // don't move clouds in snapshot mode
665 return; 640 return;
666 } 641 }
667 LLViewerRegion *regionp; 642 if (mActiveRegionList.size())
668 if (mActiveRegionList.getLength())
669 { 643 {
670 // Update all the cloud puff positions, and timer based stuff 644 // Update all the cloud puff positions, and timer based stuff
671 // such as death decay 645 // such as death decay
672 for (regionp = mActiveRegionList.getFirstData(); 646 for (region_list_t::iterator iter = mActiveRegionList.begin();
673 regionp; 647 iter != mActiveRegionList.end(); ++iter)
674 regionp = mActiveRegionList.getNextData())
675 { 648 {
649 LLViewerRegion* regionp = *iter;
676 regionp->mCloudLayer.updatePuffs(dt); 650 regionp->mCloudLayer.updatePuffs(dt);
677 } 651 }
678 652
679 // Reshuffle who owns which puffs 653 // Reshuffle who owns which puffs
680 for (regionp = mActiveRegionList.getFirstData(); 654 for (region_list_t::iterator iter = mActiveRegionList.begin();
681 regionp; 655 iter != mActiveRegionList.end(); ++iter)
682 regionp = mActiveRegionList.getNextData())
683 { 656 {
657 LLViewerRegion* regionp = *iter;
684 regionp->mCloudLayer.updatePuffOwnership(); 658 regionp->mCloudLayer.updatePuffOwnership();
685 } 659 }
686 660
687 // Add new puffs 661 // Add new puffs
688 for (regionp = mActiveRegionList.getFirstData(); 662 for (region_list_t::iterator iter = mActiveRegionList.begin();
689 regionp; 663 iter != mActiveRegionList.end(); ++iter)
690 regionp = mActiveRegionList.getNextData())
691 { 664 {
665 LLViewerRegion* regionp = *iter;
692 regionp->mCloudLayer.updatePuffCount(); 666 regionp->mCloudLayer.updatePuffCount();
693 } 667 }
694 } 668 }
695} 669}
696 670
697LLCloudGroup *LLWorld::findCloudGroup(const LLCloudPuff &puff) 671LLCloudGroup* LLWorld::findCloudGroup(const LLCloudPuff &puff)
698{ 672{
699 LLViewerRegion *regionp; 673 if (mActiveRegionList.size())
700 if (mActiveRegionList.getLength())
701 { 674 {
702 // Update all the cloud puff positions, and timer based stuff 675 // Update all the cloud puff positions, and timer based stuff
703 // such as death decay 676 // such as death decay
704 for (regionp = mActiveRegionList.getFirstData(); 677 for (region_list_t::iterator iter = mActiveRegionList.begin();
705 regionp; 678 iter != mActiveRegionList.end(); ++iter)
706 regionp = mActiveRegionList.getNextData())
707 { 679 {
680 LLViewerRegion* regionp = *iter;
708 LLCloudGroup *groupp = regionp->mCloudLayer.findCloudGroup(puff); 681 LLCloudGroup *groupp = regionp->mCloudLayer.findCloudGroup(puff);
709 if (groupp) 682 if (groupp)
710 { 683 {
@@ -721,11 +694,12 @@ void LLWorld::renderPropertyLines()
721 S32 region_count = 0; 694 S32 region_count = 0;
722 S32 vertex_count = 0; 695 S32 vertex_count = 0;
723 696
724 LLViewerRegion* region; 697 for (region_list_t::iterator iter = mVisibleRegionList.begin();
725 for (region = mVisibleRegionList.getFirstData(); region; region = mVisibleRegionList.getNextData() ) 698 iter != mVisibleRegionList.end(); ++iter)
726 { 699 {
700 LLViewerRegion* regionp = *iter;
727 region_count++; 701 region_count++;
728 vertex_count += region->renderPropertyLines(); 702 vertex_count += regionp->renderPropertyLines();
729 } 703 }
730} 704}
731 705
@@ -734,10 +708,11 @@ void LLWorld::updateNetStats()
734{ 708{
735 F32 bits = 0.f; 709 F32 bits = 0.f;
736 U32 packets = 0; 710 U32 packets = 0;
737 LLViewerRegion *regionp;
738 711
739 for (regionp = mActiveRegionList.getFirstData(); regionp; regionp = mActiveRegionList.getNextData()) 712 for (region_list_t::iterator iter = mActiveRegionList.begin();
713 iter != mActiveRegionList.end(); ++iter)
740 { 714 {
715 LLViewerRegion* regionp = *iter;
741 regionp->updateNetStats(); 716 regionp->updateNetStats();
742 bits += regionp->mBitStat.getCurrent(); 717 bits += regionp->mBitStat.getCurrent();
743 packets += llfloor( regionp->mPacketsStat.getCurrent() ); 718 packets += llfloor( regionp->mPacketsStat.getCurrent() );
@@ -772,27 +747,24 @@ void LLWorld::updateNetStats()
772 747
773void LLWorld::printPacketsLost() 748void LLWorld::printPacketsLost()
774{ 749{
775 LLViewerRegion *regionp;
776
777 llinfos << "Simulators:" << llendl; 750 llinfos << "Simulators:" << llendl;
778 llinfos << "----------" << llendl; 751 llinfos << "----------" << llendl;
779 752
780 LLCircuitData *cdp = NULL; 753 LLCircuitData *cdp = NULL;
781 for (regionp = mActiveRegionList.getFirstData(); 754 for (region_list_t::iterator iter = mActiveRegionList.begin();
782 regionp; 755 iter != mActiveRegionList.end(); ++iter)
783 regionp = mActiveRegionList.getNextData()) 756 {
757 LLViewerRegion* regionp = *iter;
758 cdp = gMessageSystem->mCircuitInfo.findCircuit(regionp->getHost());
759 if (cdp)
784 { 760 {
785 cdp = gMessageSystem->mCircuitInfo.findCircuit(regionp->getHost()); 761 LLVector3d range = regionp->getCenterGlobal() - gAgent.getPositionGlobal();
786 if (cdp)
787 {
788 LLVector3d range = regionp->getCenterGlobal() - gAgent.getPositionGlobal();
789 762
790 llinfos << regionp->getHost() << ", range: " << range.magVec() << 763 llinfos << regionp->getHost() << ", range: " << range.magVec()
791 " packets lost: " << 764 << " packets lost: " << cdp->getPacketsLost() << llendl;
792 cdp->getPacketsLost() << llendl;
793 }
794 } 765 }
795 766 }
767
796 llinfos << "UserServer:" << llendl; 768 llinfos << "UserServer:" << llendl;
797 llinfos << "-----------" << llendl; 769 llinfos << "-----------" << llendl;
798 770
@@ -805,9 +777,11 @@ void LLWorld::printPacketsLost()
805 777
806void LLWorld::processCoarseUpdate(LLMessageSystem* msg, void** user_data) 778void LLWorld::processCoarseUpdate(LLMessageSystem* msg, void** user_data)
807{ 779{
808 LLViewerRegion* region = NULL; 780 LLViewerRegion* region = gWorldp->getRegion(msg->getSender());
809 region = gWorldp->getRegion(msg->getSender()); 781 if( region )
810 if( region ) region->updateCoarseLocations(msg); 782 {
783 region->updateCoarseLocations(msg);
784 }
811} 785}
812 786
813F32 LLWorld::getLandFarClip() const 787F32 LLWorld::getLandFarClip() const
@@ -828,49 +802,58 @@ void LLWorld::updateWaterObjects()
828 { 802 {
829 return; 803 return;
830 } 804 }
831 S32 min_x, min_y, max_x, max_y; 805 if (mRegionList.empty())
832 U32 region_x, region_y;
833
834 S32 rwidth = llfloor(getRegionWidthInMeters());
835
836 // First, determine the min and max "box" of water objects
837 LLViewerRegion *regionp;
838 regionp = mRegionList.getFirstData();
839
840 if (!regionp)
841 { 806 {
842 llwarns << "No regions!" << llendl; 807 llwarns << "No regions!" << llendl;
843 return; 808 return;
844 } 809 }
845 810
846 from_region_handle(regionp->getHandle(), &region_x, &region_y); 811 // First, determine the min and max "box" of water objects
847 min_x = max_x = region_x; 812 bool first = true;
848 min_y = max_y = region_y; 813 S32 min_x = 0;
814 S32 min_y = 0;
815 S32 max_x = 0;
816 S32 max_y = 0;
817 U32 region_x, region_y;
849 818
850 LLVOWater *waterp; 819 S32 rwidth = llfloor(getRegionWidthInMeters());
851 820
852 for (; regionp; regionp = mRegionList.getNextData()) 821
822 for (region_list_t::iterator iter = mRegionList.begin();
823 iter != mRegionList.end(); ++iter)
853 { 824 {
825 LLViewerRegion* regionp = *iter;
854 from_region_handle(regionp->getHandle(), &region_x, &region_y); 826 from_region_handle(regionp->getHandle(), &region_x, &region_y);
855 min_x = llmin(min_x, (S32)region_x); 827 if (first)
856 min_y = llmin(min_y, (S32)region_y); 828 {
857 max_x = llmax(max_x, (S32)region_x); 829 first = false;
858 max_y = llmax(max_y, (S32)region_y); 830 min_x = max_x = region_x;
859 waterp = regionp->getLand().getWaterObj(); 831 min_y = max_y = region_y;
832 }
833 else
834 {
835 min_x = llmin(min_x, (S32)region_x);
836 min_y = llmin(min_y, (S32)region_y);
837 max_x = llmax(max_x, (S32)region_x);
838 max_y = llmax(max_y, (S32)region_y);
839 }
840 LLVOWater* waterp = regionp->getLand().getWaterObj();
860 if (waterp) 841 if (waterp)
861 { 842 {
862 gObjectList.updateActive(waterp); 843 gObjectList.updateActive(waterp);
863 } 844 }
864 } 845 }
865 846
866 for (waterp = mHoleWaterObjects.getFirstData(); waterp; waterp = mHoleWaterObjects.getNextData()) 847 for (std::list<LLVOWater*>::iterator iter = mHoleWaterObjects.begin();
848 iter != mHoleWaterObjects.end(); ++ iter)
867 { 849 {
850 LLVOWater* waterp = *iter;
868 gObjectList.killObject(waterp); 851 gObjectList.killObject(waterp);
869 } 852 }
870 mHoleWaterObjects.removeAllNodes(); 853 mHoleWaterObjects.clear();
871 854
872 // We only want to fill in holes for stuff that's near us, say, within 512m 855 // We only want to fill in holes for stuff that's near us, say, within 512m
873 regionp = gAgent.getRegion(); 856 LLViewerRegion* regionp = gAgent.getRegion();
874 from_region_handle(regionp->getHandle(), &region_x, &region_y); 857 from_region_handle(regionp->getHandle(), &region_x, &region_y);
875 858
876 min_x = llmax((S32)region_x - 512, min_x); 859 min_x = llmax((S32)region_x - 512, min_x);
@@ -887,14 +870,14 @@ void LLWorld::updateWaterObjects()
887 U64 region_handle = to_region_handle(x, y); 870 U64 region_handle = to_region_handle(x, y);
888 if (!getRegionFromHandle(region_handle)) 871 if (!getRegionFromHandle(region_handle))
889 { 872 {
890 waterp = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_WATER, gAgent.getRegion()); 873 LLVOWater* waterp = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_WATER, gAgent.getRegion());
891 waterp->setUseTexture(FALSE); 874 waterp->setUseTexture(FALSE);
892 gPipeline.addObject(waterp); 875 gPipeline.addObject(waterp);
893 waterp->setPositionGlobal(LLVector3d(x + rwidth/2, 876 waterp->setPositionGlobal(LLVector3d(x + rwidth/2,
894 y + rwidth/2, 877 y + rwidth/2,
895 DEFAULT_WATER_HEIGHT)); 878 DEFAULT_WATER_HEIGHT));
896 waterp->setScale(LLVector3((F32)rwidth, (F32)rwidth, 0.f)); 879 waterp->setScale(LLVector3((F32)rwidth, (F32)rwidth, 0.f));
897 mHoleWaterObjects.addData(waterp); 880 mHoleWaterObjects.push_back(waterp);
898 } 881 }
899 } 882 }
900 } 883 }
@@ -943,7 +926,7 @@ void LLWorld::updateWaterObjects()
943 const S32 water_center_y = center_y + llround((wy + dim[1]) * 0.5f * gDirAxes[dir][1]); 926 const S32 water_center_y = center_y + llround((wy + dim[1]) * 0.5f * gDirAxes[dir][1]);
944 927
945 928
946 waterp = mEdgeWaterObjects[dir]; 929 LLVOWater* waterp = mEdgeWaterObjects[dir];
947 if (!waterp || waterp->isDead()) 930 if (!waterp || waterp->isDead())
948 { 931 {
949 // The edge water objects can be dead because they're attached to the region that the 932 // The edge water objects can be dead because they're attached to the region that the
@@ -971,7 +954,7 @@ void LLWorld::updateWaterObjects()
971 //llinfos << "End water update" << llendl; 954 //llinfos << "End water update" << llendl;
972} 955}
973 956
974LLViewerImage *LLWorld::getDefaultWaterTexture() 957LLViewerImage* LLWorld::getDefaultWaterTexture()
975{ 958{
976 return mDefaultWaterTexturep; 959 return mDefaultWaterTexturep;
977} 960}
@@ -988,10 +971,10 @@ U64 LLWorld::getSpaceTimeUSec() const
988 971
989void LLWorld::requestCacheMisses() 972void LLWorld::requestCacheMisses()
990{ 973{
991 for(LLViewerRegion* regionp = mRegionList.getFirstData(); 974 for (region_list_t::iterator iter = mRegionList.begin();
992 regionp; 975 iter != mRegionList.end(); ++iter)
993 regionp = mRegionList.getNextData())
994 { 976 {
977 LLViewerRegion* regionp = *iter;
995 regionp->requestCacheMisses(); 978 regionp->requestCacheMisses();
996 } 979 }
997} 980}
@@ -999,10 +982,10 @@ void LLWorld::requestCacheMisses()
999LLString LLWorld::getInfoString() 982LLString LLWorld::getInfoString()
1000{ 983{
1001 LLString info_string("World Info:\n"); 984 LLString info_string("World Info:\n");
1002 for (LLViewerRegion* regionp = mRegionList.getFirstData(); 985 for (region_list_t::iterator iter = mRegionList.begin();
1003 regionp; 986 iter != mRegionList.end(); ++iter)
1004 regionp = mRegionList.getNextData())
1005 { 987 {
988 LLViewerRegion* regionp = *iter;
1006 info_string += regionp->getInfoString(); 989 info_string += regionp->getInfoString();
1007 } 990 }
1008 return info_string; 991 return info_string;
@@ -1011,10 +994,10 @@ LLString LLWorld::getInfoString()
1011void LLWorld::disconnectRegions() 994void LLWorld::disconnectRegions()
1012{ 995{
1013 LLMessageSystem* msg = gMessageSystem; 996 LLMessageSystem* msg = gMessageSystem;
1014 for(LLViewerRegion* regionp = mRegionList.getFirstData(); 997 for (region_list_t::iterator iter = mRegionList.begin();
1015 regionp; 998 iter != mRegionList.end(); ++iter)
1016 regionp = mRegionList.getNextData())
1017 { 999 {
1000 LLViewerRegion* regionp = *iter;
1018 if (regionp == gAgent.getRegion()) 1001 if (regionp == gAgent.getRegion())
1019 { 1002 {
1020 // Skip the main agent 1003 // Skip the main agent
@@ -1094,8 +1077,11 @@ void process_region_handshake(LLMessageSystem* msg, void** user_data)
1094void send_agent_pause() 1077void send_agent_pause()
1095{ 1078{
1096 // world not initialized yet 1079 // world not initialized yet
1097 if (!gWorldp) return; 1080 if (!gWorldp)
1098 1081 {
1082 return;
1083 }
1084
1099 gMessageSystem->newMessageFast(_PREHASH_AgentPause); 1085 gMessageSystem->newMessageFast(_PREHASH_AgentPause);
1100 gMessageSystem->nextBlockFast(_PREHASH_AgentData); 1086 gMessageSystem->nextBlockFast(_PREHASH_AgentData);
1101 gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgentID); 1087 gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgentID);
@@ -1104,11 +1090,10 @@ void send_agent_pause()
1104 gAgentPauseSerialNum++; 1090 gAgentPauseSerialNum++;
1105 gMessageSystem->addU32Fast(_PREHASH_SerialNum, gAgentPauseSerialNum); 1091 gMessageSystem->addU32Fast(_PREHASH_SerialNum, gAgentPauseSerialNum);
1106 1092
1107 LLViewerRegion *regionp; 1093 for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin();
1108 for (regionp = gWorldp->mActiveRegionList.getFirstData(); 1094 iter != gWorldp->mActiveRegionList.end(); ++iter)
1109 regionp;
1110 regionp = gWorldp->mActiveRegionList.getNextData())
1111 { 1095 {
1096 LLViewerRegion* regionp = *iter;
1112 gMessageSystem->sendReliable(regionp->getHost()); 1097 gMessageSystem->sendReliable(regionp->getHost());
1113 } 1098 }
1114 1099
@@ -1132,11 +1117,10 @@ void send_agent_resume()
1132 gMessageSystem->addU32Fast(_PREHASH_SerialNum, gAgentPauseSerialNum); 1117 gMessageSystem->addU32Fast(_PREHASH_SerialNum, gAgentPauseSerialNum);
1133 1118
1134 1119
1135 LLViewerRegion *regionp; 1120 for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin();
1136 for (regionp = gWorldp->mActiveRegionList.getFirstData(); 1121 iter != gWorldp->mActiveRegionList.end(); ++iter)
1137 regionp;
1138 regionp = gWorldp->mActiveRegionList.getNextData())
1139 { 1122 {
1123 LLViewerRegion* regionp = *iter;
1140 gMessageSystem->sendReliable(regionp->getHost()); 1124 gMessageSystem->sendReliable(regionp->getHost());
1141 } 1125 }
1142 1126