コード例 #1
0
ファイル: Commands.cpp プロジェクト: SummerSnail2014/haiku
bool
FetchMessageEntriesCommand::HandleUntagged(Response& response)
{
	if (!response.EqualsAt(1, "FETCH") || !response.IsListAt(2))
		return false;

	MessageEntry entry;

	ArgumentList& list = response.ListAt(2);
	for (int32 i = 0; i < list.CountItems(); i += 2) {
		if (list.EqualsAt(i, "UID") && list.IsNumberAt(i + 1))
			entry.uid = list.NumberAt(i + 1);
		else if (list.EqualsAt(i, "RFC822.SIZE") && list.IsNumberAt(i + 1))
			entry.size = list.NumberAt(i + 1);
		else if (list.EqualsAt(i, "FLAGS") && list.IsListAt(i + 1)) {
			// Parse flags
			ArgumentList& flags = list.ListAt(i + 1);
			entry.flags = ParseFlags(flags);
		}
	}

	if (entry.uid == 0)
		return false;

	fEntries.push_back(entry);
	return true;
}
コード例 #2
0
bool
WaypointReaderZander::ParseLine(const TCHAR* line, const unsigned linenum,
                              Waypoints &way_points)
{
  // If (end-of-file or comment)
  if (line[0] == '\0' || line[0] == 0x1a ||
      _tcsstr(line, _T("**")) == line ||
      _tcsstr(line, _T("*")) == line)
    // -> return without error condition
    return true;

  // Determine the length of the line
  size_t len = _tcslen(line);
  // If less then 34 characters -> something is wrong -> cancel
  if (len < 34)
    return false;

  GeoPoint location;

  // Latitude (Characters 13-20 // DDMMSS(N/S))
  if (!ParseAngle(line + 13, location.latitude, true))
    return false;

  // Longitude (Characters 21-29 // DDDMMSS(E/W))
  if (!ParseAngle(line + 21, location.longitude, false))
    return false;

  location.Normalize(); // ensure longitude is within -180:180

  Waypoint new_waypoint(location);
  new_waypoint.file_num = file_num;
  new_waypoint.original_id = 0;

  // Name (Characters 0-12)
  if (!ParseString(line, new_waypoint.name, 12))
    return false;

  // Altitude (Characters 30-34 // e.g. 1561 (in meters))
  /// @todo configurable behaviour
  if (!ParseAltitude(line + 30, new_waypoint.elevation) &&
      !CheckAltitude(new_waypoint))
    return false;

  // Description (Characters 35-44)
  if (len > 35)
    ParseString(line + 35, new_waypoint.comment, 9);

  // Flags (Characters 45-49)
  if (len < 46 || !ParseFlags(line + 45, new_waypoint))
    if (len < 36 || !ParseFlagsFromDescription(line + 35, new_waypoint))
      new_waypoint.flags.turn_point = true;

  way_points.Append(new_waypoint);
  return true;
}
コード例 #3
0
HRESULT
Vc4Disasm::Run(const VC4_QPU_INSTRUCTION* pShader, ULONG ShaderSize, TCHAR *pTitle)
{
    if (pTitle) this->xprintf(TEXT("---------- %s ----------\n"), pTitle);
    ULONG cInstruction = ShaderSize / sizeof(VC4_QPU_INSTRUCTION);
    for (ULONG i = 0; i < cInstruction; i++)
    {
        VC4_QPU_INSTRUCTION Instruction = pShader[i];
        ParseSignature(Instruction);
        switch (VC4_QPU_GET_SIG(Instruction))
        {
        case VC4_QPU_SIG_BREAK:
        case VC4_QPU_SIG_NO_SIGNAL:
        case VC4_QPU_SIG_THREAD_SWITCH:
        case VC4_QPU_SIG_PROGRAM_END:
        case VC4_QPU_SIG_WAIT_FOR_SCOREBOARD:
        case VC4_QPU_SIG_SCOREBOARD_UNBLOCK:
        case VC4_QPU_SIG_LAST_THREAD_SWITCH:
        case VC4_QPU_SIG_COVERAGE_LOAD:
        case VC4_QPU_SIG_COLOR_LOAD:
        case VC4_QPU_SIG_COLOR_LOAD_AND_PROGRAM_END:
        case VC4_QPU_SIG_LOAD_TMU0:
        case VC4_QPU_SIG_LOAD_TMU1:
        case VC4_QPU_SIG_ALPAH_MASK_LOAD:
        case VC4_QPU_SIG_ALU_WITH_RADDR_B:
            ParseALUInstruction(Instruction);
            break;
        case VC4_QPU_SIG_LOAD_IMMEDIATE:
            if (VC4_QPU_IS_OPCODE_SEMAPHORE(Instruction))
            {
                ParseSemaphoreInstruction(Instruction);
            }
            else
            {
                ParseLoadImmInstruction(Instruction);
            }
            break;
        case VC4_QPU_SIG_BRANCH:
            ParseBranchInstruction(Instruction);
            break;
        default:
            this->xprintf(TEXT("Invalid signature"));
            break;
        }
        ParseFlags(Instruction);
        Flush(0);
    }
    return S_OK;
}
コード例 #4
0
ファイル: suntans.c プロジェクト: jadelson/suntans-joe
int main(int argc, char *argv[])
{
  int myproc, numprocs, j;
  MPI_Comm comm;
  gridT *grid;
  physT *phys;
  propT *prop;

  StartMpi(&argc,&argv,&comm,&myproc,&numprocs);

  ParseFlags(argc,argv,myproc);
  
  if(GRID)
    GetGrid(&grid,myproc,numprocs,comm);
  else
    ReadGrid(&grid,myproc,numprocs,comm);
  

  if(SOLVE) {
    //read parameters in suntans.dat into the solver
    ReadProperties(&prop,grid,myproc);
    // give space and initialize dzf(edge) dzz(center) dzzold(center)
    InitializeVerticalGrid(&grid,myproc);
    AllocatePhysicalVariables(grid,&phys,prop);
    AllocateTransferArrays(&grid,myproc,numprocs,comm);
    OpenFiles(prop,myproc);
    if(RESTART)
      ReadPhysicalVariables(grid,phys,prop,myproc,comm);
    else
      InitializePhysicalVariables(grid,phys,prop,myproc,comm);

    Solve(grid,phys,prop,myproc,numprocs,comm);
    //    FreePhysicalVariables(grid,phys,prop);
    //    FreeTransferArrays(grid,myproc,numprocs,comm);
  }

  EndMpi(&comm);
}
コード例 #5
0
ファイル: Commands.cpp プロジェクト: SummerSnail2014/haiku
bool
FetchCommand::HandleUntagged(Response& response)
{
	if (!response.EqualsAt(1, "FETCH") || !response.IsListAt(2))
		return false;

	ArgumentList& list = response.ListAt(2);
	uint32 uid = 0;
	uint32 flags = 0;

	for (int32 i = 0; i < list.CountItems(); i += 2) {
		if (list.EqualsAt(i, "UID") && list.IsNumberAt(i + 1))
			uid = list.NumberAt(i + 1);
		else if (list.EqualsAt(i, "FLAGS") && list.IsListAt(i + 1)) {
			// Parse flags
			ArgumentList& flagList = list.ListAt(i + 1);
			flags = ParseFlags(flagList);
		}
	}

	if (fListener != NULL)
		fListener->FetchedData(fFlags, uid, flags);
	return true;
}
コード例 #6
0
ファイル: specification.cpp プロジェクト: acmol/toft
int PrintSpecification::Parse(const char* format)
{
    const char* f = format;

    f += ParseFlags(f, &this->flags);
    f += ParsePrintWidth(f, &this->width);

    if (*f == '.') {
        ++f;
        int n = ParsePrintWidth(f, &this->precision);
        if (n > 0)
            f += n;
        else
            return 0;
    }

    f += ParseLength(f, &this->length);
    int n = ParsePrintSpecifier(f, &this->specifier);
    if (n == 0)
        return 0;
    f += n;

    return f - format;
}
コード例 #7
0
bool
WaypointReaderWinPilot::ParseLine(const TCHAR *line, Waypoints &waypoints)
{
  TCHAR ctemp[4096];
  const TCHAR *params[20];
  static constexpr unsigned int max_params = ARRAY_SIZE(params);
  size_t n_params;

  // If (end-of-file)
  if (line[0] == '\0')
    // -> return without error condition
    return true;

  // If comment
  if (line[0] == _T('*')) {
    if (first) {
      first = false;
      welt2000_format = (_tcsstr(line, _T("WRITTEN BY WELT2000")) != nullptr);
    }

    // -> return without error condition
    return true;
  }

  if (_tcslen(line) >= ARRAY_SIZE(ctemp))
    /* line too long for buffer */
    return false;

  GeoPoint location;

  // Get fields
  n_params = ExtractParameters(line, ctemp, params, max_params, true);
  if (n_params < 6)
    return false;

  // Latitude (e.g. 51:15.900N)
  if (!ParseAngle(params[1], location.latitude, true))
    return false;

  // Longitude (e.g. 00715.900W)
  if (!ParseAngle(params[2], location.longitude, false))
    return false;
  location.Normalize(); // ensure longitude is within -180:180

  Waypoint new_waypoint = factory.Create(location);

  // Name (e.g. KAMPLI)
  if (*params[5] == _T('\0'))
    return false;
  new_waypoint.name=params[5];

  // Altitude (e.g. 458M)
  /// @todo configurable behaviour
  if (!ParseAltitude(params[3], new_waypoint.elevation) &&
      !factory.FallbackElevation(new_waypoint))
    return false;

  if (n_params > 6) {
    // Description (e.g. 119.750 Airport)
    new_waypoint.comment=params[6];
    if (welt2000_format)
      ParseRunwayDirection(params[6], new_waypoint.runway);
  }

  // Waypoint Flags (e.g. AT)
  ParseFlags(params[4], new_waypoint);

  waypoints.Append(std::move(new_waypoint));
  return true;
}
コード例 #8
0
static bool
ParseWayPointString(WAYPOINT *Temp, const TCHAR *input,
                    RasterTerrain &terrain)
{
  TCHAR *endptr;
  size_t length;

  Temp->FileNum = globalFileNum;

  Temp->Number = _tcstol(input, &endptr, 10);
  if (endptr == input || *endptr != _T(','))
    return false;

  input = endptr + 1;

  if (!ParseAngle(input, &Temp->Location.Latitude, &endptr) ||
      Temp->Location.Latitude > 90 || Temp->Location.Latitude < -90 ||
      *endptr != _T(','))
    return false;

  input = endptr + 1;

  ParseAngle(input, &Temp->Location.Longitude, &endptr);
  if (!ParseAngle(input, &Temp->Location.Longitude, &endptr) ||
      Temp->Location.Longitude > 180 || Temp->Location.Longitude < -180 ||
      *endptr != _T(','))
    return false;

  input = endptr + 1;

  if (!ParseAltitude(input, &Temp->Altitude, &endptr) ||
      *endptr != _T(','))
    return false;

  input = endptr + 1;

  Temp->Flags = ParseFlags(input, &input);
  if (*input != _T(','))
    return false;

  ++input;

  endptr = _tcschr(input, _T(','));
  if (endptr != NULL)
    length = endptr - input;
  else
    length = _tcslen(input);

  if (length >= sizeof(Temp->Name))
    length = sizeof(Temp->Name) - 1;

  while (length > 0 && input[length - 1] == 0)
    --length;

  memcpy(Temp->Name, input, length * sizeof(input[0]));
  Temp->Name[length] = 0;

  if (endptr != NULL) {
    input = endptr + 1;

    endptr = _tcschr(input, '*');
    if (endptr != NULL) {
      length = endptr - input;

      // if it is a home waypoint raise zoom level
      Temp->Zoom = _tcstol(endptr + 2, NULL, 10);
    } else {
      length = _tcslen(input);
      Temp->Zoom = 0;
    }

    if (length >= sizeof(Temp->Comment))
      length = sizeof(Temp->Comment) - 1;

    while (length > 0 && input[length - 1] == 0)
      --length;

    memcpy(Temp->Comment, input, length * sizeof(input[0]));
    Temp->Comment[length] = 0;
  } else {
    Temp->Comment[0] = 0;
    Temp->Zoom = 0;
  }

  if(Temp->Altitude <= 0) {
    WaypointAltitudeFromTerrain(Temp, terrain);
  }

  if (Temp->Details) {
    free(Temp->Details);
  }

  return true;
}
コード例 #9
0
ファイル: FxTemplate.cpp プロジェクト: LTolosa/Jedi-Outcast
// Parse a primitive, apply defaults first, grab any base level
//	key pairs, then process any sub groups we may contain.
//------------------------------------------------------
bool CPrimitiveTemplate::ParsePrimitive( CGPGroup *grp )
{
	CGPGroup	*subGrp;
	CGPValue	*pairs;
	const char	*key; 
	const char	*val;

	// Lets work with the pairs first
	pairs = grp->GetPairs();

	while( pairs )
	{
		// the fields
		key = pairs->GetName();
		val = pairs->GetTopValue();

		// Huge stricmp lists suxor
		if ( !stricmp( key, "count" ))
		{
			ParseCount( val );
		}
		else if ( !stricmp( key, "shaders" ) || !stricmp( key, "shader" ))
		{
			ParseShaders( pairs );
		}
		else if ( !stricmp( key, "models" ) || !stricmp( key, "model" ))
		{
			ParseModels( pairs );
		}
		else if ( !stricmp( key, "sounds" ) || !stricmp( key, "sound" ))
		{
			ParseSounds( pairs );
		}
		else if ( !stricmp( key, "impactfx" ))
		{
			ParseImpactFxStrings( pairs );
		}
		else if ( !stricmp( key, "deathfx" ))
		{
			ParseDeathFxStrings( pairs );
		}
		else if ( !stricmp( key, "emitfx" ))
		{
			ParseEmitterFxStrings( pairs );
		}
		else if ( !stricmp( key, "playfx" ))
		{
			ParsePlayFxStrings( pairs );
		}
		else if ( !stricmp( key, "life" ))
		{
			ParseLife( val );
		}
		else if ( !stricmp( key, "cullrange" ))
		{
			mCullRange = atoi( val );
			mCullRange *= mCullRange; // Square
		}
		else if ( !stricmp( key, "delay" ))
		{
			ParseDelay( val );
		}
		else if ( !stricmp( key, "bounce" ) || !stricmp( key, "intensity" )) // me==bad for reusing this...but it shouldn't hurt anything)
		{
			ParseElasticity( val );
		}
		else if ( !stricmp( key, "min" ))
		{
			ParseMin( val );
		}
		else if ( !stricmp( key, "max" ))
		{
			ParseMax( val );
		}
		else if ( !stricmp( key, "angle" ) || !stricmp( key, "angles" ))
		{
			ParseAngle( val );
		}
		else if ( !stricmp( key, "angleDelta" ))
		{
			ParseAngleDelta( val );
		}
		else if ( !stricmp( key, "velocity" ) || !stricmp( key, "vel" ))
		{
			ParseVelocity( val );
		}
		else if ( !stricmp( key, "acceleration" ) || !stricmp( key, "accel" ))
		{
			ParseAcceleration( val );
		}
		else if ( !stricmp( key, "gravity" ))
		{
			ParseGravity( val );
		}
		else if ( !stricmp( key, "density" ))
		{
			ParseDensity( val );
		}
		else if ( !stricmp( key, "variance" ))
		{
			ParseVariance( val );
		}
		else if ( !stricmp( key, "origin" ))
		{
			ParseOrigin1( val );
		}
		else if ( !stricmp( key, "origin2" ))
		{
			ParseOrigin2( val );
		}
		else if ( !stricmp( key, "radius" )) // part of ellipse/cylinder calcs.
		{
			ParseRadius( val );
		}
		else if ( !stricmp( key, "height" )) // part of ellipse/cylinder calcs.
		{
			ParseHeight( val );
		}
		else if ( !stricmp( key, "rotation" ))
		{
			ParseRotation( val );
		}
		else if ( !Q_stricmp( key, "rotationDelta" ))
		{
			ParseRotationDelta( val );
		}
		else if ( !stricmp( key, "flags" ) || !stricmp( key, "flag" ))
		{ // these need to get passed on to the primitive
			ParseFlags( val );
		}
		else if ( !stricmp( key, "spawnFlags" ) || !stricmp( key, "spawnFlag" ))
		{ // these are used to spawn things in cool ways, but don't ever get passed on to prims.
			ParseSpawnFlags( val );
		}
		else if ( !stricmp( key, "name" ))
		{
			if ( val )
			{
				// just stash the descriptive name of the primitive
				strcpy( mName, val );
			}
		}
		else
		{
			theFxHelper.Print( "Unknown key parsing an effect primitive: %s\n", key );
		}

		pairs = (CGPValue *)pairs->GetNext();
	}

	subGrp = grp->GetSubGroups();

	// Lets chomp on the groups now
	while ( subGrp )
	{
		key = subGrp->GetName();

		if ( !stricmp( key, "rgb" ))
		{
			ParseRGB( subGrp );
		}
		else if ( !stricmp( key, "alpha" ))
		{
			ParseAlpha( subGrp );
		}
		else if ( !stricmp( key, "size" ) || !stricmp( key, "width" ))
		{
			ParseSize( subGrp );
		}
		else if ( !stricmp( key, "size2" ) || !stricmp( key, "width2" ))
		{
			ParseSize2( subGrp );
		}
		else if ( !stricmp( key, "length" ) || !stricmp( key, "height" ))
		{
			ParseLength( subGrp );
		}
		else
		{
			theFxHelper.Print( "Unknown group key parsing a particle: %s\n", key );
		}

		subGrp = (CGPGroup *)subGrp->GetNext();
	}

	return true;
}
コード例 #10
0
//--------------------------------------------------------------------
// @mfunc Tokenize the column info
//
// @rdesc BOOL
//      @flag TRUE | Parsing yielded no Error
//
BOOL CParseInitFile::GetColumns
(
	CHAR*  pszInput
)
{
	ASSERT(pszInput);
	WCHAR*	pwszColName = NULL;
	WCHAR*	pwszColIDName = NULL;
	WCHAR*	pwszTempGuid = NULL;
	WCHAR*	pwszPrefix = NULL;
	WCHAR*	pwszSuffix = NULL;
	CCol	NewCol;
	DBID	dbidCol;
	GUID*	pGuid = NULL;
	GUID	guid;
	HRESULT hr = S_OK;
	
	CHAR*	pszStart	= pszInput;
	CHAR*	pszEndData	= strchr(pszStart, ',');
	CHAR*	pszEnd		= pszStart + strlen(pszStart);

	TRACE_CALL(L"PRIVLIB: CParseInitFile::GetColumns.\n");

	memset(&dbidCol, 0, sizeof(DBID));

	//Initialize NewCol to default values
	InitializeNewCol(NewCol);
	
	//Error checking
	if(pszStart==NULL || pszEndData==NULL || pszEndData > pszEnd)
	{
		odtLog << "ERROR:  Unable to find Column Name, Seperators, or End Markers in INI <File:" << m_pszFileName << ">" << ENDL;
		odtLog << "ERROR:  Make sure your using a correctly generated INI File from TableDump.exe" << ENDL;
		return FALSE;
	}

	//Loop over all column info		
	for(ULONG i=0; i<=COL_SUFFIX; i++)
	{
		//Place the NULL Terminator
		pszEndData[0] = '\0';
		
		//Fill in Appropiate column info
		if(i==COL_NAME)
		{
			//Column Names can be NULL
			PROVIDER_FREE(pwszColName);
			if(pszStart != pszEndData)
			{
				//Convert to WCHAR
				pwszColName = ConvertToWCHAR(pszStart);
			}
			
			//Store the column name
			NewCol.SetColName(pwszColName);
		}
		else if(i==COL_NUMBER)
		{
			// column num
			NewCol.SetColNum(strtoul(pszStart, NULL, 10));
		}
		else if(i==COL_DBTYPE)
		{
			// column DBTYPE
			NewCol.SetProviderType(ConvertToDBTYPE(pszStart));
		}
		else if(i==COL_SIZE)
		{
			DBLENGTH ulValue = strtoul(pszStart, NULL, 10);
			
			//set the column size
			NewCol.SetColumnSize(ulValue);
		}
		else if(i==COL_PRECISION)
		{
			ULONG ulValue = strtoul(pszStart, NULL, 10);

			// set the actual column precision
			NewCol.SetPrecision((BYTE)ulValue);
		}			
		else if(i==COL_SCALE)
		{
			// column scale
			NewCol.SetScale((BYTE)strtol(pszStart, NULL, 10));
		}
		else if(i==COL_FLAGS)
		{
			// column Flags
			ParseFlags(pszStart, NewCol);
		}
		else if(i==COL_PREFIX)
		{
			//if the ini has null here (which is marked as '(null)' then set 
			//it the way it should be
			if (strcmp("(null)",pszStart))
			{
				// column Flags
				PROVIDER_FREE(pwszPrefix)
				pwszPrefix = ConvertToWCHAR(pszStart);
				NewCol.SetPrefix(pwszPrefix);
			}
			else
			{
				// column Flags
				PROVIDER_FREE(pwszPrefix)
				pwszPrefix = ConvertToWCHAR("");
				NewCol.SetPrefix(pwszPrefix);
			}
		}
		else if(i==COL_SUFFIX)
		{
			//if the ini has null here (which is marked as '(null)' then set 
			//it the way it should be
			if (strcmp("(null)",pszStart))
			{
				// column Flags
				PROVIDER_FREE(pwszSuffix)
				pwszSuffix = ConvertToWCHAR(pszStart);
				NewCol.SetSuffix(pwszSuffix);
			}
			else
			{
				// column Flags
				PROVIDER_FREE(pwszSuffix)
				pwszSuffix = ConvertToWCHAR("");
				NewCol.SetSuffix(pwszSuffix);
			}
		}
		else if((i==COL_IDKIND) && (pszStart != pszEndData))
		{
			dbidCol.eKind = strtoul(pszStart, NULL, 10);
		}
		else if((i==COL_IDGUID) && (pszStart != pszEndData))
		{
			if(dbidCol.eKind == DBKIND_PGUID_NAME ||
				dbidCol.eKind == DBKIND_PGUID_PROPID)
			{
				SAFE_ALLOC(pGuid, GUID, 1);
				PROVIDER_FREE(pwszTempGuid);
				pwszTempGuid = ConvertToWCHAR(pszStart);
				hr = CLSIDFromString(pwszTempGuid, pGuid);
				dbidCol.uGuid.pguid = pGuid;
			}
			else
			{
				PROVIDER_FREE(pwszTempGuid);
				pwszTempGuid = ConvertToWCHAR(pszStart);
				hr = CLSIDFromString(pwszTempGuid, &guid);
				dbidCol.uGuid.guid = guid;
			}
		}
		else if((i==COL_IDNAME) && (pszStart != pszEndData))
		{
			if(dbidCol.eKind == DBKIND_PGUID_NAME ||
				dbidCol.eKind == DBKIND_GUID_NAME ||
				dbidCol.eKind == DBKIND_NAME )
			{
				PROVIDER_FREE(pwszColIDName);
				pwszColIDName = ConvertToWCHAR(pszStart);
				dbidCol.uName.pwszName = pwszColIDName;
			}
			else
			{
				dbidCol.uName.ulPropid = strtoul(pszStart, NULL, 10);
			}
		}

		//Find the next Info Piece
		if(i<COL_SUFFIX)
		{
			pszStart	= pszEndData+1;
			pszEndData	= strchr(pszStart, ',');
			if((i==COL_FLAGS) && (!pszEndData))
				goto END;
			if(pszEndData == NULL)
				pszEndData = pszEnd;

			//Error checking
			if(pszStart==NULL || pszEndData==NULL || pszEndData > pszEnd)
			{
				odtLog << "ERROR:  Unable to find Column Name, Seperators, or End Markers in INI <File:" << m_pszFileName << ">" << ENDL;
				odtLog << "ERROR:  Make sure your using a correctly generated INI File from TableDump.exe" << ENDL;
				return FALSE;
			}
		}
	}

END:
	//Add the new columnInfo at the end fo the list
	NewCol.SetColID(&dbidCol);
	m_ColData.AddTail(NewCol);

CLEANUP:
	PROVIDER_FREE(pwszColName);
	PROVIDER_FREE(pGuid);
	PROVIDER_FREE(pwszColIDName);
	PROVIDER_FREE(pwszTempGuid);
	PROVIDER_FREE(pwszPrefix);
	PROVIDER_FREE(pwszSuffix);
	return  TRUE;
}
コード例 #11
0
ファイル: parser.c プロジェクト: NVIDIA/winex_lgpl
/*******************************************************************
 *         ParseOrdinal
 *
 * Parse an ordinal definition.
 */
