Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#2629 closed enhancement (fixed)

[PATCH] Allow the ResourceDropsite to be modified through tech research

Reported by: Niek Owned by: leper
Priority: Should Have Milestone: Alpha 18
Component: UI & Simulation Keywords: technology dropsite patch
Cc: Patch:

Description

It would be nice to be able to modify which resources a Dropsite accepts through technology research.

This patch also includes a small fix the AI API to fix an undefined error which occured due to the ResourceDropsite fix.

The technology could look like this:

{
	"genericName": "Advanced Dropsite",
	"description": "Citizens are now able to drop food at the house",
	"cost": {"food": 0, "wood": 0, "stone": 0, "metal": 100},
	"requirements": {"tech": "phase_village"},
	"requirementsTooltip": "Unlocked in Village Phase.",
	"icon": "upgrade_advanced.png",
	"researchTime": 10,
	"tooltip": "Citizens are now able to drop food at the house",
	"modifications": [
		{"value": "ResourceDropsite/Types", "replace": "food"}
	],
	"affects": ["House"],
	"soundComplete": "interface/alarm/alarm_upgradearmory.xml"
}

The value ("food" in this case) should be a string to be accepted. Also the building that is being modified should have a ResourceDropsite/Types tag. But this tag is allowed to be empty e.g. this:

  <ResourceDropsite>
    <Types> </Types>
  </ResourceDropsite>

Attachments (4)

ResourceModify.patch (1.6 KB ) - added by leper 10 years ago.
patch that modifies both the API and the ResourceDropsite component
ResourceModify.2.patch (1.7 KB ) - added by Niek 9 years ago.
New patch
ResourceModify.3.patch (1.7 KB ) - added by Niek 9 years ago.
Removes curly bracket and uses a variable instead of copying over the whole expression
ResourceModify.4.patch (1.7 KB ) - added by Niek 9 years ago.
Without the 'if'-statement

Download all attachments as: .zip

Change History (20)

by leper, 10 years ago

Attachment: ResourceModify.patch added

patch that modifies both the API and the ResourceDropsite component

comment:1 by Stan, 10 years ago

Keywords: patch review added

comment:2 by leper, 10 years ago

Milestone: Alpha 17Alpha 18

comment:3 by leper, 9 years ago

Keywords: review removed

Splitting "" results in [""] which is not what is wanted here. Checking if it is empty before splitting and returning [] is what should be done.

The AI change would be nicer with an early return.

by Niek, 9 years ago

Attachment: ResourceModify.2.patch added

New patch

comment:4 by Niek, 9 years ago

Keywords: review added

comment:5 by Nikos, 9 years ago

Tested and it works perfectly fine. No errors and workers dropped food in the house.

comment:6 by scythetwirler, 9 years ago

Summary: [Patch] Allow the ResourceDropsite to be modified through tech research[PATCH] Allow the ResourceDropsite to be modified through tech research

comment:7 by scythetwirler, 9 years ago

Braces around line 24-26 can be removed.

Also, it'd be nicer to use another variable instead of copy and pasting the same long expression.

Last edited 9 years ago by scythetwirler (previous) (diff)

by Niek, 9 years ago

Attachment: ResourceModify.3.patch added

Removes curly bracket and uses a variable instead of copying over the whole expression

comment:8 by agentx, 9 years ago

Just a tip: If branching is not needed, don't use if.

if (this.types) == "") 
 	return []; 
	 
return this.types.split(/\s+/);

better:

return this.types === "" ? [] : this.types.split(/\s+/);

Avoids also the not matching brackets pitfall.

by Niek, 9 years ago

Attachment: ResourceModify.4.patch added

Without the 'if'-statement

comment:9 by scythetwirler, 9 years ago

Extra tab whitespace on line 379 of binaries/data/mods/public/simulation/ai/common-api/entity.js

in reply to:  9 comment:10 by Niek, 9 years ago

Replying to scythetwirler:

Extra tab whitespace on line 379 of binaries/data/mods/public/simulation/ai/common-api/entity.js

I should add one?

in reply to:  9 ; comment:11 by Niek, 9 years ago

Replying to scythetwirler:

Extra tab whitespace on line 379 of binaries/data/mods/public/simulation/ai/common-api/entity.js

I mean, the empty line has the same indentation as line 380 (which is correct I believe).

in reply to:  11 ; comment:12 by scythetwirler, 9 years ago

Replying to niektb:

Replying to scythetwirler:

Extra tab whitespace on line 379 of binaries/data/mods/public/simulation/ai/common-api/entity.js

I mean, the empty line has the same indentation as line 380 (which is correct I believe).

Not according to leper. :P

in reply to:  12 comment:13 by Niek, 9 years ago

Replying to scythetwirler:

Replying to niektb:

Replying to scythetwirler:

Extra tab whitespace on line 379 of binaries/data/mods/public/simulation/ai/common-api/entity.js

I mean, the empty line has the same indentation as line 380 (which is correct I believe).

Not according to leper. :P

I just checked and it isn't the case here :D

comment:14 by leper, 9 years ago

Owner: set to leper
Resolution: fixed
Status: newclosed

In 16003:

Allow techs to modify the resources that can be dropped of at dropsite. Patch by niektb. Fixes #2629.

comment:15 by leper, 9 years ago

Keywords: review removed

Thanks for the patch.

in reply to:  15 comment:16 by Niek, 9 years ago

Replying to leper:

Thanks for the patch.

Np, thank you for commiting.

Note: See TracTickets for help on using tickets.