Exemplo n.º 1
0
void warn_in_prog( CHAR_DATA * ch, int low, int high, const char *where, int vnum, MPROG_DATA * mprog, RENUMBER_AREA * r_area )
{
   const char *p, *start_number;
   int num;

   p = mprog->comlist;
   while( *p )
   {
      if( isdigit( *p ) )
      {
         start_number = p;
         while( isdigit( *p ) && *p )
            p++;

         char* temp = (char*) malloc((p - start_number + 1) * sizeof(char));
         memcpy(temp, start_number, p - start_number + 1);
         num = atoi( temp );
         free(temp);

         if( num >= low && num <= high )
         {
            pager_printf( ch,
                          "Warning! %s prog in %s vnum %d might contain a reference to %d.\r\n(Translation: Room %d, Obj %d, Mob %d)\r\n",
                          mprog_type_to_name( mprog->type ), where, vnum, num, find_translation( num, r_area->r_room ),
                          find_translation( num, r_area->r_obj ), find_translation( num, r_area->r_mob ) );
         }
         if( *p == '\0' )
            break;
      }
      p++;
   }
}
Exemplo n.º 2
0
void translate_objvals( CHAR_DATA * ch, AREA_DATA * area, RENUMBER_AREA * r_area, bool verbose )
{
   int i, new_vnum;
   OBJ_INDEX_DATA *obj;

   for( i = area->low_o_vnum; i <= area->hi_o_vnum; i++ )
   {
      obj = get_obj_index( i );
      if( !obj )
         continue;

      if( obj->item_type == ITEM_CONTAINER )
      {
         new_vnum = find_translation( obj->value[2], r_area->r_obj );
         if( new_vnum != NOT_FOUND )
         {
            if( verbose )
               pager_printf( ch, "...    container %d; fixing objval2 (key vnum) %d -> %d\r\n", i, obj->value[2], new_vnum );
            obj->value[2] = new_vnum;
         }
         else if( verbose )
            pager_printf( ch, "...    container %d; no need to fix.\r\n", i );
      }
      else if( obj->item_type == ITEM_SWITCH || obj->item_type == ITEM_LEVER ||
               obj->item_type == ITEM_PULLCHAIN || obj->item_type == ITEM_BUTTON )
      {
         /*
          * levers might have room vnum references in their objvals 
          */
         if( IS_SET( obj->value[0], TRIG_TELEPORT )
             || IS_SET( obj->value[0], TRIG_TELEPORTALL )
             || IS_SET( obj->value[0], TRIG_TELEPORTPLUS )
             || IS_SET( obj->value[0], TRIG_RAND4 )
             || IS_SET( obj->value[0], TRIG_RAND6 ) || IS_SET( obj->value[0], TRIG_DOOR ) )
         {
            new_vnum = find_translation( obj->value[1], r_area->r_room );
            if( new_vnum != NOT_FOUND )
            {
               if( verbose )
                  pager_printf( ch, "...    lever %d: fixing source room (%d -> %d)\r\n", i, obj->value[1], new_vnum );
               obj->value[1] = new_vnum;
            }
            if( IS_SET( obj->value[0], TRIG_DOOR ) && IS_SET( obj->value[0], TRIG_PASSAGE ) )
            {
               new_vnum = find_translation( obj->value[2], r_area->r_room );
               if( new_vnum != NOT_FOUND )
               {
                  if( verbose )
                     pager_printf( ch, "...    lever %d: fixing dest room (passage) (%d -> %d)\r\n",
                                   i, obj->value[2], new_vnum );
                  obj->value[2] = new_vnum;
               }
            }
         }
      }
   }
}
Exemplo n.º 3
0
void translate_exits( CHAR_DATA * ch, AREA_DATA * area, RENUMBER_AREA * r_area, bool verbose )
{
   int i, new_vnum;
   EXIT_DATA *pexit, *rv_exit;
   ROOM_INDEX_DATA *room;
   int old_vnum;

   for( i = area->low_r_vnum; i <= area->hi_r_vnum; i++ )
   {
      room = get_room_index( i );
      if( !room )
         continue;
      for( pexit = room->first_exit; pexit; pexit = pexit->next )
      {
         /*
          * translate the exit destination, if it was moved 
          */
         new_vnum = find_translation( pexit->vnum, r_area->r_room );
         if( new_vnum != NOT_FOUND )
            pexit->vnum = new_vnum;
         /*
          * if this room was moved 
          */
         if( pexit->rvnum != i )
         {
            old_vnum = pexit->rvnum;
            pexit->rvnum = i;
            /*
             * all reverse exits in other areas will be wrong 
             */
            rv_exit = get_exit_to( pexit->to_room, rev_dir[pexit->vdir], old_vnum );
            if( rv_exit && pexit->to_room->area != area )
            {
               if( rv_exit->vnum != i )
               {
                  pager_printf( ch, "...    fixing reverse exit in area %s.\r\n", pexit->to_room->area->filename );
                  rv_exit->vnum = i;
               }
            }
         }

         /*
          * translate the key 
          */
         if( pexit->key != -1 )
         {
            new_vnum = find_translation( pexit->key, r_area->r_obj );
            if( new_vnum == NOT_FOUND )
               continue;
            pexit->key = new_vnum;
         }
      }
   }
}
Exemplo n.º 4
0
URLTranslation *urltrans_find(URLTranslationList *trans, Msg *msg) 
{
    URLTranslation *t = NULL;
    
    t = find_translation(trans, msg);
    if (t == NULL) {
        t = find_default_translation(trans, msg->sms.smsc_id, msg->sms.sender, msg->sms.receiver, msg->sms.account);
    }

    return t;
}
Exemplo n.º 5
0
char* run_machine ( void )
{
   char* nextpc_orig;
   char* nextpc_trans;
   while (1) {
      nextpc_orig = (char*)(regs_arm[REG_PC]);
      if (nextpc_orig == stop_at)
         return NULL;
      nextpc_trans = find_translation(nextpc_orig);
      if (nextpc_trans == NULL)
         return nextpc_orig;
      run_translation(nextpc_trans, (char*) &regs_arm[0] );
   }
}
Exemplo n.º 6
0
void format(char* s, const char* fmt, const char* p, int* v, int n)
{
	const char* t = fmt;
	while (1) {
		int c = (int)strcspn(t, ESCAPE_STR);
		memcpy(s, t, c);
		s += c;
		t += c;
		if (!*t) {
			break;
		} else if (*t == ESCAPE_CHAR) {
			if (isdigit(*++t)) {	/* \N */
				c = (*t-'0') * 2;
				++t;
				memcpy(s, p+v[c], v[c+1]-v[c]);
				s += v[c+1] - v[c];
			} else if (isalpha(*t) && isdigit(*(t+1))) {
								/* \xN */
				const char* q;
				++t;
				c = *t - '0';
				if (pcre_get_substring(p, v, n, c, &q) <= 0) {
					++t;
					/* TODO: handle error */
					continue;
				}
				if (find_translation(q, s,
							to_section(*(t-1)))) {
					s += strlen(s);
				} else {
					s += pcre_copy_substring(p, v, n, c, s,
							100);
					/* TODO: fix the use of magic number */
				}
				++t;
				pcre_free_substring(q);
			} else {
				++t;
				/* do nothing */
			}
		} else {
			printf("\nformat: impossible!\n");
			system("pause");
		}
	}
	*s = 0;
}
Exemplo n.º 7
0
URLTranslation *urltrans_find(URLTranslationList *trans, Octstr *text,
			      Octstr *smsc, Octstr *sender, Octstr *receiver) 
{
    List *words;
    URLTranslation *t = NULL;
    int reject = 0;
    
    /* do not panic if text == NULL */
    if (text != NULL) {
        words = octstr_split_words(text);
        t = find_translation(trans, words, smsc, sender, receiver, &reject);
        list_destroy(words, octstr_destroy_item);
    }
    
    if (reject)
	t = find_black_list_translation(trans, smsc);
    if (t == NULL) {
	t = find_default_translation(trans, smsc, sender, receiver, &reject);
	if (reject)
	    t = find_black_list_translation(trans, smsc);
    }
    return t;
}
Exemplo n.º 8
0
void translate_reset( RESET_DATA * reset, RENUMBER_AREA * r_data )
/* this function translates a reset according to the renumber data in r_data */
{
   /*
    * a list based approach to fixing the resets. instead
    * of having a bunch of several instances of very 
    * similar code, i just made this array that tells the
    * code what to do. it's pretty straightforward 
    */
   const char *action_table[] = { "Mm1r3", "Oo1r3", "Ho1", "Po1o3",
      "Go1", "Eo1", "Dr1", "Rr1", NULL
   };
   const char *p;
   RENUMBER_DATA *r_table;
   int *parg, new_vnum, i;

   /*
    * T is a special case 
    */
   if( reset->command == 'T' )
   {
      if( IS_SET( reset->extra, TRAP_ROOM ) )
         r_table = r_data->r_room;
      else if( IS_SET( reset->extra, TRAP_OBJ ) )
         r_table = r_data->r_obj;
      else
      {
         bug( "translate_reset: Invalid 'T' reset found.\r\n" );
         return;
      }
      new_vnum = find_translation( reset->arg3, r_table );
      if( new_vnum != NOT_FOUND )
         reset->arg3 = new_vnum;
      return;
   }

   /*
    * B is another special case 
    */
   if( reset->command == 'B' )
   {
      bug( "translate_reset: B command found." );
      if( ( reset->arg2 & BIT_RESET_TYPE_MASK ) == BIT_RESET_DOOR ||
          ( reset->arg2 & BIT_RESET_TYPE_MASK ) == BIT_RESET_ROOM )
      {
         new_vnum = find_translation( reset->arg1, r_data->r_obj );
         if( new_vnum != NOT_FOUND )
            reset->arg1 = new_vnum;
      }
      return;
   }

   for( i = 0; action_table[i] != NULL; i++ )
   {
      if( reset->command == action_table[i][0] )
      {
         p = action_table[i] + 1;
         while( *p )
         {
            if( *p == 'm' )
               r_table = r_data->r_mob;
            else if( *p == 'o' )
               r_table = r_data->r_obj;
            else if( *p == 'r' )
               r_table = r_data->r_room;
            else
            {
               bug( "translate_reset: Invalid action found in action table.\r\n" );
               p += 2;
               continue;
            }
            p++;

            if( *p == '1' )
               parg = &( reset->arg1 );
            else if( *p == '2' )
               parg = &( reset->arg2 );
            else if( *p == '3' )
               parg = &( reset->arg3 );
            else
            {
               bug( "translate_reset: Invalid argument number found in action table.\r\n" );
               p++;
               continue;
            }
            p++;

            new_vnum = find_translation( *parg, r_table );
            if( new_vnum != NOT_FOUND )
               *parg = new_vnum;

         }
         return;
      }
   }

   if( action_table[i] == NULL )
      bug( "translate_reset: Invalid reset '%c' found.\r\n", reset->command );
}
Exemplo n.º 9
0
const char* ko_translateSecter(const char* untranslated, int sector, bool* found)
{
	static char result[NUM_SECTIONS][MAX_TRANSLATED_LEN];
	static char tempStr[MAX_TRANSLATED_LEN];
	if(strlen(untranslated)==1) return untranslated;
	if(sector==2)
	{
		memset(result[sector], 0, MAX_TRANSLATED_LEN);
		if (!find_translation(untranslated, result[sector], sector))
		{
			if(strcmp(untranslated+strlen(untranslated)-1, "s")==0)
			{
				strncpy(tempStr, untranslated, strlen(untranslated)-1);
				tempStr[strlen(untranslated)-1] = 0;
				if (!find_translation(tempStr, result[sector], sector))
				{
					if(strcmp(untranslated+strlen(untranslated)-2, "es")==0)
					{
						strncpy(tempStr, untranslated, strlen(untranslated)-2);
						tempStr[strlen(untranslated)-2] = 0;
						if (!find_translation(tempStr, result[sector], sector))
						{
							if(strcmp(untranslated+strlen(untranslated)-3, "ies")==0)
							{
								strncpy(tempStr, untranslated, strlen(untranslated)-3);
								tempStr[strlen(untranslated)-3] = 'y';
								tempStr[strlen(untranslated)-4] = 0;
								if (!find_translation(tempStr, result[sector], sector))
								{
									return result[sector];
								}
							}
							else
							{
								return result[sector];
							}
						}
					}
					else
					{
						return result[sector];
					}
				}
			}
			else
			{
				return result[sector];
			}
		}
	}
	else if(sector==1)
	{
		if (!find_translation(untranslated, result[sector], sector))
		{
			if(strcmp(untranslated+strlen(untranslated)-1, "s")==0)
			{
				strncpy(tempStr, untranslated, strlen(untranslated)-1);
				tempStr[strlen(untranslated)-1] = 0;
				if (!find_translation(tempStr, result[sector], sector))
				{
					if(strcmp(untranslated+strlen(untranslated)-2, "es")==0)
					{
						strncpy(tempStr, untranslated, strlen(untranslated)-2);
						tempStr[strlen(untranslated)-2] = 0;
						if (!find_translation(tempStr, result[sector], sector))
						{
							if(strcmp(untranslated+strlen(untranslated)-3, "ies")==0)
							{
								strncpy(tempStr, untranslated, strlen(untranslated)-3);
								tempStr[strlen(untranslated)-3] = 'y';
								tempStr[strlen(untranslated)-4] = 0;
								if (!find_translation(tempStr, result[sector], sector))
								{
									save_untranslated(untranslated, sector);
									*found = false;
									return untranslated;
								}
							}
							else
							{
								save_untranslated(untranslated, sector);
								*found = false;
								return untranslated;
							}
						}
					}
					else
					{
						save_untranslated(untranslated, sector);
						*found = false;
						return untranslated;
					}
				}
			}
			else
			{
				save_untranslated(untranslated, sector);
				*found = false;
				return untranslated;
			}
		}
	}
	else
	{
		if (!find_translation(untranslated, result[sector], sector))
		{
			save_untranslated(untranslated, sector);
			*found = false;
			return untranslated;
		}
	}
	return result[sector];
}