<commit_before>/*
 *  caosVM_camera.cpp
 *  openc2e
 *
 *  Created by <NAME> on Tue May 25 2004.
 *  Copyright (c) 2004 <NAME>. All rights reserved.
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 */

#include "caosVM.h"
#include "World.h"

/**
 META (command) metaroom_id (integer) camera_x (integer) camera_y (integer) transition (integer)
 
 set metaroom current camera is pointing at. coordinates point to top left of new
 camera position.
 
 transition: 0 for none, 1 for flip horz, 2 for burst
 */
void caosVM::c_META() {
	VM_VERIFY_SIZE(4)
	VM_PARAM_INTEGER(transition)
	VM_PARAM_INTEGER(camera_y)
	VM_PARAM_INTEGER(camera_x)
	VM_PARAM_INTEGER(metaroom_id)

	assert(metaroom_id >= 0);
	// TODO assert((unsigned int)metaroom_id < world.map.getMetaRoomCount());
	world.camera.goToMetaRoom(metaroom_id, camera_x, camera_y, (cameratransition)transition);
}

/**
 CMRT (command) pan (integer)

 centre current camera on TARG.

 pan: 0 for none (jump), 1 for smooth scroll if in same metaroom, 2 for smooth scroll if visible
 */
void caosVM::c_CMRT() {
	VM_VERIFY_SIZE(1)
	VM_PARAM_INTEGER(pan)
	// TODO
}

/**
 CMRA (command) x (integer) y (integer) pan (integer)
*/
void caosVM::c_CMRA() {
	VM_VERIFY_SIZE(3)
	VM_PARAM_INTEGER(pan)
	VM_PARAM_INTEGER(y)
	VM_PARAM_INTEGER(x)

	world.camera.moveTo(x, y, (panstyle)pan);
}
<commit_msg>fix META to handle -1 coords<commit_after>/*
 *  caosVM_camera.cpp
 *  openc2e
 *
 *  Created by <NAME> on Tue May 25 2004.
 *  Copyright (c) 2004 <NAME>. All rights reserved.
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 */

#include "caosVM.h"
#include "World.h"

/**
 META (command) metaroom_id (integer) camera_x (integer) camera_y (integer) transition (integer)
 
 set metaroom current camera is pointing at. coordinates point to top left of new
 camera position. set a coordinate to -1 to use the top-left corner of the metaroom.
 
 transition: 0 for none, 1 for flip horz, 2 for burst
 */
void caosVM::c_META() {
	VM_VERIFY_SIZE(4)
	VM_PARAM_INTEGER(transition)
	VM_PARAM_INTEGER(camera_y)
	VM_PARAM_INTEGER(camera_x)
	VM_PARAM_INTEGER(metaroom_id)

	assert(metaroom_id >= 0);
	MetaRoom *m = world.map.getMetaRoom(metaroom_id);
	if (!m) return; // DS does 'meta 0 -1 -1 0' in !map.cos for some stupid reason
	
	int camerax = camera_x; if (camerax == -1) camerax = m->x();
	int cameray = camera_y; if (cameray == -1) cameray = m->y();
	
	world.camera.goToMetaRoom(metaroom_id, camerax, cameray, (cameratransition)transition);
}

/**
 CMRT (command) pan (integer)

 centre current camera on TARG.

 pan: 0 for none (jump), 1 for smooth scroll if in same metaroom, 2 for smooth scroll if visible
 */
void caosVM::c_CMRT() {
	VM_VERIFY_SIZE(1)
	VM_PARAM_INTEGER(pan)
	// TODO
}

/**
 CMRA (command) x (integer) y (integer) pan (integer)
*/
void caosVM::c_CMRA() {
	VM_VERIFY_SIZE(3)
	VM_PARAM_INTEGER(pan)
	VM_PARAM_INTEGER(y)
	VM_PARAM_INTEGER(x)

	world.camera.moveTo(x, y, (panstyle)pan);
}

{'fraction_non_alphanumeric': 0.1008209338122114, 'fraction_numerical': 0.013340174448435094, 'mean_word_length': 4.184840425531915, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2309397', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1339, 'n_words': 463}