+ $this->user[$idx]->name = $name_new; // OK - add new user
+ $this->user[$idx]->stat_set("room");
+ $this->user[$idx]->step_set(0);
+ while (array_pop($this->user[$idx]->comm) != NULL);
+ $this->user[$idx]->subst = "standup";
+ $this->user[$idx]->lacc = $curtime;
+ $this->user[$idx]->laccwr = $curtime;
+ $this->user[$idx]->bantime = 0;
+ $this->user[$idx]->ip = $ip;
+
+ $this->user[$idx]->rec = $authenticate;
+ $this->user[$idx]->flags = $user_type;
+ $this->user[$idx]->flags |= ($authenticate != FALSE ? USER_FLAG_AUTH : 0x00);
+ $this->user[$idx]->flags |= ( ($pass != FALSE && $bdb == FALSE) ? USER_FLAG_DBFAILED : 0x00);
+ log_auth("XXX", sprintf("FLAGS: [%x]", $this->user[$idx]->flags));
+
+ if ($authenticate != FALSE) {
+ $this->user[$idx]->code = $authenticate->code_get();
+ }
+ // fprintf(STDERR, "QQ %s: flag %x\n", __FUNCTION__, $this->user[$idx]->flags);
+ if ($ghost > -1) {
+ log_main("ghost: rename!");
+ $ghost_user = $this->user[$ghost];
+
+ if ($ghost_auth == FALSE) {
+ for ($sfx = 1 ; $sfx <= MAX_PLAYERS ; $sfx++) {
+ $ghostname = 'ghost'.$sfx;
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ if (strcmp("", $this->user[$i]->sess) == 0)
+ continue;
+
+ if (strcasecmp($this->user[$i]->name, $ghostname) == 0) {
+ $ghostname = '';
+ break;
+ }
+ }
+ if ($ghostname != '')
+ break;
+ }
+
+ $ghost_user->name = $ghostname;
+
+ if ($ghost_user->stat == 'room' && $ghost_user->subst == 'standup') {
+ $this->standup_update($ghost_user);
+ }
+ else {
+ log_main("chatt_send pre table update");
+ $this->table_update($ghost_user);
+ log_main("chatt_send post table update");
+ }
+ } // if ($ghost_auth == FALSE
+ else {
+ // FIXME: cacciare il vecchio utente room && table (if needed)
+ $ghost_user->the_end = TRUE;
+ $ghost_user->lacc = 0;
+ $this->garbage_manager(TRUE);
+ }
+ } // if ($ghost > -1) {