示例#1
0
static void
LoadGroupQueue (DECODE_REF fh, QUEUE *pQueue)
{
	COUNT num_links;

	cread_16 (fh, &num_links);

	while (num_links--)
	{
		HIPGROUP hGroup;
		IP_GROUP *GroupPtr;
		BYTE tmpb;

		cread_16 (fh, NULL); /* unused; was race_id */

		hGroup = BuildGroup (pQueue, 0);
		GroupPtr = LockIpGroup (pQueue, hGroup);

		cread_16 (fh, NULL); /* unused; was which_side */
		cread_8  (fh, NULL); /* unused; was captains_name_index */
		cread_8  (fh, NULL); /* padding; for savegame compat */
		cread_16 (fh, &GroupPtr->group_counter);
		cread_8  (fh, &GroupPtr->race_id);
		cread_8  (fh, &tmpb); /* was var2 */
		GroupPtr->sys_loc = LONIBBLE (tmpb);
		GroupPtr->task = HINIBBLE (tmpb);
		cread_8  (fh, &GroupPtr->in_system); /* was crew_level */
		cread_8  (fh, NULL); /* unused; was max_crew */
		cread_8  (fh, &tmpb); /* was energy_level */
		GroupPtr->dest_loc = LONIBBLE (tmpb);
		GroupPtr->orbit_pos = HINIBBLE (tmpb);
		cread_8  (fh, &GroupPtr->group_id); /* was max_energy */
		cread_16s(fh, &GroupPtr->loc.x);
		cread_16s(fh, &GroupPtr->loc.y);

		UnlockIpGroup (pQueue, hGroup);
	}
}
示例#2
0
static void
bubble_preprocess (ELEMENT *ElementPtr)
{
	BYTE thrust_wait, turn_wait;

	thrust_wait = HINIBBLE (ElementPtr->turn_wait);
	turn_wait = LONIBBLE (ElementPtr->turn_wait);
	if (thrust_wait > 0)
		--thrust_wait;
	else
	{
		ElementPtr->next.image.frame =
				IncFrameIndex (ElementPtr->current.image.frame);
		ElementPtr->state_flags |= CHANGING;

		thrust_wait = (BYTE)((COUNT)TFB_Random () & 3);
	}

	if (turn_wait > 0)
		--turn_wait;
	else
	{
		COUNT facing;
		SIZE delta_facing;

		facing = NORMALIZE_FACING (ANGLE_TO_FACING (
				GetVelocityTravelAngle (&ElementPtr->velocity)));
		if ((delta_facing = TrackShip (ElementPtr, &facing)) == -1)
			facing = (COUNT)TFB_Random ();
		else if (delta_facing <= ANGLE_TO_FACING (HALF_CIRCLE))
			facing += (COUNT)TFB_Random () & (ANGLE_TO_FACING (HALF_CIRCLE) - 1);
		else
			facing -= (COUNT)TFB_Random () & (ANGLE_TO_FACING (HALF_CIRCLE) - 1);
		SetVelocityVector (&ElementPtr->velocity,
				MISSILE_SPEED, facing);

#define TRACK_WAIT 2
		turn_wait = TRACK_WAIT;
	}

	ElementPtr->turn_wait = MAKE_BYTE (turn_wait, thrust_wait);
}
示例#3
0
GString *
eo_massage_str(const gchar *in_str, gsize maxlen, int dupn)
{
    gchar *tmp_ptr;
    /* The characters in "reject" come from:
     * http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx.
     * Add to the list as necessary for other OS's.
     */
    const gchar *reject = "<>:\"/\\|?*"
        "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a"
    "\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14"
    "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f";
    GString *out_str;
    GString *ext_str;

    out_str = g_string_new("");

    /* Find all disallowed characters/bytes and replace them with %xx */
    while ( (tmp_ptr = strpbrk(in_str, reject)) != NULL ) {
        out_str = g_string_append_len(out_str, in_str, tmp_ptr - in_str);
        out_str = g_string_append_c(out_str, '%');
        out_str = g_string_append_c(out_str, HEXTOASCII(HINIBBLE(*tmp_ptr)));
        out_str = g_string_append_c(out_str, HEXTOASCII(LONIBBLE(*tmp_ptr)));
        in_str = tmp_ptr + 1;
    }
    out_str = g_string_append(out_str, in_str);
    if ( out_str->len > maxlen ) {
        if ( (tmp_ptr = strrchr(out_str->str, '.')) != NULL ) {
            /* Retain the extension */
            ext_str = g_string_new(tmp_ptr);
            out_str = g_string_truncate(out_str, maxlen - ext_str->len);
            out_str = g_string_append(out_str, ext_str->str);
            g_string_free(ext_str, TRUE);
        }
        else
            out_str = g_string_truncate(out_str, maxlen);
    }
    if ( dupn != 0 )
        out_str = eo_rename(out_str, dupn);
    return out_str;
}
示例#4
0
static void
blaster_preprocess (ELEMENT *ElementPtr)
{
    BYTE wait;

    switch (ElementPtr->mass_points)
    {
    case BLASTER_DAMAGE * 1:
        if (GetFrameIndex (ElementPtr->current.image.frame) < 8)
        {
            ElementPtr->next.image.frame =
                IncFrameIndex (ElementPtr->current.image.frame);
            ElementPtr->state_flags |= CHANGING;
        }
        break;
    case BLASTER_DAMAGE * 3:
        if (GetFrameIndex (ElementPtr->current.image.frame) < 19)
            ElementPtr->next.image.frame =
                IncFrameIndex (ElementPtr->current.image.frame);
        else
            ElementPtr->next.image.frame =
                SetAbsFrameIndex (ElementPtr->current.image.frame, 16);
        ElementPtr->state_flags |= CHANGING;
        break;
    }

    if (LONIBBLE (ElementPtr->turn_wait))
        --ElementPtr->turn_wait;
    else if ((wait = HINIBBLE (ElementPtr->turn_wait)))
    {
        COUNT facing;

        facing = NORMALIZE_FACING (ANGLE_TO_FACING (
                                       GetVelocityTravelAngle (&ElementPtr->velocity)));
        if (TrackShip (ElementPtr, &facing) > 0)
            SetVelocityVector (&ElementPtr->velocity, BLASTER_SPEED, facing);

        ElementPtr->turn_wait = MAKE_BYTE (wait, wait);
    }
}
示例#5
0
BYTE RemapISR( BYTE type, ISR_HANDLER_PTR isrFunc )
{
  DWORD dwTmp;
  BYTE bRet;
  BYTE bBuffer[4];

  dwTmp = (DWORD)isrFunc;
  dwTmp >>= 1;
  bBuffer[0] = LOBYTE(dwTmp);
  bBuffer[1] = 0xEF;    // GOTO
  bBuffer[2] = HIBYTE( LOWORD( dwTmp ));
  bBuffer[3] = 0xF0 | LONIBBLE( LOBYTE( HIWORD( dwTmp )));

  dwTmp = (type == LOW_ISR) ? SECOND_LOW_ISR_VECTOR : SECOND_HIGH_ISR_VECTOR;

  bRet = memprg_write( bBuffer, dwTmp, sizeof( bBuffer ));
  if ( bRet != sizeof( bBuffer ) )
  {
    return -1;
  }
  return 0;
}
示例#6
0
文件: uqmdebug.c 项目: intgr/sc2-uqm
COUNT
calculateBioValue (const SOLARSYS_STATE *system, const PLANET_DESC *world)
{
	COUNT result;
	COUNT numBio;
	COUNT i;

	assert (system->pOrbitalDesc == world);
	
	numBio = callGenerateForScanType (system, world, GENERATE_ALL,
			BIOLOGICAL_SCAN, NULL);

	result = 0;
	for (i = 0; i < numBio; i++)
	{
		NODE_INFO info;
		callGenerateForScanType (system, world, i, BIOLOGICAL_SCAN, &info);
		result += BIO_CREDIT_VALUE *
				LONIBBLE (CreatureData[info.type].ValueAndHitPoints);
	}
	return result;
}
示例#7
0
文件: uqmdebug.c 项目: intgr/sc2-uqm
void
dumpPlanetType (FILE *out, int index, const PlanetFrame *planetType)
{
	int i;
	fprintf (out,
			"%s\n"
			"\tType: %s\n"
			"\tColor: %s\n"
			"\tSurface generation algoritm: %s\n"
			"\tTectonics: %s\n"
			"\tAtmosphere: %s\n"
			"\tDensity: %s\n"
			"\tElements:\n",
			planetTypeString (index),
			worldSizeString (PLANSIZE (planetType->Type)),
			bodyColorString (PLANCOLOR (planetType->Type)),
			worldGenAlgoString (PLANALGO (planetType->Type)),
			tectonicsString (planetType->BaseTectonics),
			atmosphereString (HINIBBLE (planetType->AtmoAndDensity)),
			densityString (LONIBBLE (planetType->AtmoAndDensity))
			);
	for (i = 0; i < NUM_USEFUL_ELEMENTS; i++)
	{
		const ELEMENT_ENTRY *entry;
		entry = &planetType->UsefulElements[i];
		if (entry->Density == 0)
			continue;
		fprintf(out, "\t\t0 to %d %s-quality (+%d) deposits of %s (%s)\n",
				DEPOSIT_QUANTITY (entry->Density),
				depositQualityString (DEPOSIT_QUALITY (entry->Density)),
				DEPOSIT_QUALITY (entry->Density) * 5,
				GAME_STRING (ELEMENTS_STRING_BASE + entry->ElementType),
				GAME_STRING (CARGO_STRING_BASE + 2 + ElementCategory (
				entry->ElementType))
			);
	}
	fprintf (out, "\n");
}