示例#1
0
void LoadPatchSection(const char *section, std::vector<Patch> &patches, IniFile &ini)
{
	std::vector<std::string> lines;

	if (!ini.GetLines(section, lines))
		return;

	Patch currentPatch;

	for (std::vector<std::string>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
	{
		std::string line = *iter;

		if (line.size())
		{
			if (line[0] == '+' || line[0] == '$')
			{
				// Take care of the previous code
				if (currentPatch.name.size())
					patches.push_back(currentPatch);
				currentPatch.entries.clear();

				// Set active and name
				currentPatch.active = (line[0] == '+') ? true : false;
				if (currentPatch.active)
					currentPatch.name = line.substr(2, line.size() - 2);
				else
					currentPatch.name = line.substr(1, line.size() - 1);
				continue;
			}

			std::string::size_type loc = line.find_first_of('=', 0);

			if (loc != std::string::npos)
				line[loc] = ':';

			std::vector<std::string> items;
			SplitString(line, ':', items);

			if (items.size() >= 3)
			{
				PatchEntry pE;
				bool success = true;
				success &= TryParse(items[0], &pE.address);
				success &= TryParse(items[2], &pE.value);

				pE.type = PatchType(std::find(PatchTypeStrings, PatchTypeStrings + 3, items[1]) - PatchTypeStrings);
				success &= (pE.type != (PatchType)3);
				if (success)
					currentPatch.entries.push_back(pE);
			}
		}
	}

	if (currentPatch.name.size() && currentPatch.entries.size())
		patches.push_back(currentPatch);
}
示例#2
0
void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, IniFile& globalIni,
                      IniFile& localIni)
{
  // Load the name of all enabled patches
  std::string enabledSectionName = section + "_Enabled";
  std::vector<std::string> enabledLines;
  std::set<std::string> enabledNames;
  localIni.GetLines(enabledSectionName, &enabledLines);
  for (const std::string& line : enabledLines)
  {
    if (line.size() != 0 && line[0] == '$')
    {
      std::string name = line.substr(1, line.size() - 1);
      enabledNames.insert(name);
    }
  }

  const IniFile* inis[2] = {&globalIni, &localIni};

  for (const IniFile* ini : inis)
  {
    std::vector<std::string> lines;
    Patch currentPatch;
    ini->GetLines(section, &lines);

    for (std::string& line : lines)
    {
      if (line.size() == 0)
        continue;

      if (line[0] == '$')
      {
        // Take care of the previous code
        if (currentPatch.name.size())
        {
          patches.push_back(currentPatch);
        }
        currentPatch.entries.clear();

        // Set active and name
        currentPatch.name = line.substr(1, line.size() - 1);
        currentPatch.active = enabledNames.find(currentPatch.name) != enabledNames.end();
        currentPatch.user_defined = (ini == &localIni);
      }
      else
      {
        std::string::size_type loc = line.find('=');

        if (loc != std::string::npos)
        {
          line[loc] = ':';
        }

        const std::vector<std::string> items = SplitString(line, ':');

        if (items.size() >= 3)
        {
          PatchEntry pE;
          bool success = true;
          success &= TryParse(items[0], &pE.address);
          success &= TryParse(items[2], &pE.value);

          const auto iter =
              std::find(s_patch_type_strings.begin(), s_patch_type_strings.end(), items[1]);
          pE.type = PatchType(std::distance(s_patch_type_strings.begin(), iter));

          success &= (pE.type != (PatchType)3);
          if (success)
          {
            currentPatch.entries.push_back(pE);
          }
        }
      }
    }

    if (currentPatch.name.size() && currentPatch.entries.size())
    {
      patches.push_back(currentPatch);
    }
  }
}
示例#3
0
void LoadPatchSection(const char *section, std::vector<Patch> &patches,
                      IniFile &globalIni, IniFile &localIni)
{
	// Load the name of all enabled patches
	std::string enabledSectionName = std::string(section) + "_Enabled";
	std::vector<std::string> enabledLines;
	std::set<std::string> enabledNames;
	localIni.GetLines(enabledSectionName.c_str(), enabledLines);
	for (auto iter = enabledLines.begin(); iter != enabledLines.end(); ++iter)
	{
		const std::string& line = *iter;
		if (line.size() != 0 && line[0] == '$')
		{
			std::string name = line.substr(1, line.size() - 1);
			enabledNames.insert(name);
		}
	}

	IniFile* inis[] = {&globalIni, &localIni};

	for (size_t i = 0; i < ArraySize(inis); ++i)
	{
		std::vector<std::string> lines;
		Patch currentPatch;
		inis[i]->GetLines(section, lines);

		for (auto iter = lines.begin(); iter != lines.end(); ++iter)
		{
			std::string line = *iter;

			if (line.size() == 0)
				continue;

			if (line[0] == '$')
			{
				// Take care of the previous code
				if (currentPatch.name.size())
					patches.push_back(currentPatch);
				currentPatch.entries.clear();

				// Set active and name
				currentPatch.name = line.substr(1, line.size() - 1);
				currentPatch.active = enabledNames.find(currentPatch.name) != enabledNames.end();
				currentPatch.user_defined = (i == 1);
			}
			else
			{
				std::string::size_type loc = line.find_first_of('=', 0);

				if (loc != std::string::npos)
					line[loc] = ':';

				std::vector<std::string> items;
				SplitString(line, ':', items);

				if (items.size() >= 3)
				{
					PatchEntry pE;
					bool success = true;
					success &= TryParse(items[0], &pE.address);
					success &= TryParse(items[2], &pE.value);

					pE.type = PatchType(std::find(PatchTypeStrings, PatchTypeStrings + 3, items[1]) - PatchTypeStrings);
					success &= (pE.type != (PatchType)3);
					if (success)
						currentPatch.entries.push_back(pE);
				}
			}
		}

		if (currentPatch.name.size() && currentPatch.entries.size())
			patches.push_back(currentPatch);
	}
}
示例#4
0
文件: anim.cpp 项目: somaen/twin-e
int SetInterAnimObjet(int animState, char *animData, char *body, animTimerData *animTimerDataPtr) {
	short int animOpcode;

	short int var0;

	char *edi;
	char *ebx;
	int ebp;
	int eax;
	int keyFrameLength;
	int numOfPointInBody;
	int numOfPointInAnim;
	char *keyFramePtrOld;

	numOfPointInAnim = READ_LE_U16(animData + 2);

	keyFramePtr = ((numOfPointInAnim * 8 + 8) * animState) + animData + 8;

	keyFrameLength = READ_LE_U16(keyFramePtr);

	var0 = READ_LE_U16(body);

	if (!(var0 & 2)) {
		return (0);
	}

	edi = body + 16;

	ebx = animTimerDataPtr->ptr;
	ebp = animTimerDataPtr->_time;

	if (!ebx) {
		ebx = keyFramePtr;
		ebp = keyFrameLength;
	} else {
		assert_ptr(ebx);
	}

	lastKeyFramePtr = ebx;

	eax = READ_LE_S16(edi - 2);
	edi += eax;

	eax = READ_LE_S16(edi);
	eax = eax + eax * 2;
	edi = edi + eax * 2 + 12;

	numOfPointInBody = READ_LE_S16(edi - 10);

	if (numOfPointInAnim > numOfPointInBody) {
		numOfPointInAnim = numOfPointInBody;
	}

	eax = lba_time - ebp;

	if (eax >= keyFrameLength) {
		int *destPtr; // keyFrame
		int *sourcePtr;

		sourcePtr = (int *)(keyFramePtr + 8);
		destPtr = (int *) edi;

		do {
			WRITE_LE_U32(destPtr++, READ_LE_U32(sourcePtr++));
			WRITE_LE_U32(destPtr++, READ_LE_U32(sourcePtr++));

			destPtr = (int *)(((char *) destPtr) + 30);
		} while (--numOfPointInAnim);

		animTimerDataPtr->ptr = keyFramePtr;
		animTimerDataPtr->_time = lba_time;

		currentX = READ_LE_S16(keyFramePtr + 2);
		currentZ = READ_LE_S16(keyFramePtr + 4);
		currentY = READ_LE_S16(keyFramePtr + 6);

		processActorVar5 = READ_LE_S16(keyFramePtr + 8);
		processActorSub2Var0 = READ_LE_S16(keyFramePtr + 10);
		processActorVar6 = READ_LE_S16(keyFramePtr + 12);
		processActorSub2Var1 = READ_LE_S16(keyFramePtr + 14);

		return (1);
	} else {
		keyFramePtrOld = keyFramePtr;

		lastKeyFramePtr += 8;
		keyFramePtr += 8;

		processActorVar5 = READ_LE_S16(keyFramePtr);
		processActorSub2Var0 = (READ_LE_S16(keyFramePtr + 2) * eax) / keyFrameLength;
		processActorVar6 = (READ_LE_S16(keyFramePtr + 4) * eax) / keyFrameLength;
		processActorSub2Var1 = (READ_LE_S16(keyFramePtr + 6) * eax) / keyFrameLength;

		lastKeyFramePtr += 8;
		keyFramePtr += 8;

		edi += 38;

		if (--numOfPointInAnim) {
			animVar4 = numOfPointInAnim;

			do {
				animOpcode = PatchType(&edi);

				switch (animOpcode) {
				case 0: {   // allow global rotate
					PatchInterAngle(&edi, eax, keyFrameLength);
					PatchInterAngle(&edi, eax, keyFrameLength);
					PatchInterAngle(&edi, eax, keyFrameLength);
					break;
				}
				case 1: {   // dissallow global rotate
					PatchInterStep(&edi, eax, keyFrameLength);
					PatchInterStep(&edi, eax, keyFrameLength);
					PatchInterStep(&edi, eax, keyFrameLength);
					break;
				}
				case 2: {   // dissallow global rotate + hide
					PatchInterStep(&edi, eax, keyFrameLength);
					PatchInterStep(&edi, eax, keyFrameLength);
					PatchInterStep(&edi, eax, keyFrameLength);
					break;
				}
				default: {
					printf("Unsupported rotaton mode %d in SetInterAnimObjet!\n", animOpcode);
					exit(1);
				}
				}

				edi += 30;
			} while (--animVar4);
		}

		currentX = (READ_LE_S16(keyFramePtrOld + 2) * eax) / keyFrameLength;
		currentZ = (READ_LE_S16(keyFramePtrOld + 4) * eax) / keyFrameLength;
		currentY = (READ_LE_S16(keyFramePtrOld + 6) * eax) / keyFrameLength;
	}

	return (0);
}