示例#1
0
文件: SnM_Chunk.cpp 项目: Jeff0S/sws
// Overrides SNM_ChunkParserPatcher::Commit() in order to remove the fake "TAKE" line, see
// GetChunk() comments. Also see important comments for SNM_ChunkParserPatcher::Commit()
bool SNM_TakeParserPatcher::Commit(bool _force)
{
	if (m_reaObject && (m_updates || _force) && m_chunk->GetLength() && !(GetPlayStateEx(NULL) & 4))
	{
// SNM_ChunkParserPatcher::Commit() mod ----->
		if (m_fakeTake)
		{
			m_fakeTake = false;
			const char* p = strstr(m_chunk->Get(), "\nNAME ");
			// empty item (i.e. no take at all) or NULL takes only
			if (!p) 
			{
				p = strstr(m_chunk->Get(), "\nTAKE");
				if (p)
				{
					const char* p2 = p+5;
					while (*p2 && p2 < (m_chunk->Get()+m_chunk->GetLength()) && *p2 != '\n') p2++;
					if (*p2 == '\n')
						m_chunk->DeleteSub((int)(p-m_chunk->Get()), (int)(p2-p));
				}
			}
			// "normal" item
			else
			{
				char* p2 = (char*)(p-1);
				while (*p2 && p2 > m_chunk->Get() && *p2 != '\n') p2--;
				if (*p2 == '\n' && !strncmp(p2, "\nTAKE", 5))
				{
					m_chunk->DeleteSub((int)(p2-m_chunk->Get()), (int)(p-p2));
					p -= (int)(p-p2);
				}

				// if there's a "TAKE" before "NAME" it must not be "TAKE NULL"
				p--; // we assume it's safe (serious other issues otherwise)
				while (*p && p > m_chunk->Get() && *p != '\n') p--;
				if (!strncmp(p, "\nTAKE NULL", 10))
					m_chunk->DeleteSub((int)(p+5-m_chunk->Get()), 5); // removes " NULL"
			}
		}
// SNM_ChunkParserPatcher::Commit() mod <-----

		if (!SNM_GetSetObjectState(m_reaObject, m_chunk)) {
			SetChunk("", 0);
			return true;
		}
	}
	return false;
}
示例#2
0
void InsertMarker(COMMAND_T* _ct)
{
	AddProjectMarker2(NULL, false, (int)_ct->user && (GetPlayStateEx(NULL)&1) ? GetPlayPositionEx(NULL) : GetCursorPositionEx(NULL), 0.0, "", -1, 0);
	UpdateTimeline();
	Undo_OnStateChangeEx2(NULL, SWS_CMD_SHORTNAME(_ct), UNDO_STATE_MISCCFG, -1);
}