Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tic 0.47.0 #340

Merged
merged 4 commits into from
Oct 17, 2017
Merged

Tic 0.47.0 #340

merged 4 commits into from
Oct 17, 2017

Conversation

vamolessa
Copy link

Beside things described in issue299 (link), I've moved the memset(buffer, 0, TIC_CODE_SIZE); to inside the if(contents).

Also, in order to implement the "-watch" option, I decided to do it as one single command "-code-watch".

So in order to invoke TIC injecting external code, one would still use

tic -code code.lua

And if you also want to watch for file modifications on window focus (sdl event)

tic -code-watch code.lua

I found this to be simpler as I didn't have to change this bit of code in console.c

if (argc == 2) cmdLoadCart(console, argv[1]);
else if (argc == 3)
{
	cmdInjectCode(console, argv[1], argv[2]);
	cmdInjectSprites(console, argv[1], argv[2]);
	cmdInjectMap(console, argv[1], argv[2]);
}
else if (argc > 3)
{
	cmdLoadCart(console, argv[1]);

	for (s32 i = 2; i < argc; i += 2)
	{
		cmdInjectCode(console, argv[i], argv[i + 1]);
		cmdInjectSprites(console, argv[i], argv[i + 1]);
		cmdInjectMap(console, argv[i], argv[i + 1]);
	}
}

I belive that once we need to code more complex command line options, we'd be better with some command line arg parsing lib.

Is it cool? :)

src/console.c Outdated
@@ -2317,7 +2317,8 @@ static void tryReloadCode(Console* console, char* codeBuffer)

static void cmdInjectCode(Console* console, const char* param, const char* name)
{
if(strcmp(param, "-code") == 0)
bool watch = strcmp(param, "-code-watch") == 0;
if(strcmp(param, "-code") == 0 || watch)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Micro-optimization: format as if(watch || strcmp(param, "-code") == 0) to prevent doing 2 strcmps when only 1 is needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough!

@nesbox nesbox merged commit 335d8cb into nesbox:tic_0.47.0 Oct 17, 2017
@nesbox nesbox added the enhancement Improvement of existing feature or adding something new label Oct 17, 2017
@nesbox nesbox added this to the 0.47.0 milestone Oct 17, 2017
@nesbox
Copy link
Owner

nesbox commented Oct 17, 2017

Pls don't forget to update the Wiki https://github.com/nesbox/TIC-80/wiki#command-line-arguments
Thanks @matheuslessarodrigues

@nesbox
Copy link
Owner

nesbox commented Oct 20, 2017

@matheuslessarodrigues
found a bug here #346
pls fix

@vamolessa
Copy link
Author

noted. should fix latter today!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing feature or adding something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants