From: Anders R. <ma...@us...> - 2006-03-27 20:25:31
|
Update of /cvsroot/planeshift/planeshift/src/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24541/src/server Modified Files: adminmanager.cpp cachemanager.cpp weathermanager.cpp weathermanager.h Log Message: - Updated npcroom.zip with sequence for lightning. - Added flag to sectors table to indicated if automatic weather should be started at startup or not. => BUMPPED DB VERSION - Added handling of change of downfall type for portals. - Added stop and start params to /rain and /snow to start and stop automatic weather for a sector. - Added off paramter to /fog, the same functionality as using -1. Index: adminmanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/adminmanager.cpp,v retrieving revision 1.317 retrieving revision 1.318 diff -C2 -d -r1.317 -r1.318 *** adminmanager.cpp 22 Mar 2006 23:00:01 -0000 1.317 --- adminmanager.cpp 27 Mar 2006 20:25:22 -0000 1.318 *************** *** 3465,3469 **** else { ! psserver->SendSystemError(me->clientnum,"You cannot create a lightning if it is not raining!"); } } --- 3465,3469 ---- else { ! psserver->SendSystemError(me->clientnum, "You cannot create a lightning if it is not raining!"); } } *************** *** 3473,3477 **** if(msg.sector.IsEmpty()) { ! psserver->SendSystemError(me->clientnum, "Syntax: /fog sector density [fade r g b] / [-1 to reset]"); return; } --- 3473,3477 ---- if(msg.sector.IsEmpty()) { ! psserver->SendSystemError(me->clientnum, "Syntax: /fog sector [density [fade [r g b]]|off]"); return; } *************** *** 3495,3500 **** { // Set fog ! psserver->GetWeatherManager()->QueueNextEvent(0, psWeatherMessage::FOG, msg.density, 0, msg.fade, ! sectorinfo->name, sectorinfo,0,(int)msg.x,(int)msg.y,(int)msg.z); } --- 3495,3502 ---- { // Set fog ! psserver->GetWeatherManager()->QueueNextEvent(0, psWeatherMessage::FOG, ! msg.density, 0, msg.fade, ! sectorinfo->name, sectorinfo,0, ! (int)msg.x,(int)msg.y,(int)msg.z); //rgb } *************** *** 3505,3509 **** if(msg.sector.GetData() == NULL) { ! psserver->SendSystemError(me->clientnum, "Syntax: /rain sector length drops fade"); return; } --- 3507,3511 ---- if(msg.sector.GetData() == NULL) { ! psserver->SendSystemError(me->clientnum, "Syntax: /rain sector [length [drops [fade]]|start|stop]"); return; } *************** *** 3524,3531 **** } ! // queue the event ! psserver->GetWeatherManager()->QueueNextEvent(0, psWeatherMessage::RAIN, ! msg.rainDrops, msg.interval, ! msg.fade, msg.sector, sectorinfo); } --- 3526,3560 ---- } ! if (msg.interval == -1) // Start automatic weather ! { ! if (!sectorinfo->rain_enabled) ! { ! psserver->SendSystemInfo(me->clientnum,"Automatic weather started in sector %s", ! msg.sector.GetDataSafe()); ! sectorinfo->rain_enabled = true; ! psserver->GetWeatherManager()->StartWeather(sectorinfo); ! } ! ! } else if (msg.interval == -2) // Stop automatic weather ! { ! psserver->SendSystemInfo(me->clientnum,"Automatic weather stopped in sector %s", ! msg.sector.GetDataSafe()); ! sectorinfo->rain_enabled = false; // Disable this will prevent any new ! // rain events from beeing started. Will not stop current shower and ! // that is ok since we don't have a user determined fade factor here. ! } ! else ! { ! if (sectorinfo->rain_enabled) ! { ! psserver->SendSystemInfo(me->clientnum,"Automatic weather stopped"); ! sectorinfo->rain_enabled = false; ! } ! ! // queue the event ! psserver->GetWeatherManager()->QueueNextEvent(0, psWeatherMessage::RAIN, ! msg.rainDrops, msg.interval, ! msg.fade, msg.sector, sectorinfo); ! } } *************** *** 3534,3538 **** if(msg.sector.GetData() == NULL) { ! psserver->SendSystemError(me->clientnum, "Syntax: /snow sector length drops fade"); return; } --- 3563,3567 ---- if(msg.sector.GetData() == NULL) { ! psserver->SendSystemError(me->clientnum, "Syntax: /snow sector [length [drops [fade]]|start|stop]"); return; } Index: cachemanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/cachemanager.cpp,v retrieving revision 1.148 retrieving revision 1.149 diff -C2 -d -r1.148 -r1.149 *** cachemanager.cpp 22 Mar 2006 06:12:04 -0000 1.148 --- cachemanager.cpp 27 Mar 2006 20:25:22 -0000 1.149 *************** *** 310,313 **** --- 310,314 ---- newsector->uid = result[currentrow].GetInt("id"); newsector->name = result[currentrow]["name"]; + newsector->rain_enabled = strcmp(result[currentrow]["rain_enabled"],"Y")==0; newsector->rain_min_gap = result[currentrow].GetInt("rain_min_gap"); Index: weathermanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/weathermanager.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** weathermanager.cpp 22 Mar 2006 22:18:21 -0000 1.42 --- weathermanager.cpp 27 Mar 2006 20:25:22 -0000 1.43 *************** *** 49,66 **** while (iter.HasNext() ) { ! psSectorInfo *sector = iter.Next(); - // Is rain/snow enabled for this sector - if (sector->rain_max_duration != 0) - { - // Queue event to start rain/snow - QueueNextEvent(sector->GetRandomRainGap(), - psWeatherMessage::RAIN, - sector->GetRandomRainDrops(), - 0, // Duration is calculated when stop event is created - 0, // Fade is calculated when sending weather event - sector->name, - sector); - } } --- 49,56 ---- while (iter.HasNext() ) { ! psSectorInfo *si = iter.Next(); ! ! StartWeather(si); } *************** *** 69,72 **** --- 59,78 ---- } + void WeatherManager::StartWeather(psSectorInfo *si) + { + // Is rain/snow enabled for this sector + if (si->rain_enabled) + { + // Queue event to start rain/snow + QueueNextEvent(si->GetRandomRainGap(), + psWeatherMessage::RAIN, + si->GetRandomRainDrops(), + 0, // Duration is calculated when stop event is created + 0, // Fade is calculated when sending weather event + si->name, + si); + } + } + void WeatherManager::UpdateClient(uint32_t cnum) { *************** *** 284,288 **** event->si->is_snowing = true; ! if (event->si->lightning_min_gap && event->value > 2000 && event->si->is_raining) { // Queue lightning during rain storm here first --- 290,295 ---- event->si->is_snowing = true; ! if (event->si->lightning_min_gap && event->value > 2000 && ! event->si->is_raining && event->si->rain_enabled) { // Queue lightning during rain storm here first *************** *** 317,321 **** } ! else // if this is event to turn off rain/rain, queue event to turn on again later { if(event->type== psWeatherMessage::SNOW) --- 324,329 ---- } ! // if this is event to turn off rain/rain ! else { if(event->type== psWeatherMessage::SNOW) *************** *** 324,337 **** event->si->is_raining = false; ! if (event->si->rain_max_duration != 0) ! { ! QueueNextEvent(event->si->GetRandomRainGap(), ! event->type, ! event->si->GetRandomRainDrops(), ! 0, ! 0, ! event->si->name, ! event->si); ! } } --- 332,337 ---- event->si->is_raining = false; ! // Queue event to turn on again later if enabled ! StartWeather(event->si); } *************** *** 375,383 **** case psWeatherMessage::LIGHTNING: { - Notify2(LOG_WEATHER,"Lightning in sector '%s'",event->sector.GetData()); - if (event->si->is_raining) { ! // CPrintf(CON_DEBUG, "Lightning in sector %s.\n",(const char *)event->sector); psWeatherMessage::NetWeatherInfo info; info.has_downfall = false; --- 375,382 ---- case psWeatherMessage::LIGHTNING: { if (event->si->is_raining) { ! Notify2(LOG_WEATHER,"Lightning in sector '%s'",event->sector.GetData()); ! psWeatherMessage::NetWeatherInfo info; info.has_downfall = false; *************** *** 392,396 **** --- 391,397 ---- if (lightning.valid) + { psserver->GetEventManager()->Broadcast(lightning.msg); + } else { *************** *** 398,402 **** } ! if (event->si->rain_max_duration != 0 && event->si->lightning_max_gap != 0) { --- 399,403 ---- } ! if (event->si->rain_enabled && event->si->lightning_max_gap != 0) { *************** *** 417,421 **** --- 418,424 ---- psWeatherMessage time(0,event->value); if (time.valid) + { psserver->GetEventManager()->Broadcast(time.msg); + } else { Index: weathermanager.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/weathermanager.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** weathermanager.h 14 Mar 2006 17:16:37 -0000 1.22 --- weathermanager.h 27 Mar 2006 20:25:22 -0000 1.23 *************** *** 65,68 **** --- 65,69 ---- int b = 0); + void StartWeather(psSectorInfo *si); void HandleWeatherEvent(psWeatherGameEvent *event); void SendClientCurrentTime(int cnum); |