static void ParseOrdinal(int ordinal)
{
    const char *token;

    ORDDEF *odp = xmalloc( sizeof(*odp) );
    memset( odp, 0, sizeof(*odp) );
    EntryPoints[nb_entry_points++] = odp;

    token = GetToken(0);

    for (odp->type = 0; odp->type < TYPE_NBTYPES; odp->type++)
        if (TypeNames[odp->type] && !strcmp( token, TypeNames[odp->type] ))
            break;

    if (odp->type >= TYPE_NBTYPES)
        fatal_error( "Expected type after ordinal, found '%s' instead\n", token );

    token = GetToken(0);
    if (*token == '-') token = ParseFlags( odp );

    odp->name = xstrdup( token );
    odp->export_name = xstrdup( token );
    fix_export_name( odp->name );
    odp->lineno = current_line;
    odp->ordinal = ordinal;

    switch(odp->type)
    {
    case TYPE_VARIABLE:
        ParseVariable( odp );
        break;
    case TYPE_PASCAL_16:
    case TYPE_PASCAL:
    case TYPE_STDCALL:
    case TYPE_VARARGS:
    case TYPE_CDECL:
        ParseExportFunction( odp );
        break;
    case TYPE_ABS:
        ParseEquate( odp );
        break;
    case TYPE_STUB:
        ParseStub( odp );
        break;
    case TYPE_EXTERN:
        ParseExtern( odp );
        break;
    case TYPE_FORWARD:
        ParseForward( odp );
        break;
    default:
        assert( 0 );
    }

#ifndef __i386__
    if (odp->flags & FLAG_I386)
    {
        /* ignore this entry point on non-Intel archs */
        EntryPoints[--nb_entry_points] = NULL;
        free( odp );
        return;
    }
#endif

    if (ordinal != -1)
    {
        if (ordinal >= MAX_ORDINALS) fatal_error( "Ordinal number %d too large\n", ordinal );
        if (ordinal > Limit) Limit = ordinal;
        if (ordinal < Base) Base = ordinal;
        odp->ordinal = ordinal;
        Ordinals[ordinal] = odp;
    }

    if (!strcmp( odp->name, "@" ))
    {
        if (ordinal == -1)
            fatal_error( "Nameless function needs an explicit ordinal number\n" );
        if (SpecType != SPEC_WIN32)
            fatal_error( "Nameless functions not supported for Win16\n" );
        odp->name[0] = 0;
    }
    else Names[nb_names++] = odp;
}
コード例 #12
0
ファイル: wc16printf.c プロジェクト: bhanug/likewise-open
static
int
W16PrintfCore(
    PPRINTF_BUFFER pBuffer,
    int bMSCompat,
    const wchar16_t* pwszFormat,
    va_list args
    )
{
    size_t sLen = 0;
    const wchar16_t* pwszPos = pwszFormat;
    const wchar16_t* pwszTokenStart = pwszFormat;
    unsigned int dwFlags = 0;
    unsigned int dwLengthModifier = 0;
    unsigned int dwType = 0;
    size_t sWidth = 0;
    ssize_t iPrecision = -1;
    // Enough room for all supported fixed sized types
    char szArgBuffer[100];
    wchar_t wszArgBuffer[1];
    wchar16_t w16szArgBuffer[100];
    // Enough room for all supported format specifiers
    char szFormatBuffer[20];
    char *pszFormatBufferPos = NULL;

    while (*pwszPos)
    {
        if (*pwszPos == '%')
        {
            pBuffer->pfnWriteWc16s(
                    pBuffer,
                    pwszTokenStart,
                    pwszPos - pwszTokenStart);

            pwszPos++;

            // Put the format specifier (% included) into a multibyte
            // string incase regular printf needs to be called
            pszFormatBufferPos = szFormatBuffer;
            *pszFormatBufferPos++ = '%';

            pwszTokenStart = pwszPos;
            dwFlags = ParseFlags(&pwszPos);
            // update multibyte format
            // subtract for % * . * null
            if (pwszPos - pwszTokenStart > sizeof(szFormatBuffer) - 5)
            {
                errno = ENOMEM;
                return -1;
            }
            sLen = wc16stombs(
                    pszFormatBufferPos,
                    pwszTokenStart,
                    pwszPos - pwszTokenStart);
            if (sLen == (size_t)-1)
            {
                return -1;
            }
            pszFormatBufferPos += sLen;

            if (*pwszPos == '*')
            {
                pwszPos++;
                sWidth = va_arg(args, size_t);
            }
            else
            {
                sWidth = (size_t)wc16stoull(pwszPos, &pwszPos, 10);
            }
            *pszFormatBufferPos++ = '*';

            iPrecision = -1;
            if (*pwszPos == '.')
            {
                pwszPos++;
                if (*pwszPos == '*')
                {
                    pwszPos++;
                    iPrecision = va_arg(args, ssize_t);
                }
                else if (*pwszPos != '-')
                {
                    iPrecision = (ssize_t)wc16stoull(pwszPos, &pwszPos, 10);
                }
            }
            *pszFormatBufferPos++ = '.';
            *pszFormatBufferPos++ = '*';

            pwszTokenStart = pwszPos;

            dwLengthModifier = ParseLengthModifier(&pwszPos);
            dwType = ParseType(&pwszPos, &dwType);

            if (pszFormatBufferPos - szFormatBuffer +
                    pwszPos - pwszTokenStart > sizeof(szFormatBuffer) - 1)
            {
                errno = ENOMEM;
                return -1;
            }
            sLen = wc16stombs(
                    pszFormatBufferPos,
                    pwszTokenStart,
                    pwszPos - pwszTokenStart);
            if (sLen == (size_t)-1)
            {
                return -1;
            }
            pszFormatBufferPos += sLen;
            *pszFormatBufferPos = 0;

            if (bMSCompat && (dwType == TYPE_STRING || dwType == TYPE_CHAR))
            {
                if (dwLengthModifier == LENGTH_LONG)
                {
                    dwLengthModifier = LENGTH_W16CHAR_T;
                }
                else if (dwLengthModifier == LENGTH_SHORT)
                {
                    dwLengthModifier = LENGTH_CHAR;
                }
                else
                {
                    if (dwFlags & FLAG_UPPER_CASE)
                    {
                        dwLengthModifier = LENGTH_CHAR;
                    }
                    else
                    {
                        dwLengthModifier = LENGTH_W16CHAR_T;
                    }
                }
            }

            switch (dwType)
            {
                case TYPE_OCTAL:
                case TYPE_UNSIGNED_INTEGER:
                case TYPE_HEX:
                case TYPE_INTEGER:
                    if (dwLengthModifier == LENGTH_LONG_LONG)
                    {
                        long long llArg = va_arg(args, long long);
                        sLen = snprintf(
                                    szArgBuffer,
                                    sizeof(szArgBuffer),
                                    szFormatBuffer,
                                    sWidth,
                                    iPrecision,
                                    llArg);
                    }
                    else
                    {
                        long lArg = va_arg(args, long);
                        sLen = snprintf(
                                    szArgBuffer,
                                    sizeof(szArgBuffer),
                                    szFormatBuffer,
                                    sWidth,
                                    iPrecision,
                                    lArg);
                    }
                    if (sLen > sizeof(szArgBuffer) || (ssize_t) sLen < 0)
                    {
                        errno = ENOMEM;
                        return -1;
                    }
                    pBuffer->pfnWriteMbs(pBuffer, szArgBuffer, sLen);
                    break;

                case TYPE_DOUBLE:
                case TYPE_AUTO_DOUBLE:
                case TYPE_HEX_DOUBLE:
                case TYPE_SCIENTIFIC:
                    if (dwLengthModifier == LENGTH_LONG_DOUBLE)
                    {
                        long double ldArg = va_arg(args, long double);
                        sLen = snprintf(
                                    szArgBuffer,
                                    sizeof(szArgBuffer),
                                    szFormatBuffer,
                                    sWidth,
                                    iPrecision,
                                    ldArg);
                    }
コード例 #13
0
ファイル: suntans.c プロジェクト: jadelson/suntans-joe
main(int argc, char *argv[])
{
  int myproc, numprocs, j, i;
  MPI_Comm comm;
  gridT *grid;
  physT *phys;
  propT *prop;
  sediT *sedi;
  spropT *sprop;
  waveT *wave;
  wpropT *wprop;

  StartMpi(&argc,&argv,&comm,&myproc,&numprocs);

  ParseFlags(argc,argv,myproc);
  
  
  if(GRID)
    GetGrid(&grid,myproc,numprocs,comm);
  else
    ReadGrid(&grid,myproc,numprocs,comm);


  if(SOLVE) {
    ReadProperties(&prop,myproc);
    InitializeVerticalGrid(&grid);
    AllocatePhysicalVariables(grid,&phys,prop);

   // if(prop->wave){
      InitializeWaveProperties(&wprop, prop, myproc);
      AllocateWaveVariables(grid, &wave, prop, wprop);
      InitializeWaveVariables(grid, wave, prop, wprop, myproc, comm);
      
   // }
    
    if(prop->sedi){
      InitializeSediProperties(prop, &sprop, myproc);
      AllocateSediVariables(grid, &sedi, sprop, prop);
      InitializeSediVariables(grid, sedi, prop, sprop, myproc, comm);
    }
    
    AllocateTransferArrays(&grid,myproc,numprocs,comm);
    
    OpenFiles(prop,myproc);
    
    if(RESTART){
      ReadPhysicalVariables(grid,phys,prop,sedi,sprop,wave,wprop,myproc,comm);
     
    }
    else{
      InitializePhysicalVariables(grid,phys,sedi,prop,sprop);
      
    }

    InputTides(grid, phys, prop, myproc);
    
    SetDragCoefficients(grid,phys,prop);
    
    if (prop->wave)
      if (wprop->wind_forcing){
    	ObtainKrigingCoef(grid, wave, wprop, myproc, numprocs);    
    	for (i = 0; i< wprop->nstation; i++)      
    	  InputWind(i, prop, wave,wprop,myproc,numprocs);
      }

   
    Solve(grid,phys,prop,sprop,sedi,wave,wprop,myproc,numprocs,comm);
   
    //    FreePhysicalVariables(grid,phys,prop);
    //    FreeTransferArrays(grid,myproc,numprocs,comm);   
  }

  EndMpi(&comm);
}
コード例 #14
0
ファイル: cheat_codes_new.cpp プロジェクト: jewalky/srvmgr
void RunCommand(byte* _this, byte* player, const char* ccommand, uint32_t rights, bool console)
{
    if(!ccommand) return;
    if(ccommand[0] != '#') return;

    std::string command(ccommand);
    command = Trim(command);

    std::string rawcmd = command;

    size_t spacepos = command.find_first_of(' ');
    if(spacepos != std::string::npos)
        rawcmd.erase(spacepos);

    if(rawcmd == "#mapinfo")
    {
		const char* map_file = Config::CurrentMapName.c_str();
		const char* map_name = Config::CurrentMapTitle.c_str();

		uint32_t tme = zxmgr::GetCurrentMapTime()/1000;
		uint32_t tm_h = tme / 3600;
		uint32_t tm_m = tme / 60 - tm_h * 60;
		uint32_t tm_s = tme - (tm_h * 3600 + tm_m * 60);
		tme = zxmgr::GetTotalMapTime()*60;
		uint32_t tt_h = tme / 3600;
		uint32_t tt_m = tme / 60 - tt_h * 60;
		uint32_t tt_s = tme - (tt_h * 3600 + tt_m * 60);

        std::string time_left = "infinite";
        if(!Config::Suspended && zxmgr::GetTotalMapTime() != 0x7FFFFFFF) time_left = Format("%u:%02u:%02u", tt_h, tt_m, tt_s);

        if(player) zxmgr::SendMessage(player, "map: \"%s\" in \"%s\", time elapsed: %u:%02u:%02u, time total: %s", map_name, map_file, tm_h, tm_m, tm_s, time_left.c_str());
        else if(console) Printf("Map: \"%s\" in \"%s\", time elapsed: %u:%02u:%02u, time total: %s", map_name, map_file, tm_h, tm_m, tm_s, time_left.c_str());
        goto ex;
    }

    if(rights & GMF_CMD_CHAT)
    {
        if(command.find("#@") == 0)
        {
            command.erase(0, 2);
            std::string what = "";
            if(!player || console) what = Format("[broadcast] <server%u>: %s", Config::ServerID, command.c_str());
            else if(player) what = Format("[broadcast] %s: %s", *(const char**)(player + 0x18), command.c_str());
            else what = Format("[broadcast] %s", command.c_str());
            if(!NetCmd_Broadcast(what)) NetHat::Connected = false;
            goto ex;
        }
        else if(command.find("#!") == 0)
        {
            command.erase(0, 2);
            if(!player || console) zxmgr::SendMessage(NULL, "<server>: %s", command.c_str());
            else if(player) zxmgr::SendMessage(NULL, "%s: %s", *(const char**)(player + 0x18), command.c_str());
            else zxmgr::SendMessage(NULL, command.c_str());
            goto ex;
        }
    }

    if(rights & GMF_CMD_KICK)
    {
        if(rawcmd == "#kick")
        {
            command.erase(0, 5);
            command = TrimLeft(command);
			byte* target = zxmgr::FindByNickname(command.c_str());

			if(target) zxmgr::Kick(target, false);
            goto ex;
        }
        else if(rawcmd == "#kickme")
        {
            if(!player || console)
            {
                Printf("This command may not be used from the console.");
                goto ex;
            }

            if(player) zxmgr::Kick(player, true);
            goto ex;
        }
		else if(rawcmd == "#kickall")
		{
			zxmgr::KickAll(NULL);
			goto ex;
		}
        else if(rawcmd == "#kick_silent")
        {
            command.erase(0, 12);
            command = TrimLeft(command);
            byte* target = zxmgr::FindByNickname(command.c_str());

            if(target) zxmgr::Kick(target, true);
            goto ex;
        }
        else if(rawcmd == "#disconnect")
        {
            command.erase(0, 11);
            command = TrimLeft(command);
            byte* target = zxmgr::FindByNickname(command.c_str());

            if(target) zxmgr::Disconnect(target);
            goto ex;
        }
    }

    if(rights & GMF_CMD_INFO)
    {
        if(rawcmd == "#locate")
        {
            command.erase(0, 7);
            command = TrimLeft(command);
			byte* target = zxmgr::FindByNickname(command.c_str());

            if(target && *(byte**)(target + 0x38))
            {
                uint32_t p_x = *(uint8_t*)(*(uint32_t*)(*(byte**)(target + 0x38) + 0x10));
                uint32_t p_y = *(uint8_t*)(*(uint32_t*)(*(byte**)(target + 0x38) + 0x10) + 1);

                if(!player || console)
                    Printf("%s (%u:%u)", *(const char**)(target + 0x18), p_x, p_y);
                else if(player)
                    zxmgr::SendMessage(player, "%s (%u:%u)", *(const char**)(target + 0x18), p_x, p_y);
            }
            goto ex;
        }
        else if(rawcmd == "#info")
        {
            command.erase(0, 5);
            command = TrimLeft(command);
            byte* target = zxmgr::FindByNickname(command.c_str());

            if(!target) goto ex;
            if(!*(byte**)(target + 0x38)) goto ex;

            const char* p_charname = *(const char**)(target + 0x18);
            const char* p_logname = *(const char**)(target + 0x0A78);
            byte* netinf = zxmgr::GetNetworkStruct(target);
            bool p_connected = (netinf);
            const char* p_address = "n/a";
            if(p_connected) p_address = (const char*)(netinf + 8);

            std::string p_state;
            if(p_connected) p_state = Format("connected (%s)", p_address);
            else p_state = "disconnected";

            byte* unit = *(byte**)(target + 0x38);

            uint8_t p_body      = *(uint8_t*)(unit + 0x84);
            uint8_t p_reaction  = *(uint8_t*)(unit + 0x86);
            uint8_t p_mind      = *(uint8_t*)(unit + 0x88);
            uint8_t p_spirit    = *(uint8_t*)(unit + 0x8A);

            const char* p_strong = (vd2_CheckStrong(unit) ? "yes" : "no");

            if(!player || console)
            {
                Printf("nickname: \"%s\", login: \"%s\", state: %s, stats: [%u,%u,%u,%u], strong: %s",
                       p_charname, p_logname, p_state.c_str(),
                       p_body, p_reaction, p_mind, p_spirit, p_strong);
            }
            else if(player)
            {
                zxmgr::SendMessage(player, "nickname: \"%s\", login: \"%s\", state: %s, stats: [%u,%u,%u,%u], strong: %s\n",
                                    p_charname, p_logname, p_state.c_str(),
                                    p_body, p_reaction, p_mind, p_spirit, p_strong);
            }

            goto ex;
        }
		else if(rawcmd == "#scan")
		{
			if(!player) goto ex;
			byte* unit = *(byte**)(player + 0x38);
			if(!unit) goto ex;

			SR_DumpToFile(player);
			goto ex;
		}
    }

    if(rights & GMF_CMD_KILL)
    {
        if(rawcmd == "#kill")
        {
            command.erase(0, 5);
            command = TrimLeft(command);
            byte* target = zxmgr::FindByNickname(command.c_str());

            if(target)
            {
                uint32_t tri = 0;
                if(!*(uint32_t*)(target + 0x2C))
                    tri = *(uint32_t*)(target + 0x14);

                if(CHECK_FLAG(tri, GMF_ANY))
                {
                    if(((tri & GMF_GODMODE) &&
                        (rights & GMF_GODMODE_ADMIN)) ||
                        (tri & GMF_GODMODE_ADMIN)) goto ex;
                }

				zxmgr::Kill(target, player);
            }
            goto ex;
        }
		else if(rawcmd == "#murder")
		{
			command.erase(0, 7);
			command = TrimLeft(command);
            byte* target = zxmgr::FindByNickname(command.c_str());

            if(target)
            {
                uint32_t tri = 0;
                if(!*(uint32_t*)(target + 0x2C))
                    tri = *(uint32_t*)(target + 0x14);

                if(CHECK_FLAG(tri, GMF_ANY))
                {
                    if((((tri & GMF_GODMODE) &&
                       !(rights & GMF_GODMODE_ADMIN)) ||
                        (tri & GMF_GODMODE_ADMIN)) && target != player) goto ex;
                }

				zxmgr::Kill(target, player);
				byte* unit = *(byte**)(target + 0x38);
				if(unit && target != player)
					DropEverything(unit, true);
			}
			goto ex;
		}
        else if(rawcmd == "#killall")
        {
            zxmgr::KillAll(player, false);
        }
        else if(rawcmd == "#killai")
        {
            zxmgr::KillAll(player, true);
        }
    }

    if(rights & GMF_CMD_PICKUP)
    {
        if(rawcmd == "#pickup")
        {
            if(!player || console)
            {
                Printf("This command may not be used from the console.");
                goto ex;
            }

            if(player)
            {
                cheat_codes_2(player, ccommand);
            }
            goto ex;
        }
    }

    if(rights & GMF_CMD_SUMMON)
    {
        if(rawcmd == "#summon")
        {
            if(!player || console)
            {
                Printf("This command may not be used from the console.");
                goto ex;
            }

            if(player && *(byte**)(player + 0x38))
            {
                command.erase(0, 7);
                command = Trim(command);
				if(!command.length()) goto ex;

                uint32_t count = 1;
                size_t fsp = command.find_first_of(" ");
                if(fsp != std::string::npos)
                {
                    std::string intstr = command;
                    intstr.erase(fsp);
                    if(CheckInt(intstr))
                    {
                        command.erase(0, fsp + 1);
                        command = TrimLeft(command);
                        count = StrToInt(intstr);
                        if(!count) count = 1;
                    }
                }

				if(!command.length()) goto ex;
                for(uint32_t i = 0; i < count; i++)
                {
					byte* unit = zxmgr::Summon(player, command.c_str(), *(byte**)(0x00642C2C), false, NULL);
                    //byte* unit = Map::CreateUnitForEx(player, command.c_str(), false);
                    //zxmgr::SendMessage(NULL, "what: %02X\n", *(uint8_t*)(*(byte**)(unit + 0x1C4) + 0x78));
                    //Unit::SetSpells(unit);
                }
            }
        }
    }

    if(rights & GMF_CMD_SET)
    {
        if(rawcmd == "#nextmap")
        {
            zxmgr::NextMap();
            goto ex;
        }
        else if(rawcmd == "#prevmap")
        {
            zxmgr::PrevMap();
            goto ex;
        }
        else if(rawcmd == "#resetmap")
        {
            if(Config::Suspended)
            {
                zxmgr::SetTotalMapTime(Config::OriginalTime);
                Config::Suspended = false;
            }
            zxmgr::ResetMap();
            goto ex;
        }
        else if(rawcmd == "#shutdown")
        {
            TerminateProcess(GetCurrentProcess(), 100);
            goto ex;
        }
        else if(rawcmd == "#suspend")
        {
            if(!Config::Suspended)
            {
                Config::OriginalTime = zxmgr::GetTotalMapTime();
                zxmgr::SetTotalMapTime(0x7FFFFFFF);

                if(!player || console) Printf("Map timer suspended.");
                else if(player) zxmgr::SendMessage(player, "suspend: map timer suspended.");
            }
            else
            {
                bool change_map = false;
                uint32_t cur_time = zxmgr::GetCurrentMapTime() / 60000;
                if(cur_time >= Config::OriginalTime) change_map = true;

                zxmgr::SetTotalMapTime(Config::OriginalTime);
                Config::OriginalTime = 0;

                if(!player || console) Printf("Map timer released.");
                else if(player) zxmgr::SendMessage(player, "suspend: map timer released.");

                if(change_map)
                {
                    Printf("Note: map timer beyond total map time. Changing map...");
                    zxmgr::NextMap();
                }
            }

            Config::Suspended = !Config::Suspended;
            goto ex;
        }
        else if(rawcmd == "#set" && (command.find("#set mode") == 0))
        {
            command.erase(0, 9);
            command = Trim(command);

            if(!command.length())
            {
                if(!player || console) Printf("Mode is set to %08X.", Config::ServerFlags);
                else if(player) zxmgr::SendMessage(player, "mode is set to %08X", Config::ServerFlags);
            }
            else
            {
                int32_t add_flags = 0;
                if(command[0] == '+') add_flags = 1;
                else if(command[0] == '-') add_flags = -1;
                else if(command[0] == '=') add_flags = 0;
                else goto ex;

                if(add_flags != 0) command.erase(0, 1);
                if(command[0] != '=') goto ex;
                command.erase(0, 1);

                uint32_t old_mode = Config::ServerFlags;

                uint32_t flags = ParseFlags(TrimLeft(command));
                if(add_flags == -1) Config::ServerFlags &= ~flags;
                else if(add_flags == 1) Config::ServerFlags |= flags;
                else Config::ServerFlags = flags;

                if(old_mode != Config::ServerFlags)
                {
                    if(!player || console) Printf("Mode is set to %08X (was: %08X).", Config::ServerFlags, old_mode);
                    else if(player) zxmgr::SendMessage(player, "mode is set to %08X (was: %08X)", Config::ServerFlags, old_mode);

					if(Config::ServerFlags & SVF_SOFTCORE)
					{
						MAX_SKILL = 110;
						Config::ServerCaps |= SVC_SOFTCORE;
					}
					else
					{
						MAX_SKILL = 100;
						Config::ServerCaps &= ~SVC_SOFTCORE;
					}
                }
                else
                {
                    if(!player || console) Printf("Mode is set to %08X.", Config::ServerFlags);
                    else if(player) zxmgr::SendMessage(player, "mode is set to %08X", Config::ServerFlags);
                }
            }

            goto ex;
        }
        else if(command.find("#speed") == 0)
        {
            command.erase(0, 6);
            command = Trim(command);
            if(!CheckInt(command)) goto ex;
            uint32_t speed = StrToInt(command);
            if(!speed) speed = 1;
            if(speed > 8) speed = 8;

			zxmgr::SetSpeed(speed);
            goto ex;
        }
		else if(rawcmd == "#mapwide")
		{
			if(!player || console)
			{
				Printf("This command may not be used from the console.");
				goto ex;
			}

			uint32_t what = 7; // blizzard
			
			command.erase(0, 8);
			command = Trim(command);
			if(CheckInt(command) && command.length()) what = StrToInt(command);

			byte* unit = *(byte**)(player + 0x38);
			if(!unit) goto ex;

			uint8_t p_x = *(uint8_t*)(*(byte**)(unit + 0x10));
            uint8_t p_y = *(uint8_t*)(*(byte**)(unit + 0x10) + 1);

            uint32_t p_mapwidth = *(uint32_t*)(*(uint32_t*)(0x006B16A8) + 0x50000);
            uint32_t p_mapheight = *(uint32_t*)(*(uint32_t*)(0x006B16A8) + 0x50004);

			uint32_t step_x = 1;
			uint32_t step_y = 1;

			switch(what)
			{
			case 7: // blizzard
				step_x = 1;
				step_y = 1;
				break;
			case 14: // darkness
			case 15: // light
			case 6: // poison cloud
				step_x = 1;
				step_y = 1;
				break;
			case 9: // acid steam
				step_x = 1;
				step_y = 1;
				break;
			case 2: // fire ball
				step_x = 1;
				step_y = 1;
				break;
			case 3: // fire wall
				step_x = 1;
				step_y = 1;
				break;
			default: // any other spell is forbidden
				goto ex;			
			}

			uint32_t count_x = 51;
			uint32_t count_y = 51;

			int32_t start_x = p_x - 25;
			int32_t start_y = p_y - 25;

			for(int32_t i = start_x; i <= start_x+count_x; i++)
			{
				for(int32_t j = start_y; j <= start_y+count_y; j++)
				{
					if(i < 8 || i > p_mapwidth-8 ||
						j < 8 || j > p_mapheight-8) continue;
					zxmgr::CastPointEffect(unit, i, j, what);
				}
			}
 
			goto ex;
		}
		else if(rawcmd == "#inn")
		{
			if(!player) goto ex;
			byte* unit = *(byte**)(player + 0x38);
			if(!unit) goto ex;
			byte* item = *(byte**)(unit + 0x74);
			if(!item) goto ex;
			zxmgr::SendMessage(NULL, "%04x", *(uint16_t*)(item+0x40));
			goto ex;
		}
		else if(rawcmd == "#uh")
		{
			if(!player) goto ex;
			SOCKET ps = zxmgr::GetSocket(player);

			Packet testp;
			testp.WriteUInt32(0xBADFACE1);
			SOCK_SendPacket(ps, testp, 0, true);
			goto ex;
		}
    }

    if(rights & GMF_CMD_CREATE)
    {
        if(rawcmd == "#create")
        {
            if(!player || console)
            {
                Printf("This command may not be used from the console.");
                goto ex;
            }

            if(!*(byte**)(player + 0x38)) goto ex;

            command.erase(0, 7);
            command = Trim(command);

            uint32_t count = 1;
            size_t fsp = command.find_first_of(" ");
            if(fsp != std::string::npos)
            {
                std::string intstr = command;
                intstr.erase(fsp);
                if(CheckInt(intstr))
                {
                    command.erase(0, fsp + 1);
                    command = TrimLeft(command);
                    count = StrToInt(intstr);
                    if(!count) count = 1;
                }
            }

            if(ToLower(command) == "gold")
            {
                zxmgr::GiveMoney(player, count, 1);
            }
            else
            {
                if(command.find("{") != std::string::npos)
                {
                    for(uint32_t i = 0; i < count; i++)
					{
						byte* t_item = zxmgr::ConstructItem(command);
						if(!t_item) goto ex;
						// special case for scrolls/potions
						if(*(uint8_t*)(t_item + 0x58) == 0 && *(uint8_t*)(t_item + 0x45) == 0 && *(uint8_t*)(t_item + 0x46) == 0 && *(uint16_t*)(t_item + 0x4A) == 1)
						{
							*(uint16_t*)(t_item + 0x42) = count;
							zxmgr::GiveItemTo(t_item, player);
							break;
						}

						*(uint16_t*)(t_item + 0x42) = 1;
	                    zxmgr::GiveItemTo(t_item, player);
					}
                }
                else
                {
					byte* t_item = zxmgr::ConstructItem(command);
					if(!t_item) goto ex;
                    *(uint16_t*)(t_item + 0x42) = count;
                    zxmgr::GiveItemTo(t_item, player);
                }
            }

            zxmgr::UpdateUnit(*(byte**)(player + 0x38), player, 0xFFFFFFFF, 0xFFB, 0, 0);
            goto ex;
        }
    }

	// #modify player +god:
	//  включает годмод. годмод сбрасывается при выходе игрока с карты ИЛИ при выходе установившего ГМа с карты.
	// #modify player ++god: годмод НЕ сбрасывается при выходе ГМа с карты.
	// #modify player -god (--god): отменяет команды выше. количество минусов в данном случае значения не имеет.
	// #modify player +spells: временно добавляет все заклинания. при выходе игрока или установившего ГМа с карты заклинания
    //  сбрасываются обратно на старую книгу. также можно сбросить заклинания через #modify player -spells.
	// #modify player -spells: если книга заклинаний игрока не менялась, временно удаляет все заклинания.
	//  при выходе игрока или ГМа с карты заклинания возвращаются в норму. эффект отменяется через #modify player +spells.
	// #modify player ++spells: то же самое, но навсегда. сбросить заклинания обратно невозможно.
	// #modify player --spells: см. выше про -spells.

	if(rights & GMF_CMD_MODIFY)
	{
		if(rawcmd == "#modify")
		{
			command.erase(0, 7);
			command = Trim(command);

			byte* target = NULL;
			std::string targetname = "";
			for(size_t i = 0; i < command.length(); i++)
			{
				targetname += command[i];
				if(targetname == "self") continue;
				target = zxmgr::FindByNickname(targetname.c_str());
				if(target) break;
			}
			
			if(!target)
			{
				std::string lowercommand = ToLower(command);
				if(lowercommand.find("self") == 0)
				{
					targetname = "self";
					target = player;
				}
				else goto ex;
			}

			Player* pi = PI_Get(target);
			if(!pi) goto ex;

			command.erase(0, targetname.length());
			command = TrimLeft(command);
			if(!command.length()) goto ex;

			int r_change = 0;
			if(command[0] == '+') r_change = 1;
			else if(command[0] == '-') r_change = -1;
			if(!r_change) goto ex;

			command.erase(0, 1);
			if(!command.length()) goto ex;
			if(command[0] == '+') r_change = 2;
			else if(command[0] == '-') r_change = -2;
			
			if(r_change == 2 || r_change == -2)
				command.erase(0, 1);

			command = ToLower(TrimLeft(command));

			byte* unit = *(byte**)(target + 0x38);
			
			if(command == "god")
			{
				if(r_change > 0)
				{
					pi->GodMode = true;
					if(r_change == 1) pi->GodSetter = player;
					else pi->GodSetter = NULL;
				}
				else if(r_change < 0)
				{
					pi->GodMode = false;
					pi->GodSetter = NULL;
				}
			}
			else if(command == "spells" && unit)
			{
				if(r_change > 0)
				{
					if(pi->SetSpells == -1 && r_change != 2) // prev. command removed spells
					{
						pi->SetSpells = 0;
						zxmgr::SetSpells(unit, pi->LastSpells);
						pi->LastSpells = 0;
					}
					else
					{
						if(r_change == 1)
						{
							pi->SetSpells = 1;
							pi->SpellSetter = player;
						}
						else
						{
							pi->SetSpells = 0;
							pi->SpellSetter = NULL;
						}

						pi->LastSpells = zxmgr::GetSpells(unit);
						zxmgr::SetSpells(unit, 0xFFFFFFFF);
					}
				}
				else if(r_change < 0)
				{
					if(pi->SetSpells == 1 && r_change != -2) // prev. command added spells
					{
						pi->SetSpells = 0;
						zxmgr::SetSpells(unit, pi->LastSpells);
						pi->LastSpells = 0;
					}
					else
					{
						if(r_change == -1)
						{
							pi->SetSpells = 1;
							pi->SpellSetter = player;
						}
						else
						{
							pi->SetSpells = 0;
							pi->SpellSetter = NULL;
						}

						pi->SetSpells = -1;
						pi->LastSpells = zxmgr::GetSpells(unit);
						zxmgr::SetSpells(unit, 0);
					}
				}

				zxmgr::UpdateUnit(unit, 0, 0xFFFFFFFF, 0xFFB, 0, 0);
			}
			else if(command == "knowledge" && unit)
			{
				if(r_change > 0)
				{

				}
				else if(r_change < 0)
				{

				}
			}
		}
	}

ex:
    return;
}