Areas can now be spectatable, too.
- Makes it so that people can join, but can't type IC unless invited. - The CM can set it with `/area_spectate`.
This commit is contained in:
		
							parent
							
								
									86f91ba3e8
								
							
						
					
					
						commit
						fcd8f5b5ab
					
				@ -963,10 +963,7 @@ void Courtroom::list_areas()
 | 
			
		||||
      i_area.append(QString::number(arup_players.at(n_area)));
 | 
			
		||||
      i_area.append(" users | ");
 | 
			
		||||
 | 
			
		||||
      if (arup_locks.at(n_area) == true)
 | 
			
		||||
          i_area.append("LOCKED");
 | 
			
		||||
      else
 | 
			
		||||
          i_area.append("OPEN");
 | 
			
		||||
      i_area.append(arup_locks.at(n_area));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (i_area.toLower().contains(ui_music_search->text().toLower()))
 | 
			
		||||
@ -978,7 +975,7 @@ void Courtroom::list_areas()
 | 
			
		||||
      {
 | 
			
		||||
        // Colouring logic here.
 | 
			
		||||
        ui_area_list->item(n_listed_areas)->setBackground(free_brush);
 | 
			
		||||
        if (arup_locks.at(n_area))
 | 
			
		||||
        if (arup_locks.at(n_area) == "Locked")
 | 
			
		||||
        {
 | 
			
		||||
            ui_area_list->item(n_listed_areas)->setBackground(locked_brush);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -64,7 +64,7 @@ public:
 | 
			
		||||
      append_music(malplaced);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void arup_append(int players, QString status, QString cm, bool locked)
 | 
			
		||||
  void arup_append(int players, QString status, QString cm, QString locked)
 | 
			
		||||
  {
 | 
			
		||||
      arup_players.append(players);
 | 
			
		||||
      arup_statuses.append(status);
 | 
			
		||||
@ -88,7 +88,7 @@ public:
 | 
			
		||||
    }
 | 
			
		||||
    else if (type == 3)
 | 
			
		||||
    {
 | 
			
		||||
      arup_locks[place] = (value == "True");
 | 
			
		||||
      arup_locks[place] = value;
 | 
			
		||||
    }
 | 
			
		||||
    list_areas();
 | 
			
		||||
  }
 | 
			
		||||
@ -253,7 +253,7 @@ private:
 | 
			
		||||
  QVector<int> arup_players;
 | 
			
		||||
  QVector<QString> arup_statuses;
 | 
			
		||||
  QVector<QString> arup_cms;
 | 
			
		||||
  QVector<bool> arup_locks;
 | 
			
		||||
  QVector<QString> arup_locks;
 | 
			
		||||
 | 
			
		||||
  QSignalMapper *char_button_mapper;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -408,7 +408,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
 | 
			
		||||
 | 
			
		||||
      for (int area_n = 0; area_n < areas; area_n++)
 | 
			
		||||
      {
 | 
			
		||||
          w_courtroom->arup_append(0, "Unknown", "Unknown", false);
 | 
			
		||||
          w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown");
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      int total_loading_size = char_list_size * 2 + evidence_list_size + music_list_size;
 | 
			
		||||
@ -503,7 +503,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
 | 
			
		||||
 | 
			
		||||
      for (int area_n = 0; area_n < areas; area_n++)
 | 
			
		||||
      {
 | 
			
		||||
          w_courtroom->arup_append(0, "Unknown", "Unknown", false);
 | 
			
		||||
          w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown");
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      int total_loading_size = char_list_size * 2 + evidence_list_size + music_list_size;
 | 
			
		||||
 | 
			
		||||
@ -22,6 +22,7 @@ import yaml
 | 
			
		||||
 | 
			
		||||
from server.exceptions import AreaError
 | 
			
		||||
from server.evidence import EvidenceList
 | 
			
		||||
from enum import Enum
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class AreaManager:
 | 
			
		||||
@ -63,13 +64,18 @@ class AreaManager:
 | 
			
		||||
            self.evidence_list.append(Evidence("weeeeeew", "desc3", "3.png"))
 | 
			
		||||
            """
 | 
			
		||||
            
 | 
			
		||||
            self.is_locked = False
 | 
			
		||||
            self.is_locked = self.Locked.FREE
 | 
			
		||||
            self.blankposting_allowed = True
 | 
			
		||||
            self.non_int_pres_only = non_int_pres_only
 | 
			
		||||
            self.jukebox = jukebox
 | 
			
		||||
            self.jukebox_votes = []
 | 
			
		||||
            self.jukebox_prev_char_id = -1
 | 
			
		||||
 | 
			
		||||
        class Locked(Enum):
 | 
			
		||||
            FREE = 1,
 | 
			
		||||
            SPECTATABLE = 2,
 | 
			
		||||
            LOCKED = 3
 | 
			
		||||
 | 
			
		||||
        def new_client(self, client):
 | 
			
		||||
            self.clients.add(client)
 | 
			
		||||
            self.server.area_manager.send_arup_players()
 | 
			
		||||
@ -80,15 +86,29 @@ class AreaManager:
 | 
			
		||||
                client.is_cm = False
 | 
			
		||||
                self.owned = False
 | 
			
		||||
                self.server.area_manager.send_arup_cms()
 | 
			
		||||
                if self.is_locked:
 | 
			
		||||
                if self.is_locked != self.Locked.FREE:
 | 
			
		||||
                    self.unlock()
 | 
			
		||||
        
 | 
			
		||||
        def unlock(self):
 | 
			
		||||
            self.is_locked = False
 | 
			
		||||
            self.is_locked = self.Locked.FREE
 | 
			
		||||
            self.blankposting_allowed = True
 | 
			
		||||
            self.invite_list = {}
 | 
			
		||||
            self.server.area_manager.send_arup_lock()
 | 
			
		||||
            self.send_host_message('This area is open now.')
 | 
			
		||||
 | 
			
		||||
        def spectator(self):
 | 
			
		||||
            self.is_locked = self.Locked.SPECTATABLE
 | 
			
		||||
            for i in self.clients:
 | 
			
		||||
                self.invite_list[i.id] = None
 | 
			
		||||
            self.server.area_manager.send_arup_lock()
 | 
			
		||||
            self.send_host_message('This area is spectatable now.')
 | 
			
		||||
 | 
			
		||||
        def lock(self):
 | 
			
		||||
            self.is_locked = self.Locked.LOCKED
 | 
			
		||||
            for i in self.clients:
 | 
			
		||||
                self.invite_list[i.id] = None
 | 
			
		||||
            self.server.area_manager.send_arup_lock()
 | 
			
		||||
            self.send_host_message('This area is locked now.')
 | 
			
		||||
        
 | 
			
		||||
        def is_char_available(self, char_id):
 | 
			
		||||
            return char_id not in [x.char_id for x in self.clients]
 | 
			
		||||
@ -215,7 +235,7 @@ class AreaManager:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        def can_send_message(self, client):
 | 
			
		||||
            if self.is_locked and not client.is_mod and not client.id in self.invite_list:
 | 
			
		||||
            if self.is_locked != self.Locked.FREE and not client.is_mod and not client.id in self.invite_list:
 | 
			
		||||
                client.send_host_message('This is a locked area - ask the CM to speak.')
 | 
			
		||||
                return False
 | 
			
		||||
            return (time.time() * 1000.0 - self.next_message_time) > 0
 | 
			
		||||
@ -366,5 +386,5 @@ class AreaManager:
 | 
			
		||||
    def send_arup_lock(self):
 | 
			
		||||
        lock_list = [3]
 | 
			
		||||
        for area in self.areas:
 | 
			
		||||
            lock_list.append(area.is_locked)
 | 
			
		||||
            lock_list.append(area.is_locked.name)
 | 
			
		||||
        self.server.send_arup(lock_list)
 | 
			
		||||
 | 
			
		||||
@ -182,9 +182,10 @@ class ClientManager:
 | 
			
		||||
        def change_area(self, area):
 | 
			
		||||
            if self.area == area:
 | 
			
		||||
                raise ClientError('User already in specified area.')
 | 
			
		||||
            if area.is_locked and not self.is_mod and not self.id in area.invite_list:
 | 
			
		||||
                #self.send_host_message('This area is locked - you will be unable to send messages ICly.')
 | 
			
		||||
            if area.is_locked == area.Locked.LOCKED and not self.is_mod and not self.id in area.invite_list:
 | 
			
		||||
                raise ClientError("That area is locked!")
 | 
			
		||||
            if area.is_locked == area.Locked.SPECTATABLE and not self.is_mod and not self.id in area.invite_list:
 | 
			
		||||
                self.send_host_message('This area is spectatable, but not free - you will be unable to send messages ICly unless invited.')
 | 
			
		||||
 | 
			
		||||
            if self.area.jukebox:
 | 
			
		||||
                self.area.remove_jukebox_vote(self, True)
 | 
			
		||||
@ -215,13 +216,13 @@ class ClientManager:
 | 
			
		||||
 | 
			
		||||
        def send_area_list(self):
 | 
			
		||||
            msg = '=== Areas ==='
 | 
			
		||||
            lock = {True: '[LOCKED]', False: ''}
 | 
			
		||||
            for i, area in enumerate(self.server.area_manager.areas):
 | 
			
		||||
                owner = 'FREE'
 | 
			
		||||
                if area.owned:
 | 
			
		||||
                    for client in [x for x in area.clients if x.is_cm]:
 | 
			
		||||
                        owner = 'CM: {}'.format(client.get_char_name())
 | 
			
		||||
                        break
 | 
			
		||||
                lock = {area.Locked.FREE: '', area.Locked.SPECTATABLE: '[SPECTATABLE]', area.Locked.LOCKED: '[LOCKED]'}
 | 
			
		||||
                msg += '\r\nArea {}: {} (users: {}) [{}][{}]{}'.format(area.abbreviation, area.name, len(area.clients), area.status, owner, lock[area.is_locked])
 | 
			
		||||
                if self.area == area:
 | 
			
		||||
                    msg += ' [*]'
 | 
			
		||||
@ -236,7 +237,7 @@ class ClientManager:
 | 
			
		||||
            info += '=== {} ==='.format(area.name)
 | 
			
		||||
            info += '\r\n'
 | 
			
		||||
 | 
			
		||||
            lock = {True: '[LOCKED]', False: ''}
 | 
			
		||||
            lock = {area.Locked.FREE: '', area.Locked.SPECTATABLE: '[SPECTATABLE]', area.Locked.LOCKED: '[LOCKED]'}
 | 
			
		||||
            info += '[{}]: [{} users][{}]{}'.format(area.abbreviation, len(area.clients), area.status, lock[area.is_locked])
 | 
			
		||||
            
 | 
			
		||||
            sorted_clients = []
 | 
			
		||||
 | 
			
		||||
@ -697,7 +697,7 @@ def ooc_cmd_uncm(client, arg):
 | 
			
		||||
        client.is_cm = False
 | 
			
		||||
        client.area.owned = False
 | 
			
		||||
        client.area.blankposting_allowed = True
 | 
			
		||||
        if client.area.is_locked:
 | 
			
		||||
        if client.area.is_locked != client.area.Locked.FREE:
 | 
			
		||||
            client.area.unlock()
 | 
			
		||||
        client.server.area_manager.send_arup_cms()
 | 
			
		||||
        client.area.send_host_message('{} is no longer CM in this area.'.format(client.get_char_name()))
 | 
			
		||||
@ -714,20 +714,28 @@ def ooc_cmd_area_lock(client, arg):
 | 
			
		||||
    if not client.area.locking_allowed:
 | 
			
		||||
        client.send_host_message('Area locking is disabled in this area.')
 | 
			
		||||
        return
 | 
			
		||||
    if client.area.is_locked:
 | 
			
		||||
    if client.area.is_locked == client.area.Locked.LOCKED:
 | 
			
		||||
        client.send_host_message('Area is already locked.')
 | 
			
		||||
    if client.is_cm:
 | 
			
		||||
        client.area.is_locked = True
 | 
			
		||||
        client.server.area_manager.send_arup_lock()
 | 
			
		||||
        client.area.send_host_message('Area is locked.')
 | 
			
		||||
        for i in client.area.clients:
 | 
			
		||||
            client.area.invite_list[i.id] = None
 | 
			
		||||
        client.area.lock()
 | 
			
		||||
        return
 | 
			
		||||
    else:
 | 
			
		||||
        raise ClientError('Only CM can lock the area.')
 | 
			
		||||
    
 | 
			
		||||
def ooc_cmd_area_spectate(client, arg):
 | 
			
		||||
    if not client.area.locking_allowed:
 | 
			
		||||
        client.send_host_message('Area locking is disabled in this area.')
 | 
			
		||||
        return
 | 
			
		||||
    if client.area.is_locked == client.area.Locked.SPECTATABLE:
 | 
			
		||||
        client.send_host_message('Area is already spectatable.')
 | 
			
		||||
    if client.is_cm:
 | 
			
		||||
        client.area.spectator()
 | 
			
		||||
        return
 | 
			
		||||
    else:
 | 
			
		||||
        raise ClientError('Only CM can make the area spectatable.')
 | 
			
		||||
        
 | 
			
		||||
def ooc_cmd_area_unlock(client, arg):
 | 
			
		||||
    if not client.area.is_locked:
 | 
			
		||||
    if client.area.is_locked == client.area.Locked.FREE:
 | 
			
		||||
        raise ClientError('Area is already unlocked.')
 | 
			
		||||
    if not client.is_cm:
 | 
			
		||||
        raise ClientError('Only CM can unlock area.')
 | 
			
		||||
 | 
			
		||||
@ -268,7 +268,7 @@ class TsuServer3:
 | 
			
		||||
        CM:
 | 
			
		||||
            ARUP#2##<area1_cm: string>##<area2_cm: string>#...
 | 
			
		||||
        Lockedness:
 | 
			
		||||
            ARUP#3##<area1_l: bool>##<area2_l: bool>#...
 | 
			
		||||
            ARUP#3##<area1_l: string>##<area2_l: string>#...
 | 
			
		||||
 | 
			
		||||
        """
 | 
			
		||||
        if len(args) < 2:
 | 
			
		||||
@ -277,13 +277,13 @@ class TsuServer3:
 | 
			
		||||
        if args[0] not in (0,1,2,3):
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
        if args[0] in (0, 3):
 | 
			
		||||
        if args[0] == 0:
 | 
			
		||||
            for part_arg in args[1:]:
 | 
			
		||||
                try:
 | 
			
		||||
                    sanitised = int(part_arg)
 | 
			
		||||
                except:
 | 
			
		||||
                    return
 | 
			
		||||
        elif args[0] in (1, 2):
 | 
			
		||||
        elif args[0] in (1, 2, 3):
 | 
			
		||||
            for part_arg in args[1:]:
 | 
			
		||||
                try:
 | 
			
		||||
                    sanitised = str(part_arg)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user